Switch Developer API
Build with Switch.
Call Switch’s generation models straight from your code. Every request lands in the same queue Studio uses, with the same receipt and the same tokens.
In plain English
One API call. Real images.
What you can build
Four ways in.
REST API
Generate from code
POST a prompt, a model, and a count. Images land in your Library and you poll one URL for the result.
MCP
Connect AI assistants
Point Claude, Cursor, or any MCP client at Switch. It can generate, search your library, and check your balance.
Command line
Run it from the terminal
The switch CLI fires the same API from scripts and automations. One login, machine-readable output.
References
Bring your own look
Attach a face or product reference. Your prompt drives the scene, lighting, and camera while the subject stays locked.
See it work
Say it. Get it.
One prompt
You write
“a sunset over Miami”
Switch runs
model: switch · count: 4Four images in your Library, ready to download.
A lookbook
You write
“front · side · three-quarter · over the shoulder”
Switch runs
model: nano_banana_2 · prompts: [ … ]A four-shot set of the same subject, one prompt each.
With a reference
You write
“a black silk gown on a marble staircase”
Switch runs
model: switch_ultra · references: [ face, body ]Your subject, kept consistent, in a brand-new scene.
Spend Center
Know what you're spending
Your spend comes with a paid membership.
See membershipsQuickstart
Your first call
task_id and a status_url you can poll.curl -X POST https://www.switchapp.ai/api/v1/tasks \ -H "Authorization: Bearer $SWITCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "switch", "prompt": "a sunset over Miami", "count": 1 }'
Authentication
Two kinds of credentials
Switch has two credential types. Which one you use depends on what you are calling, and full access uses both.
API key
sk_switch_live_…Unlocks the REST API
Image generation and account info over /api/v1/*: the curl examples above, plus the CLI image and whoami commands.
Create one in the API keys section below, then send it as Authorization: Bearer.
OAuth sign-in
browser loginUnlocks the MCP tools
Video, uploads, library search, balance and model listing: the tools exposed over the MCP server.
Used by MCP clients and by switch login --oauth. You sign in through the browser; there is no key to copy.
Rule of thumb: OAuth when your client can open a browser (Claude, Cursor, Codex). A key when it cannot: bots and scripts send the key as Authorization: Bearer to the same MCP endpoint and get every tool. Keys made from this page carry both the REST and the MCP scopes. An OAuth login will not work for the REST API.
Task creation
The request body
/api/v1/tasks takes a JSON body. Tasks are scoped to the key’s owner. Count caps at 10 per request.| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
| model | string (alias) | yes | . | One of the public aliases. See Model aliases. |
| prompt | string | yes (or prompts) | . | Single prompt repeated count times. |
| prompts | string[] | yes (or prompt) | . | Explicit per-image prompts. Length sets count automatically. |
| count | integer | no | 1 | 1 to 10. Ignored if prompts[] is set. |
| references | object[] | no | [] | { url: "https://…", type: "face" | "body" } |
| folder | string | no | "Generated" | Destination folder name in your Library. |
| quality | string | no | "2K" | 0.5K | 1K | 2K | 4K |
| scheduled_for | ISO 8601 | no | null | The task waits and runs at this time. |
API keys
Create and manage keys
Your keys comes with a paid membership.
See membershipsRevoke
Turn a key off
HTTP/2 401 { "error": { "code": "INVALID_KEY", "message": "Missing or invalid Switch API key. ..." } }
Revoking is permanent. Create a new key to replace it.
MCP connector
Let an AI assistant use Switch
Switch runs a hosted MCP server, so AI tools like Claude and Cursor can use Switch directly. There is nothing to install and no server to run. You point your client at the endpoint and sign in.
Endpoint
https://www.switchapp.ai/mcpConnect
Add the endpoint to your MCP client and sign in through the browser when prompted: that is the OAuth step. For step-by-step setup for Claude, ChatGPT, Claude Code, Codex, and Cursor . plus OAuth and troubleshooting, see the MCP setup guide. Then hand your assistant Build a brand. Make a commercial. . one markdown file that teaches any LLM the full Switch workflow: the questions to ask, how to load references, the prompt shape, and how Brand assets saves a reusable brand.
What it gives you
Once connected, the assistant can generate video, upload media, search your library, check your balance, and list available models, all against your own Switch account.
The MCP server is hosted by Switch, so you never run server code. Sign-in uses OAuth, or an API key from this page sent as a Bearer header for bots and scripts that cannot open a browser.
Voice & audio
Give your videos a voice
The same surface the Audio Studio room runs on: save voices, speak with them, build dialogue, and lip sync a video. These routes authenticate with your signed-in Switch session, so the quickest way to try them is the browser console on switchapp.ai. From an AI assistant or a script, connect the MCP connector , its voice tools drive these exact routes on your account.
The voice library, /api/audio/voices
One library for every saved voice. Each voice comes back with a kind: reference is an instant voice match saved from a clip (free, unlimited); clone is a trained voice.
- GET /api/audio/voicesList your voices, newest first. Query:
limit(up to 200),offset,q(name/tag search),kind. Returnsvoices[]withvoiceId,name,kind,ready,tagsand a short-livedsampleUrlpreview. - POST /api/audio/voicesSave a reference voice from a clip:
nameplusaudioBase64(with optionalformat) or a reachableaudioUrl, oraudioGenerationIdto reuse a Library clip. Clip of about 5 to 30 seconds, max 10MB. Free, ready instantly. - PATCH /api/audio/voicesRename or re-tag:
speakerId(the voiceId) plusnameand/ortags. - DELETE /api/audio/voicesRemove a voice:
speakerId. It disappears from every picker.
The routing rule
Reference voices speak through generate; trained voices speak through tts. Concretely: a kind: "reference" voice (ids starting ref_) goes to POST /api/audio/generate as audioRefs: [{ voiceId }] and bills 1 token per second of finished audio. A kind: "clone" voice goes to POST /api/audio/tts as speakerId and bills 1 token per line. Sending a reference voice to tts fails. Through the MCP connector this routing is handled for you, pass the voice’s name.
Speak, POST /api/audio/tts
Studio preset voices and trained voices. Body: text (up to 2048 chars) plus voiceType (a preset voice id) or speakerId (a trained voice . wins if both are sent). Delivery knobs: speechRate −50…100, pitch −12…12, loudnessRate −50…100 (0 is normal). format: mp3 or ogg_opus. Returns a playable url (7-day link), durationMs and generationId; the clip lands in your library. Costs 1 token per line.
Generative audio, POST /api/audio/generate
The richer sibling: narration, instant voice match, and multi-voice dialogue from one call. Body: text (up to 2048 chars) plus optional references, up to 3 of audioRefs: [{ voiceId | audioUrl | audioData }] (or plain audioRefUrls), addressed in the script as @Audio1 to@Audio3, or a single imageUrl to voice a scene from a picture (never both). Same speechRate / pitch / loudnessRate knobs. Output caps at 120 seconds and bills 1 token per second, reconciled to the real length, a 3-second clip never pays for 60. Returns url, durationSec and generationId.
Examples
// Signed in at www.switchapp.ai — run in the browser console. const r = await fetch('/api/audio/voices?limit=50', { credentials: 'include' }); const { voices } = await r.json(); // [{ voiceId: 'ref_…', name: 'My narrator', kind: 'reference', // ready: true, tags: [], sampleUrl: 'https://…' }, …] // kind decides the speak route, see "The routing rule" above. // Optional filters: ?q=narrator ?kind=reference|clone ?offset=50
From an AI assistant, the MCP tools
Connected through the MCP connector, four tools cover the whole flow:
- voiceYour voice library in one tool,
action:list,create(save a reference voice fromaudio_urloraudio_base64+voice_name),rename(voice_idtakes the id or current name, plusnew_name),clone(registers a talking-avatar voice, 2 credits),delete. - generate_audioSpeak any script. Pass the saved voice by NAME as
voice, reference voices, trained voices and presets are all routed correctly by kind. Or match instantly from clips withreference_audio_url(s)(up to 3,@Audio1to@Audio3for dialogue). Knobs:speech_rate−50…100,pitch−12…12,loudness−50…100. - upload_mediaTurn a local or attached clip into a clean URL, pass
urlorbase64+mime, then feed the returned url intovoice createorlip_sync_videoas the source. - lip_sync_videoMake the person in a video speak your audio. Simplest path:
action: "create"withengine: "best",video_urlandsound_file(whole-clip sync). Precise path:identify-face→createwith a face and timing →status. Source video mp4/mov, 2 to 60s, up to 100MB, 720p/1080p.
A lip sync render takes about 2 minutes; failed renders refund themselves. The finished video comes back at the source clip’s resolution and lands in your library and feed.
Rate limits
How much, how fast
count: 10 request uses 10 of your minute budget.60
images / minute
1,000
images / day
10
max count / request
Reference
Command line
Run Switch from your terminal
The switch CLI runs Switch from your terminal, handy for scripts and automation. It calls the same APIs as everything else; there is no second account or backend.
Install
npm install -g @switchapp/cli
Developer preview. The package is not published to npm yet, so this command does not work today; it is how you will install the CLI once it ships.
Log in
# REST: image generation + whoami switch login --key sk_switch_live_... # MCP: video, uploads, library switch login --oauth
See Authentication for which login unlocks which commands. Credentials are stored in ~/.switch/config.json.
Check your account
switch whoamiGenerate an image
switch image generate --prompt "a sunset over Miami" switch image status <task_id>
Troubleshooting
- 401 / invalid key: image generation needs an Ultra plan key. Create one in the API keys section below.
- “unknown tool” on video, upload, or library: those run over MCP; sign in with
switch login --oauthfirst. - 402 / out of tokens: top up your account, then retry.
Add --json to any command for machine-readable output.
Usage & budgets
Read spend, set budgets
Read your spend and set budgets from code, the same data the Spend Center shows. Send your API key as Authorization: Bearer.
GET /api/v1/usage
Spend today / this week / this month, your effective limit, remaining, a forecast, and a breakdown by model and by source.
Plain English: how much you've spent, how much is left, and where it went.
GET /api/v1/budget
Your configured budget plus the effective caps actually in force (the most restrictive of your budget, your agency cap, and any admin limit).
Plain English: what your spending limits are right now.
POST /api/v1/budget
Set daily / weekly / monthly caps. Body: { "daily_dollars": 200, "weekly_dollars": null, "monthly_dollars": 1000 }. A blank window means no cap there; a budget can only tighten an agency/admin cap, never loosen it.
Plain English: set the most you want to spend per day, week, or month.
# From the CLI (developer preview) switch usage # today's spend, limit, remaining, forecast switch budget set 200 # cap spending at $200/day switch budget show # see your current budget switch budget disable # remove your self-set budget
The CLI is in developer preview and not yet published to npm; these commands call the same endpoints above.
API examples
Curl examples
$SWITCH_API_KEY with the key from your API keys section.curl -X POST https://www.switchapp.ai/api/v1/tasks \ -H "Authorization: Bearer $SWITCH_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "switch", "prompt": "a sunset over Miami", "count": 1 }'
Models
Model aliases
| Alias | Model | Tokens / image |
|---|---|---|
| switch | Switch Model | 1 |
| switch_pro | Switch Pro | 2 |
| switch_ultra | Switch Ultra | 5 |
| nano_banana_2 | Nano Banana 2 | 4 |
| nano_banana_pro | Nano Banana Pro | 6 |
| gpt_image | GPT Image 2 | 3 |
| gpt_image_2 | GPT Image 2 | 3 |
| gpt_image_transparent | GPT Image 2 (transparent) | 3 |
| gpt_image_25 | GPT Image 2.5 | 1 / 3 / 8 |
| gpt_image_25_flare | GPT Image 2.5 Flare | 1 / 3 / 8 |
Errors
Error codes
{ error: { code, message } }.| Status | Code | Meaning |
|---|---|---|
| 400 | INVALID_JSON | Body is not valid JSON. |
| 400 | MODEL_REQUIRED | Body missing the model field. |
| 400 | PROMPT_REQUIRED | Provide prompt (string) or prompts (string[]). |
| 400 | BAD_COUNT | count must be an integer between 1 and 10. |
| 400 | BAD_QUALITY | quality must be 0.5K, 1K, 2K, or 4K. |
| 400 | BAD_REFERENCE_TYPE | Reference type must be face or body. |
| 400 | BAD_REFERENCE_URL | Reference URL must be valid, public, and http(s). |
| 400 | UNKNOWN_ALIAS | Model alias is not in the public set. |
| 400 | INACTIVE_MODEL | Alias resolved but production model is no longer active. |
| 400 | BAD_SCHEDULE | scheduled_for must be ISO 8601. |
| 401 | INVALID_KEY | Missing, malformed, or revoked API key. |
| 403 | INSUFFICIENT_SCOPE | Key lacks the tasks:create scope. |
| 403 | ULTRA_REQUIRED | Account is not Switch Ultra (or admin). |
| 429 | RATE_LIMITED | Per-minute or per-day budget exhausted. Retry-After header included. |
| 500 | AUTH_INTEGRITY | Temporary server error. Retry; contact support if it persists. |
| 500 | ENQUEUE_FAILED | Could not queue the task. Please retry. |
| 404 | TASK_NOT_FOUND | Task status or receipt was not found for this key owner. |