API Documentation
One key for Claude / GPT / Gemini / DeepSeek. OpenAI-compatible — change base_url and go. Anthropic-compatible endpoint for Claude Code & PDF input. Official model names accepted.
1. Quick start
- Register at cocodot.co/register — verify email for $0.5 free credit.
- Create an API key in Console → AI.
- Point base_url at cocodot and call:
curl https://cocodot.co/api/ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-YOUR_KEY" \
-d '{
"model": "claude-opus-4-8",
"messages": [{"role": "user", "content": "Hello!"}]
}'Color legend: yellow = replace with your own value · green = model name · blue = cocodot endpoint (copy as-is)
2. Endpoints & auth
| Purpose | Endpoint | Auth |
|---|---|---|
| Chat (OpenAI-compatible) | POST /api/ai/v1/chat/completions | Authorization: Bearer sk-… |
| Messages (Anthropic-compatible) | POST /api/ai/v1/messages | x-api-key: sk-… or Bearer |
| Model dropdown (for clients) | GET /api/ai/v1/models | Public |
| Full list + live prices | GET /api/ai/models | Public |
Base URL for OpenAI SDKs / clients: https://cocodot.co/api/ai/v1 · For Anthropic SDK / Claude Code: https://cocodot.co/api/ai
3. Models, prices & official names
You can pass either the official model name or the cocodot short ID — both route, and bill, identically. Case-insensitive.
| Official name (examples) | Short ID | Model |
|---|---|---|
| claude-fable-5 | mcf-1 | Claude Fable 5 |
| claude-opus-4-8 | mco-6 | Claude Opus 4.8 |
| claude-sonnet-4-6 | mcs-5 | Claude Sonnet 4.6 |
| claude-haiku-4-5 | mch-1 | Claude Haiku 4.5 |
| gpt-5.5 | mog-6 | GPT-5.5 |
| gemini-3.1-flash-lite | mgg-10 | Gemini 3.1 Flash-lite |
| deepseek-chat | deepseek-v4-flash | DeepSeek V4 Flash |
| qwen | qwen3.5-flash | Qwen3.5 Flash |
| qwen3.5-35b-a3b | qwen3.5-35b-a3b | Qwen3.5 35B-A3B |
| qwen3.5-397b-a17b | qwen3.5-397b-a17b | Qwen3.5 397B-A17B |
| qwen-plus | qwen3.6-plus | Qwen3.6 Plus |
| glm | glm-5.2 | GLM-5.2 |
| glm-5.1 | glm-5.1 | GLM-5.1 |
Matching is by keyword — any name containing "opus" routes to Opus 4.8, "sonnet" to Sonnet, "gpt" to GPT-5.5, etc. Unknown names pass through to upstream unchanged. Full live list & per-token prices: GET https://cocodot.co/api/ai/modelsPrice list →Cost calculator →
🔥 Fable 5 (mcf-1) is Anthropic's newest flagship — direct access from China, no special params needed (we handle its zero-data-retention requirement automatically). · All models are capped at their official price; main models are 10% below it. Some models are tiered by input length — every tier is listed on the pricing page.
4. Code examples
Python(openai SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://cocodot.co/api/ai/v1",
api_key="sk-YOUR_KEY",
)
resp = client.chat.completions.create(
model="claude-opus-4-8", # official name OK; "mco-6" also works
messages=[{"role": "user", "content": "Write a haiku about the sea"}],
)
print(resp.choices[0].message.content)Node.js(openai SDK)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://cocodot.co/api/ai/v1",
apiKey: "sk-YOUR_KEY",
});
const resp = await client.chat.completions.create({
model: "gpt-5.5",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);Python(anthropic SDK,native Messages format)
from anthropic import Anthropic
client = Anthropic(
base_url="https://cocodot.co/api/ai", # note: no /v1 here
api_key="sk-YOUR_KEY",
)
msg = client.messages.create(
model="claude-opus-4-8",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(msg.content[0].text)More examples (LangChain / streaming / tool calling): github.com/cocodot2026/cocodot-api-examples ↗
5. Client setup
Every OpenAI-compatible client works. The four we get asked about most:
SillyTavern
- API → Chat Completion, source: Custom (OpenAI-compatible)
- Custom endpoint (Base URL):
https://cocodot.co/api/ai/v1· API key: yoursk-… - Click Connect — the model dropdown auto-fills (via /v1/models). Pick e.g. claude-opus-4-8 and chat.
Cursor
- Settings → Models → API Keys: paste your sk-… into "OpenAI API Key"
- Enable "Override OpenAI Base URL":
https://cocodot.co/api/ai/v1 - Add / tick the model names you want (claude-opus-4-8, gpt-5.5, …) and Verify.
Cline(VS Code)
- API Provider: "OpenAI Compatible"
- Base URL:
https://cocodot.co/api/ai/v1· API key: sk-… - Model ID: claude-opus-4-8 (or any official name).
Claude Code
export ANTHROPIC_BASE_URL=https://cocodot.co/api/ai
export ANTHROPIC_API_KEY=sk-YOUR_KEY
claude # then use Claude Code as usualModel names map automatically (fable → mcf-1, opus → mco-6, sonnet → mcs-5, haiku → mch-1). Details: /claude-code
6. Streaming
Pass stream: true — standard SSE, works with every OpenAI SDK. Usage is billed from upstream usage data (estimated from characters if upstream omits it).
stream = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "..."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")Standard OpenAI parameters pass through: temperature, top_p, max_tokens, stop, presence_penalty, frequency_penalty, seed, response_format (JSON mode), tools / tool_choice (function calling), stream_options (e.g. include_usage). Availability of advanced features depends on the selected model.
7. Tool calling & JSON mode
Function calling uses the standard OpenAI tools format and passes straight through — flagship Claude / GPT / Gemini models all support it.
resp = client.chat.completions.create(
model="claude-opus-4-8",
messages=[{"role": "user", "content": "What's the weather in Shanghai?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}],
)
# model decides to call the tool:
print(resp.choices[0].message.tool_calls)Force JSON output with response_format={"type": "json_object"} (remember to also ask for JSON in the prompt).
8. PDF / document input
Claude models can read PDFs directly — supported on the Anthropic-compatible /v1/messages endpoint via the document content block (base64).
import base64
from anthropic import Anthropic
client = Anthropic(base_url="https://cocodot.co/api/ai", api_key="sk-YOUR_KEY")
pdf_b64 = base64.b64encode(open("report.pdf", "rb").read()).decode()
msg = client.messages.create(
model="claude-opus-4-8",
max_tokens=2048,
messages=[{
"role": "user",
"content": [
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": pdf_b64}},
{"type": "text", "text": "Summarize this document"},
],
}],
)
print(msg.content[0].text)PDF pages are billed as input tokens (text + per-page image), same as Anthropic official. Request body limit 25 MB.
9. Billing & credits
- Pay-per-token from your cocodot balance (Alipay / card top-up). No subscription.
- $0.5 free credit on email verification — API-only. Trial credit unlocks budget models (DeepSeek / Qwen / Haiku etc.); top up to unlock Opus / GPT / Gemini flagships.
- Every call is itemized in Console → billing records (model / tokens / amount).
- Don't trust, verify — test any relay (including us) for model downgrading: probe.cocodot.co
10. Limits & errors
| Code | Meaning & fix |
|---|---|
| 401 | Invalid / missing API key — check the Bearer or x-api-key header. |
| 402 | Insufficient balance — top up in Console. |
| 403 | Trial credit is limited to budget models (DeepSeek / Qwen / Haiku). Top up to unlock Opus / GPT / Gemini. |
| 404 | Wrong path — most often a base_url mixup (see §2 warning). |
| 413 | Request body too large — limit 25 MB. |
| 400 | Bad request — unknown model ID or malformed body. |
| 5xx | Upstream hiccup — retry with backoff; contact support if persistent. |
11. FAQ & support
Official-relay via licensed cloud vendors (not reverse-engineered). Verify it yourself anytime: downgrade test — open-source methodology.
Anything OpenAI-compatible: SillyTavern, Cursor, Cline, LangChain, LobeChat, NextChat… plus Claude Code via the Anthropic endpoint. See §5.
Requests are relayed for inference only; we don't train on your data.
In-console support, or see guides · Why trust us