API reference

One base URL. Every model.

Point any OpenAI or Anthropic SDK at unbottled.ai. Codex CLI and Claude Code too. Images, voice, video and music on the same key. No new client to learn.

126 chat modelsOpenAI + Anthropic formatStreaming and tool callsNo fixed rate limit
Get started

Quickstart

The API speaks the OpenAI and the Anthropic wire format. Code that runs against either runs here after two changes: the base URL and the key.

1
Create a key

Open API keys in your account, name the key, copy it. You see it once.

2
Set the base URL

Swap the base URL in your client. Anthropic clients take the second one.

OpenAI base URL
https://unbottled.ai/api/en-IN/v1

Any locale works in the path (en-US, de-DE, pl-PL). It only changes the language of error messages.

Anthropic base URL
https://unbottled.ai/api/en-IN

For Claude Code and Anthropic SDKs. No /v1 at the end: they add /v1/messages themselves.

Or set it once for every OpenAI SDK
export OPENAI_BASE_URL="https://unbottled.ai/api/en-IN/v1"
export OPENAI_API_KEY="sk-unb-YOUR_KEY"
3
Send a request

Paste it into a terminal, put your key in, run it. Same call in Python and JavaScript.

curl https://unbottled.ai/api/en-IN/v1/chat/completions \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "messages": [
      { "role": "system", "content": "You answer in one sentence." },
      { "role": "user", "content": "Why is the sky blue?" }
    ]
  }'
Example response
200
{
  "id": "chatcmpl-3f9c1a...",
  "object": "chat.completion",
  "created": 1767225600,
  "model": "kimi-k3.1-pro",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Air scatters blue light more than red." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "prompt_tokens_details": {"cached_tokens": 16, "cache_write_tokens": 0},
    "completion_tokens": 9,
    "total_tokens": 40,
    "credits_charged": 0.1
  }
}

Access and pricing

The API runs on the same credits as the chat app. No separate API plan, no seat fees.

What unlocks it
Any plan, from $8 a month. Every plan brings monthly credits.
Credits granted by our team, such as tester credits.
Free credits never unlock it: the monthly allowance, signup and newsletter bonuses, referral earnings.

Need more? Subscribers top up with credit packs from $5. Pack credits never expire.

Without a purchase

Accounts without a purchase cannot create keys, and every /v1 call answers HTTP 402 paid_plan_required.

Authentication

Send your key as a Bearer token on every request. Keys start with sk-unb-. Anthropic clients send it as x-api-key, and that works too.

Authorization: Bearer sk-unb-YOUR_KEY

We store a hash, not the key. Lose it and you create a new one.

A key works on the API only: /v1/models, chat (/v1/chat/completions, /v1/responses, /v1/messages) and media (/v1/images, /v1/audio, /v1/videos, /v1/music, /v1/media). It cannot touch your account, payments or settings.

Up to 20 active keys per account. Revoke any key at any time: it stops working at once.

No key or a revoked key returns 401. A key on an account without a purchase returns 402.

Chat

Chat completions

POST/v1/chat/completions

Standard OpenAI chat completions. Messages in, one assistant message out. Text and image inputs (image_url as https URL or base64 data URL).

Non-streaming

The default. You get one JSON body when the model is done. usage.credits_charged is what this call cost you.

Request
curl https://unbottled.ai/api/en-IN/v1/chat/completions \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "messages": [
      { "role": "system", "content": "You answer in one sentence." },
      { "role": "user", "content": "Why is the sky blue?" }
    ]
  }'
Example response
200
{
  "id": "chatcmpl-3f9c1a...",
  "object": "chat.completion",
  "created": 1767225600,
  "model": "kimi-k3.1-pro",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Air scatters blue light more than red." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "prompt_tokens_details": {"cached_tokens": 16, "cache_write_tokens": 0},
    "completion_tokens": 9,
    "total_tokens": 40,
    "credits_charged": 0.1
  }
}

Streaming

Set stream: true for server-sent events in the OpenAI chunk format, ended by data: [DONE]. Add stream_options.include_usage to get a final chunk with token counts and credits_charged. Closing the connection stops generation. You pay only for what ran.

Request
curl -N https://unbottled.ai/api/en-IN/v1/chat/completions \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "stream": true,
    "stream_options": { "include_usage": true },
    "messages": [{ "role": "user", "content": "Count to three." }]
  }'
Example stream
200
data: {"id":"chatcmpl-3f9c...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-3f9c...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"One, "},"finish_reason":null}]}

data: {"id":"chatcmpl-3f9c...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: {"id":"chatcmpl-3f9c...","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":7,"total_tokens":19,"credits_charged":0.1}}

data: [DONE]

Request fields

model
Required. A model id from GET /v1/models.
messages
Required. system, developer, user, assistant and tool messages. User content may be a string or text and image_url parts.
stream
true for server-sent events. Default false.
stream_options
{ include_usage: true } adds a final usage chunk.
max_tokens
Upper bound on generated tokens. max_completion_tokens takes precedence. Capped at 32768.
temperature
0 to 2. Ignored by models that do not support it.
top_p
0 to 1.
stop
A stop string or a list of them.
n
Only 1 is supported. Other values return 400.
tools
Function tools the model may call. See tool calling.
tool_choice
none, auto, required, or one named function.

Tool calling

Function calling works like OpenAI. You describe functions, the model decides to call one, you run it and send the result back. We never execute your tools.

The loop

Send tools with your messages.

The model answers with tool_calls and finish_reason: tool_calls. Each call has an id, a function name and JSON-string arguments.

Run the function yourself. Append the assistant message, then one tool message per call with its tool_call_id.

Call again. The model uses the results and answers.

1. Request with tools

Request
curl https://unbottled.ai/api/en-IN/v1/chat/completions \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "messages": [{ "role": "user", "content": "Weather in Berlin?" }],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Current weather for a city",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

2. The model asks for a call

200
{
  "object": "chat.completion",
  "model": "kimi-k3.1-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_8x2k",
            "type": "function",
            "function": { "name": "get_weather", "arguments": "{\"city\":\"Berlin\"}" }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ]
}

3. Return the result

Request
# Run get_weather yourself, then send the result back:
curl https://unbottled.ai/api/en-IN/v1/chat/completions \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "messages": [
      { "role": "user", "content": "Weather in Berlin?" },
      { "role": "assistant", "content": null, "tool_calls": [
        { "id": "call_8x2k", "type": "function",
          "function": { "name": "get_weather", "arguments": "{\"city\":\"Berlin\"}" } }
      ]},
      { "role": "tool", "tool_call_id": "call_8x2k", "content": "18C, cloudy" }
    ],
    "tools": [ ...same tools as before... ]
  }'

Streaming tool calls

With stream: true, calls arrive as delta.tool_calls chunks, addressed by index. The first chunk for an index carries id and function.name. Later chunks append to function.arguments. Concatenate them, then parse the JSON when finish_reason is tool_calls. Every OpenAI SDK does this for you.

Rules

The model must support tools: check supports_tools in GET /v1/models. Others return 400 tools_not_supported.

tool_choice none, auto and required work as in OpenAI. Naming a function that is not in tools returns 400.

Function names: letters, digits, underscore, dash, up to 64 characters.

Tool definitions and tool results are input tokens. Calls are output tokens. They bill like any other tokens.

Responses API

POST/v1/responses

The OpenAI Responses API, the format Codex CLI speaks. Same models, key, credits and rate limits as chat completions.

Request

input is a string or a list of input items. instructions is the system prompt. The answer arrives as output items. Every OpenAI SDK also gives you output_text.

Request
curl https://unbottled.ai/api/en-IN/v1/responses \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "instructions": "You answer in one sentence.",
    "input": "Why is the sky blue?"
  }'
Example response
200
{
  "id": "resp_7d2e...",
  "object": "response",
  "status": "completed",
  "model": "kimi-k3.1-pro",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        { "type": "output_text", "text": "Air scatters blue light more than red." }
      ]
    }
  ],
  "usage": { "input_tokens": 24, "output_tokens": 9, "total_tokens": 33 }
}

Streaming

Set stream: true for the Responses event stream: response.created, text deltas, then response.completed with usage.

Example stream
200
event: response.created
data: {"type":"response.created","response":{"id":"resp_7d2e...","status":"in_progress"}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"Air scatters "}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_7d2e...","status":"completed"}}

Tools: function, custom and local_shell. The model's calls come back as output items. Send each result back as a function_call_output item with the same call_id.

Reasoning models return reasoning items next to the answer.

Billing, model ids, errors and rate limits work exactly like chat completions.

Messages API

POST/v1/messages
POST/v1/messages/count_tokens

The Anthropic Messages API, the format Claude Code and the Anthropic SDKs speak. Use the base URL without /v1: clients add /v1/messages themselves.

Request

Standard Messages request: model, max_tokens, system, messages. Text and image blocks in, text and tool_use blocks out.

Request
curl https://unbottled.ai/api/en-IN/v1/messages \
  -H "x-api-key: sk-unb-YOUR_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3.1-pro",
    "max_tokens": 1024,
    "system": "You answer in one sentence.",
    "messages": [{ "role": "user", "content": "Why is the sky blue?" }]
  }'
Example response
200
{
  "id": "msg_01Hk...",
  "type": "message",
  "role": "assistant",
  "model": "kimi-k3.1-pro",
  "content": [{ "type": "text", "text": "Air scatters blue light more than red." }],
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 24, "output_tokens": 9 }
}

Streaming

Set stream: true for Anthropic server-sent events, from message_start to message_stop.

Example stream
200
event: message_start
data: {"type":"message_start","message":{"id":"msg_01Hk...","role":"assistant","content":[]}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Air scatters "}}

event: message_stop
data: {"type":"message_stop"}

Count tokens

POST /v1/messages/count_tokens counts the input tokens of a Messages request without running the model. Claude Code calls it to manage its context.

Request
curl https://unbottled.ai/api/en-IN/v1/messages/count_tokens \
  -H "x-api-key: sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "messages": [{ "role": "user", "content": "Why is the sky blue?" }]
  }'
Example response
200
{ "input_tokens": 14 }

Auth: x-api-key or Authorization: Bearer. Both take your sk-unb key.

Model: any id from GET /v1/models. The Anthropic ids Claude Code sends by default, like claude-sonnet-4-5-20250929, map to our matching Claude model.

Tools: tool_use blocks out, tool_result blocks back, as in the Anthropic API.

Same credits, same prices, same rate limits as every other endpoint.

Media

Images

POST/v1/images/generations
POST/v1/images/edits

OpenAI images format. Any model with modality image from GET /v1/models. Works with the images client of every OpenAI SDK.

Generate

Send JSON with these fields. The answer lists one url per image.

modelstring
Required. Any id with modality image from GET /v1/models.
promptstring
Required. What to draw, up to 2000 characters.
ninteger
Images per call, 1 to 4. Each one is billed.
sizestring
WIDTHxHEIGHT like 1024x1024, or auto. We pick the closest size the model renders.
aspect_ratiostring
Our extension: 1:1 | 16:9 | 9:16 | 4:3 | 3:4 | 3:2 | 2:3 | 21:9. Wins over size.
qualitystring
standard | hd | low | medium | high | auto. hd and high ask for the detailed tier where the model has one.
response_formatstring
url (default, a signed link valid 7 days) or b64_json.
Request
curl https://unbottled.ai/api/en-IN/v1/images/generations \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flux-3-klein",
    "prompt": "A lighthouse on a cliff at dawn, oil painting",
    "size": "1024x1024",
    "n": 1
  }'
Example response
200
{
  "created": 1767225600,
  "model": "flux-3-klein",
  "data": [
    { "url": "https://unbottled.ai/api/en-IN/v1/media/3f9c.../image-1.png?expires=1767830400&sig=..." }
  ],
  "credits_charged": 1.17
}

Edit an image

One input image plus a prompt. Upload it as multipart field image, or send image_url (https or base64 data URL) in JSON. The model must take image input: input_modalities contains image. Masks are not supported; describe the change in the prompt.

Request
curl https://unbottled.ai/api/en-IN/v1/images/edits \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -F model=flux-3-klein \
  -F prompt="Make it night, add a full moon" \
  -F image=@lighthouse.png

We pick the closest size and ratio the model renders.

url is a signed link to the stored file, valid 7 days without a key. b64_json returns the bytes inline.

Billed per image. credits_charged in the response says what the call cost.

Text to speech

POST/v1/audio/speech

Text in, audio bytes out. model is a voice id from GET /v1/models (modality speech), like openai-nova. OpenAI style also works: model tts-1 with voice nova.

Request
curl https://unbottled.ai/api/en-IN/v1/audio/speech \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai-nova",
    "input": "Your build finished. All tests are green.",
    "response_format": "mp3"
  }' \
  -o speech.mp3

input up to 4096 characters. speed 0.25 to 4 on OpenAI, NanoGPT and ElevenLabs voices.

response_format mp3 (default), opus, aac, flac, wav or pcm. Which ones a voice delivers depends on its provider; others answer 400 with the list.

Billed per character. The X-Credits-Charged header says what the call cost.

Transcription

POST/v1/audio/transcriptions
POST/v1/audio/translations

Speech to text, OpenAI Whisper format. Multipart upload, same SDK call you already use.

Transcribe

file up to 25 MB (mp3, mp4, m4a, wav, webm, ogg, flac), model like whisper-1, optional language. response_format json, text, srt, verbose_json or vtt.

Request
curl https://unbottled.ai/api/en-IN/v1/audio/transcriptions \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -F model=whisper-1 \
  -F file=@meeting.mp3 \
  -F response_format=json
Example response
200
{ "text": "Let's ship the release on Friday." }

Translate to English

POST /v1/audio/translations: any spoken language in, English text out. Runs on whisper-1. Same formats as transcriptions.

Request
curl https://unbottled.ai/api/en-IN/v1/audio/translations \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -F model=whisper-1 \
  -F file=@interview-de.mp3

Billed per second of audio.

Video

POST/v1/videos
GET/v1/videos/{id}
GET/v1/videos/{id}/content

Async, in the shape of OpenAI's video API. The call answers at once with a job. Poll it, then download the MP4.

Start a job

model, prompt, seconds, size or aspect_ratio, resolution, negative_prompt. The answer is a video object with status queued.

Request
curl https://unbottled.ai/api/en-IN/v1/videos \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan-2-7-t2v",
    "prompt": "A paper boat drifting down a rainy street, cinematic",
    "seconds": 5,
    "size": "1280x720"
  }'
Finished job object
200
{
  "id": "video_8f2c0e5a7b1d4c3e9a6f0b2d4e6a8c1f",
  "object": "video",
  "model": "wan-2-7-t2v",
  "status": "completed",
  "progress": 100,
  "seconds": "5",
  "size": "1280x720",
  "url": "https://unbottled.ai/api/en-IN/v1/media/<threadId>/video.mp4?expires=1767830400&sig=<signature>",
  "credits_charged": 42,
  "error": null
}

Poll and download

GET /v1/videos/{id} returns status (queued, in_progress, completed, failed), progress and, when done, a signed url. Polling is free and skips abuse limits. GET /v1/videos/{id}/content streams the MP4.

Request
# Poll until status is completed or failed (free, skipped by abuse guard)
curl https://unbottled.ai/api/en-IN/v1/videos/video_8f2c0e5a7b1d4c3e9a6f0b2d4e6a8c1f \
  -H "Authorization: Bearer sk-unb-YOUR_KEY"

# Download the MP4
curl https://unbottled.ai/api/en-IN/v1/videos/video_8f2c0e5a7b1d4c3e9a6f0b2d4e6a8c1f/content \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -o boat.mp4

Image to video: send image_url in JSON or input_reference as a multipart upload. It becomes the first frame.

Billed when the video is ready, per second of video. credits_charged shows the cost.

A failed job costs nothing. error says why.

Music

POST/v1/music
GET/v1/music/{id}
GET/v1/music/{id}/content

Async like video. Start a job, poll GET /v1/music/{id}, download GET /v1/music/{id}/content.

Start a job

Request
curl https://unbottled.ai/api/en-IN/v1/music \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "musicgen-stereo",
    "prompt": "Lo-fi hip hop, warm piano, slow vinyl crackle",
    "seconds": 20
  }'

Poll and download

Request
curl https://unbottled.ai/api/en-IN/v1/music/music_3b7d1f9a2c4e6a8b0d2f4a6c8e0b1d3f \
  -H "Authorization: Bearer sk-unb-YOUR_KEY"

curl https://unbottled.ai/api/en-IN/v1/music/music_3b7d1f9a2c4e6a8b0d2f4a6c8e0b1d3f/content \
  -H "Authorization: Bearer sk-unb-YOUR_KEY" \
  -o track.mp3

seconds: about 8, 20 or 30. The model may round it. Describe style, mood, instruments and tempo in prompt.

Billed per clip once it is ready. A failed job costs nothing.

Media files

GET/v1/media/{folder}/{file}

Every url in a media response points here. The signed link works without a key for 7 days, so you can hand it to a browser or a user. With your API key the same path works any time.

Request
# Signed link from a response: works without a key for 7 days
curl -o image.png "https://unbottled.ai/api/en-IN/v1/media/3f9c.../image-1.png?expires=1767830400&sig=..."

# Same file with your key, any time
curl -o image.png https://unbottled.ai/api/en-IN/v1/media/3f9c.../image-1.png \
  -H "Authorization: Bearer sk-unb-YOUR_KEY"
Reference

Models

GET/v1/models

GET /v1/models lists the models your key can call right now, with context size, tool support and credit prices per million tokens. Use the id as the model field in requests.

Request
curl https://unbottled.ai/api/en-IN/v1/models \
  -H "Authorization: Bearer sk-unb-YOUR_KEY"
Example response
200
{
  "object": "list",
  "data": [
    {
      "id": "kimi-k3.1-pro",
      "object": "model",
      "created": 1735689600,
      "owned_by": "moonshot",
      "name": "Kimi K3.1 Pro",
      "context_length": 131072,
      "supports_tools": true,
      "input_modalities": ["text"],
      "output_modalities": ["text"],
      "pricing": {
        "input_credits_per_million_tokens": 31.239000000000004,
        "output_credits_per_million_tokens": 1092.299,
        "cache_read_credits_per_million_tokens": 26,
        "cache_write_credits_per_million_tokens": null,
        "cache_write_1h_credits_per_million_tokens": null
      }
    }
  ]
}

The list depends on your account. Unknown or unavailable ids return 404 model_not_found. The one mapping: on /v1/messages, Claude ids that Claude Code sends by default go to our newest Claude of the same family.

Chat token prices

The pricing extension lists customer credits per million tokens at the base context tier, including markup. No field in this object is denominated in USD. A null value means no separate rate is listed.

input_credits_per_million_tokens
Uncached input.
output_credits_per_million_tokens
Generated text output.
cache_read_credits_per_million_tokens
Input read from the prompt cache.
cache_write_credits_per_million_tokens
Input written to the prompt cache at the default lifetime.
cache_write_1h_credits_per_million_tokens
Input written with a one-hour cache lifetime.

When pricing.tiers is present, use the same credit fields in the matching tier. min_prompt_tokens includes the threshold. utc_start and utc_end are UTC times in HHMM format, including the start and excluding the end.

Media models in the same list

Image, video, music, voice and transcription models sit in the same list. Each entry says what it does and where to call it.

media entry
{
  "id": "flux-3-klein",
  "object": "model",
  "owned_by": "blackForestLabs",
  "modality": "image",
  "endpoints": ["/v1/images/generations", "/v1/images/edits"],
  "input_modalities": ["text", "image"],
  "output_modalities": ["image"],
  "pricing": { "credits_per_image": 1.17 }
}

modality is chat, image, video, music, speech or transcription. endpoints lists the paths that take the model.

Media pricing is per unit: credits_per_image, credits_per_second (video), credits_per_clip (music), credits_per_1k_characters (speech), credits_per_minute (transcription).

Anthropic clients (anthropic-version header) get chat models only. Models whose provider is not set up on our side are not listed and answer 404 model_not_found.

Browse every model with prices and filters

Credits and billing

The API draws from the same credits as the chat app, billed by the same rules. One balance, one bill.

For a listed-price estimate, multiply each token count by its credit rate per million. Count each input token once as uncached, read or written.

Every response reports usage.credits_charged. Your balance is in the app under Credits.

Before a call runs we check your balance against a worst-case estimate. Not enough: HTTP 402 insufficient_credits, nothing runs, nothing is charged.

When the provider reports a charge, billing uses that charge plus markup. Otherwise it uses the applicable token rates. The final rounded charge is in usage.credits_charged.

Media calls bill the same way: the provider's real cost plus our markup where the provider reports it, the listed per-model price otherwise. Images bill per image, speech per character, transcription per second of audio, video when the clip is ready, music per clip.

Out of credits? Top up with a pack, renew or upgrade your plan. The next call works immediately.

402
HTTP/1.1 402 Payment Required
{
  "error": {
    "message": "Insufficient credits. This call needs about 1.2, you have 0.4. Top up to continue.",
    "type": "insufficient_quota",
    "param": null,
    "code": "insufficient_credits"
  }
}

Errors and rate limits

Errors use the OpenAI envelope, so SDKs raise their usual exceptions. Branch on error.code, not on the message.

Error body

{
  "error": {
    "message": "Invalid or revoked API key. ...",
    "type": "authentication_error",
    "param": null,
    "code": "invalid_api_key"
  }
}

Error codes

401missing_api_key
No key sent. Send Authorization: Bearer sk-unb-..., or x-api-key.
401invalid_api_key
Key is wrong or revoked.
402paid_plan_required
No purchase on the account yet. Any plan unlocks it.
402insufficient_credits
Balance too low for this call. Top up.
402free_tier_cap_reached
Paid balance is empty and today's free-credit cap is hit. Top up.
404model_not_found
Model does not exist or is not available to you.
400invalid_value / unsupported_parameter / tools_not_supported
Bad request: unsupported parameter, bad tool_choice, bad image URL.
400content_policy_violation
The media provider refused the prompt. Nothing is charged. Rephrase or pick another model.
403uncensored_consent_required
Uncensored models need a one-time 18+ confirmation on your account. Confirm it once on the API keys page, then retry.
429rate_limit_exceeded
Abuse protection triggered (burst or concurrent streams) or upstream provider 429. Read Retry-After and retry.
502upstream_error
The model provider failed. Safe to retry. Streams end with an error event.
503balance_unavailable
We could not read your balance, so nothing ran. Retry.
Errors that happen mid-stream arrive as a data: event with the same error object, followed by data: [DONE].

Rate limits

No fixed rate limit for paying accounts. Usage is billed per request from your credits, and calls stop with HTTP 402 when you run out. Generous abuse protection applies (a high burst ceiling and a concurrent stream cap) so runaway loops cannot overload the service. Upstream provider 429s pass through with their Retry-After header. If you get HTTP 429, back off for Retry-After seconds and retry.

429
HTTP/1.1 429 Too Many Requests
Retry-After: 12
{ "error": { "type": "rate_limit_error", "code": "rate_limit_exceeded", ... } }
Integrations

Coding tools

One base URL, one key. Codex CLI and Claude Code connect natively. OpenCode, Continue, Aider and Cline use chat completions. Pick your tool, copy the block, run it.

Paste the command and Codex runs on unbottled.ai. To keep it, append the block to ~/.codex/config.toml and start Codex with --profile unbottled.

One command
UNBOTTLED_API_KEY="sk-unb-YOUR_KEY" codex \
  -c 'model_providers.unbottled.name="unbottled.ai"' \
  -c 'model_providers.unbottled.base_url="https://unbottled.ai/api/en-IN/v1"' \
  -c 'model_providers.unbottled.env_key="UNBOTTLED_API_KEY"' \
  -c 'model_providers.unbottled.wire_api="responses"' \
  -c model_provider=unbottled \
  -m glm-5.3
Permanent setup
[model_providers.unbottled]
name = "unbottled.ai"
base_url = "https://unbottled.ai/api/en-IN/v1"
env_key = "UNBOTTLED_API_KEY"
wire_api = "responses"

[profiles.unbottled]
model_provider = "unbottled"
model = "glm-5.3"
Then start it
export UNBOTTLED_API_KEY="sk-unb-YOUR_KEY"
codex --profile unbottled
Tested with Codex CLI 0.118.0
Swap glm-5.3 for any id from GET /v1/models, like kimi-k3.1-pro, kimi-k3, uncensored-lm-v1.2. The API keys page shows the same blocks with your key already filled in.

SDK examples

The official OpenAI and Anthropic SDKs work unchanged. Set the base URL and the key, keep the rest of your code.

Chat

from openai import OpenAI

client = OpenAI(
    base_url="https://unbottled.ai/api/en-IN/v1",
    api_key="sk-unb-YOUR_KEY",
)

reply = client.chat.completions.create(
    model="kimi-k3.1-pro",
    messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(reply.choices[0].message.content)

Streaming

stream = client.chat.completions.create(
    model="kimi-k3.1-pro",
    messages=[{"role": "user", "content": "Count to three."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Responses API

reply = client.responses.create(
    model="kimi-k3.1-pro",
    input="Why is the sky blue?",
)
print(reply.output_text)

Anthropic SDK

import anthropic

client = anthropic.Anthropic(
    base_url="https://unbottled.ai/api/en-IN",
    api_key="sk-unb-YOUR_KEY",
)

reply = client.messages.create(
    model="kimi-k3.1-pro",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
# Reasoning models put a thinking block first: print the text block.
print(next(block.text for block in reply.content if block.type == "text"))

Images

import base64

img = client.images.generate(
    model="flux-3-klein",
    prompt="A lighthouse on a cliff at dawn, oil painting",
    response_format="b64_json",
)
open("lighthouse.png", "wb").write(base64.b64decode(img.data[0].b64_json))

Speech

# OpenAI names work too: model tts-1 plus voice nova is openai-nova.
audio = client.audio.speech.create(
    model="tts-1", voice="nova", input="Your build finished."
)
audio.write_to_file("speech.mp3")

Transcription

with open("meeting.mp3", "rb") as f:
    result = client.audio.transcriptions.create(model="whisper-1", file=f)
print(result.text)

Guides

Longer walkthroughs: switching from OpenAI or OpenRouter, uncensored models over the API, and wiring your key into coding tools.

Build on every model.

Create a key, point your SDK here, ship.