API quickstart
/ API docsOpenCheese AI is an AI gateway with OpenAI-compatible and Anthropic-compatible APIs. One OpenCheese API key reaches every model enabled for your account, including free models, and every request is recorded with its token usage and cost in the dashboard.
Every page of these docs is also available as Markdown: add .md to its address, for example
/en/docs.md for this page.
01Create an API key
Sign in at opencheese.dev, open API keys and create a key. Keep it on the server: never ship a privileged key in public frontend code.
02API host and base URLs
The gateway is served from https://api.opencheese.dev, a different host from the website.
Requests sent to opencheese.dev return the website, not an API response.
| Client | Base URL |
|---|---|
| OpenAI SDKs and OpenAI-compatible clients (OpenCode, Codex, Harness AI, Zed, Chatbox, RikkaHub) | https://api.opencheese.dev/v1 |
| Anthropic SDKs and Anthropic-compatible clients (Claude Code, Claude Desktop) | https://api.opencheese.dev |
Anthropic SDKs append /v1/messages themselves, so their base URL must not end in /v1. A
few apps ask for the address up to /v1 even in their Anthropic mode; each app's guide below
says which form it needs.
03Authentication
Send the key as a Bearer token:
Authorization: Bearer YOUR_OPENCHEESE_API_KEY
Anthropic-style clients may send it as x-api-key: YOUR_OPENCHEESE_API_KEY instead.
The examples read the key from OPENCHEESE_API_KEY. The key contains $ characters, so set
the variable in single quotes, which leave them alone (double quotes would expand them and
break the key):
export OPENCHEESE_API_KEY='YOUR_OPENCHEESE_API_KEY'
In PowerShell: $env:OPENCHEESE_API_KEY = 'YOUR_OPENCHEESE_API_KEY'.
04List the models your key can use
curl https://api.opencheese.dev/v1/models \
-H "Authorization: Bearer $OPENCHEESE_API_KEY"
Use an id from this list. Access depends on your plan and the key's model restrictions, so
do not copy model IDs from old examples. The Models API page explains
every field.
05Send a first request
OpenAI Chat Completions:
curl https://api.opencheese.dev/v1/chat/completions \
-H "Authorization: Bearer $OPENCHEESE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "MODEL_ID", "messages": [{"role": "user", "content": "Hello"}]}'
Anthropic Messages:
curl https://api.opencheese.dev/v1/messages \
-H "x-api-key: $OPENCHEESE_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "MODEL_ID", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'
With the OpenAI Python SDK:
from openai import OpenAI
client = OpenAI(base_url="https://api.opencheese.dev/v1", api_key="YOUR_OPENCHEESE_API_KEY")
reply = client.chat.completions.create(
model="MODEL_ID",
messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)
06Keep a conversation together
Send the same opencheese-session-uuid header with every request of one conversation, so the
dashboard shows it as one session. A request without it is a session of its own. See
Sessions for when to send it.
Endpoints
| Endpoint | Protocol | Use |
|---|---|---|
GET /v1/models |
OpenAI | Models available to the key |
POST /v1/chat/completions |
OpenAI | Chat, streaming and tools |
POST /v1/responses |
OpenAI Responses | Responses clients such as Codex |
POST /v1/messages |
Anthropic | Claude Code and Anthropic SDKs |
POST /v1/messages/count_tokens |
Anthropic | Token counting, not billed |
POST /v1/images/generations |
OpenAI Images | Generate images |
POST /v1/images/edits |
OpenAI Images (multipart) | Edit images |
GET /v1/images/capabilities |
OpenCheese | Image model parameters |
GET /v1/key |
OpenCheese | The key's spending limit and usage |
GET /v1/plan |
OpenCheese | Plan windows and balance options |
GET /v1/balance |
OpenCheese | Balance and this month's usage |
Capabilities such as streaming, tools, image input and reasoning levels vary by model: check
the model in /v1/models before depending on one.
Every page
Get started
- Sessions: One conversation, one session: the opencheese-session-uuid header.
API reference
- Models: GET /v1/models and what each field means.
- Chat Completions: POST /v1/chat/completions: streaming, tools, images, effort.
- Responses: POST /v1/responses: input, streaming events, tools.
- Messages: POST /v1/messages and /v1/messages/count_tokens.
- Images: Generate and edit images with the OpenAI Images API.
- Key, plan and balance: GET /v1/key, /v1/plan and /v1/balance.
- Errors and limits: Error shapes, codes, rate limits and retries.
Coding tools
- Claude Code: ANTHROPIC_BASE_URL, API key and model aliases in settings.json.
- Claude Desktop: Third-party inference mode with an imported configuration file.
- Codex: A config.toml model provider on the Responses API.
- OpenCode: Auto-sync, or an OpenAI-compatible provider in opencode.json.
- Harness AI: A custom provider, plus reasoning levels in settings.yaml.
- Zed: An openai_compatible provider in settings.json.
- VS Code and JetBrains: The Claude Code and Codex extensions, on the CLI settings.
Chat apps
- RikkaHub: An OpenAI or Claude provider in the Android app.
- Chatbox: An OpenAI API compatible provider, on phone or desktop.
- LobeHub: A provider entry with the right address for each format.
Errors
Most errors return an HTTP status with a JSON error body. On /v1/chat/completions, problems
you need to act on (an invalid key, a plan limit, an empty balance) arrive as the assistant's
reply so chat apps show the message to you. Errors and rate limits lists
every code.
Plans and prices
Plans are listed on the home page. Per-model prices are on the dashboard's Prices page after you sign in.
More help
- FAQ: setup, models, plans, payments and troubleshooting.
- Support Chat in the dashboard, or service@opencheese.dev.