# Use Xantly with Zapier (OpenAI connector)

[Zapier](https://zapier.com)'s **OpenAI** app lets you call chat completions inside Zaps. It supports a "Custom Base URL" field in the connection settings, pointing it at Xantly gives every Zap action BaRP routing, semantic cache, and memory. Good fit for high-volume automated workflows where the same prompt-shape fires thousands of times per day.

## Prerequisites

- A Zapier account (any plan, OpenAI app works on free)
- A Xantly API key, [create one](/dashboard/api-keys)

## Setup

1. In Zapier, create a new Zap.
2. For the Action step, search **OpenAI** → pick **Conversation** (chat completions).
3. Under **Account**, click **Connect a new OpenAI account**.
4. Fill in:

| Field | Value |
|---|---|
| API Key | `xantly_sk_...` |
| API Base | `https://api.xantly.com/v1` |

5. Click **Yes, Continue**.

Every subsequent OpenAI-app action in your Zaps now routes through Xantly.

## Build the action

1. **User Message**: (your dynamic input from the trigger)
2. **Model**: `xantly/auto-value` (speed matters in Zaps, fast + cheap is usually best)
3. **Assistant Instructions**: whatever system prompt you need
4. **Memory Key** / **Max Tokens** / etc.: as needed

Test the Zap, Xantly logs the call with routing + cost.

## High-volume patterns

Zapier's sweet spot is workflows that fire many times per day. These benefit heavily from Xantly's cache:

- **Email classifier** (categorize inbound mail), 500 calls/day, 60%+ cache hit rate.
- **Lead qualification** (score inbound forms), same pattern.
- **Customer support tagger** (tag inbound tickets), often identical prompt templates with different data.

Typical savings: **40-70% vs pointing Zapier directly at OpenAI** when cache hits kick in.

## Webhooks step for advanced use

If the OpenAI app doesn't expose a setting you need (custom headers, e.g. for `X-Xantly-Memory-Mode`), use **Webhooks by Zapier** → **POST**:

| Field | Value |
|---|---|
| URL | `https://api.xantly.com/v1/chat/completions` |
| Payload Type | JSON |
| Headers | `Authorization: Bearer xantly_sk_...`<br/>`X-Xantly-Memory-Mode: cache` |
| Data | `{ "model": "xantly/auto-speed", "messages": [...] }` |

This gives you the full Xantly feature set including memory modes.

## Model choice

| Model ID | When |
|---|---|
| `xantly/auto-speed` | Email/form classifiers, speed-tier is plenty. |
| `xantly/auto-value` | Balanced, default for most Zaps. |
| `xantly/auto-quality` | Complex Zaps (summarizing long emails, drafting responses). |
| `openai/gpt-5.4` | Pin OpenAI for schema-strict outputs. |

For high-frequency Zaps, **don't use `xantly/auto-quality`** unless you need it, speed/value tiers are 5-10× cheaper and good enough for classification / short rewriting.

## Verify

1. Create a trivial Zap: **Schedule by Zapier** (every hour) → **OpenAI Conversation** (Xantly account, model `xantly/auto-speed`, message `"say pong"`).
2. Run once manually.
3. Check the Xantly dashboard, call logged with routing + cost.

## What you get

- **Massive cache savings.** Classifiers and templated Zaps see 50-80% cache hit rates. Your bill shrinks accordingly.
- **Waterfall fallback.** Provider outages don't kill scheduled Zaps overnight.
- **Cost per Zap.** Create a separate Xantly API key per Zap (`zap-leadqualifier`, `zap-emailtagger`) and track spend per workflow.
- **Budget caps per Zap**: protect yourself from a runaway trigger.
- **Memory** via Webhooks step for Zaps that need cross-run recall.

## Gotchas

**Zapier caches the OpenAI account connection.** After changing the base URL or API key, test the Zap action once to force a reconnect, otherwise old values linger.

**`/v1` required in API Base.**

**Rate limits.** Zapier itself throttles tasks per plan. If you're on free/starter plan, you won't hit Xantly's rate limits before Zapier's, but on Pro/Company, you might. Check your Xantly plan's RPM limit.

**The built-in AI by Zapier step is different.** Zapier also ships their own "AI" step (branded as Zapier AI). That one doesn't expose base URL, only their hosted OpenAI pass-through. Use the plain **OpenAI** app instead.

**Long responses timeout.** Zapier action steps have a 30-second hard cap. For long responses, either use a shorter `max_tokens` or break the task across multiple steps.

## Next steps

- [n8n](/docs/use-with-n8n), self-hostable alternative with more power.
- [OpenAI SDK (TypeScript)](/docs/use-with-openai-sdk-typescript), for custom Zapier apps.
- [Cost-Optimized Routing](/docs/cost-optimized-routing), critical at automation scale.
- [Bring Your Own Key](/docs/bring-your-own-key), route Zapier through your own OpenAI credits.
