OpenKodo exposes three compatible API surfaces:
| Surface | Base URL | Typical clients |
|---|---|---|
| OpenAI Responses | https://api.openkodo.dev/v1 | Codex, OpenAI SDK, agent frameworks |
| OpenAI Chat Completions | https://api.openkodo.dev/v1 | OpenCode, Cline, Continue, OpenAI SDK |
| Anthropic Messages | https://api.openkodo.dev | Claude Code, Anthropic SDK |
Authentication
Send your OpenKodo key as a bearer token:
Authorization: Bearer ok_live_...
Anthropic clients may also send:
x-api-key: ok_live_...
Keys are scoped to your account and can be revoked at any time. Never expose a key in a browser or public repository.
List models
GET /v1/models
Authorization: Bearer ok_live_...
The response is OpenAI-compatible and every model also carries the limits an agent client needs when it configures itself, so nobody has to type a context window by hand:
{
"object": "list",
"data": [
{
"id": "deepseek-v4.1-flash-1017",
"object": "model",
"owned_by": "openkodo",
"name": "DeepSeek V4.1 Flash 1017",
"context_length": 1000000,
"max_output_tokens": 65536,
"max_completion_tokens": 65536,
"top_provider": {
"context_length": 1000000,
"max_completion_tokens": 65536,
"is_moderated": false
},
"architecture": {
"input_modalities": ["text", "image"],
"output_modalities": ["text"]
},
"supported_parameters": [
"stream", "max_tokens", "temperature", "top_p",
"tools", "tool_choice", "response_format",
"reasoning", "reasoning_effort"
],
"reasoning_efforts": ["none", "low", "high", "max"]
}
]
}
GET /v1/models/{id} returns the same object for one model.
| Field | Meaning |
|---|---|
context_length | Total prompt + output budget accepted by the model |
max_output_tokens / max_completion_tokens | Largest answer you can request |
supported_parameters | Request fields the model accepts, including reasoning_effort when it reasons |
reasoning_efforts | Accepted reasoning_effort values for this model |
DeepSeek models accept none, low, high and max; other reasoning models
accept low, medium and high. A model without the reasoning capability
omits both fields.
Responses API
POST /v1/responses
Content-Type: application/json
Authorization: Bearer ok_live_...
{
"model": "deepseek-v4-pro-0813",
"input": [
{"role": "user", "content": [{"type": "input_text", "text": "Review this diff."}]}
],
"stream": false
}
Responses requests are forwarded to the upstream Responses API and returned unchanged. Streaming, tools, and reasoning items are supported. Token usage is read from the upstream usage object, including cached input tokens.
Thinking mode
DeepSeek and GLM run in thinking mode by default, and reasoning tokens are
billed as output. If you set a small max_tokens the model can spend the whole
budget thinking and return an empty content with finish_reason: "length" —
that is expected, not a dropped response. Either raise max_tokens or pass:
{"thinking": {"type": "disabled"}}
Both the Chat and Responses surfaces forward this field to the upstream.
Chat Completions
POST /v1/chat/completions
Content-Type: application/json
Authorization: Bearer ok_live_...
{
"model": "deepseek-v4-pro-0813",
"messages": [
{"role": "system", "content": "You are a precise coding agent."},
{"role": "user", "content": "Refactor this function."}
],
"stream": true,
"max_tokens": 4096
}
Supported fields include messages, model, stream, max_tokens, temperature, top_p, stop, tools, tool_choice, and response_format where the upstream model supports them.
Streaming
Set "stream": true. OpenKodo forwards server-sent events and injects stream_options.include_usage so the final chunk includes token usage. Usage is deducted after the stream completes.
data: {"id":"...","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"...","choices":[],"usage":{"prompt_tokens":42,"completion_tokens":8}}
data: [DONE]
Tools
OpenAI-style tools are passed through:
{
"model": "glm-5.3",
"messages": [{"role": "user", "content": "What is the weather in Bangkok?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}
Anthropic Messages
POST /v1/messages
x-api-key: ok_live_...
anthropic-version: 2023-06-01
Content-Type: application/json
{
"model": "deepseek-v4-pro-0813",
"max_tokens": 1024,
"system": "You are a precise coding agent.",
"messages": [
{"role": "user", "content": "Write a migration for a users table."}
]
}
OpenKodo translates text, images, tool use, and tool results. Streaming is supported. Tool calls are delivered as Anthropic tool_use blocks.
Errors
OpenAI-style errors:
{
"error": {
"message": "Your credit balance is exhausted.",
"type": "billing_error",
"code": "insufficient_credits"
}
}
Anthropic-style errors:
{
"type": "error",
"error": {"type": "billing_error", "message": "Your credit balance is exhausted."}
}
Common status codes:
| Status | Meaning |
|---|---|
| 401 | Missing, invalid, or revoked key |
| 402 | Credit balance exhausted |
| 403 | Model not included in your plan |
| 404 | Unknown model |
| 429 | 5-hour request limit or concurrency limit |
| 502 | Upstream provider error |
| 503 | Provider not configured |
Rate limits
Each plan has a 5-hour usage cap, a request guardrail, and a concurrent request limit. The current values are shown on the pricing page and in the console. If you need higher limits, upgrade to Pro.
Usage headers
Non-streaming responses include:
X-OpenKodo-Request-Id
X-OpenKodo-Model
X-OpenKodo-Credits-Used-Micros
X-OpenKodo-Credits-Remaining-Micros
Both credit values are in micro-credits (1,000,000 = $1 of plan allowance).
Credits-Used-Micros is the amount actually deducted from your balance for that
request and Remaining is the balance after the deduction, so
remaining_before - remaining_after always equals used.
For streaming responses, the credit headers are sent as HTTP trailers.
Images, video, embeddings
The same key and billing work for the non-chat endpoints:
| Endpoint | Billed per | Notes |
|---|---|---|
POST /v1/images/generations | image | Standard OpenAI image request and response. size selects the 2K tier where the model has one. |
POST /v1/embeddings | input token | Standard OpenAI embeddings request and response. |
POST /v1/videos | second of output | Returns a job with id and status: queued. |
GET /v1/videos/{id} | — | Poll until completed or failed. |
GET /v1/videos/{id}/content | — | Returns the MP4. |
GET /v1/videos | — | Lists your jobs. |
Video is charged when the job is accepted, using the requested seconds and
resolution (480p, 720p, 1080p, 4k). If the provider reports failed,
the charge is returned to your plan or wallet automatically and the usage event
is voided. Images and embeddings are charged only after a successful response.
curl https://api.openkodo.dev/v1/videos \
-H "Authorization: Bearer $OPENKODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"kling-3.0","prompt":"a cat on the beach","seconds":"5","resolution":"720p"}'
Subscription usage (for quota plugins)
Status-bar plugins and editor extensions can show the same rolling meters the console shows, without scraping the HTML:
GET /api/plugin/usage
Authorization: Bearer ok_live_...
The key identifies the account; no other parameter is needed. The response is scoped to the caller and never contains routing or provider details.
{
"api_version": 1,
"plan": "Pro",
"plan_code": "pro",
"credits_remaining_micros": 201731189,
"credits_included_micros": 250000000,
"credits_per_5h_micros": 50000000,
"cost_5h_micros": 47200420,
"credits_per_week_micros": 100000000,
"cost_7d_micros": 48268811,
"requests_5h": 9056,
"requests_limit_5h": 112800,
"model_window": { "model": "deepseek-v4.1-flash-1017", "used": 9056, "limit": 112800 },
"model_windows": [{ "model": "deepseek-v4.1-flash-1017", "used": 9056, "limit": 112800 }],
"oldest_5h": "2026-11-30T11:11:44Z",
"oldest_7d": "2026-11-30T10:04:54Z",
"period_end": "2026-12-30T10:02:22Z",
"usage": { "requests": 0, "input_tokens": 0, "output_tokens": 0, "cost_micros": 0 }
}
How to read it:
- All money values are micro-dollars (
47200420=$47.200420). Divide by 1,000,000 before formatting. - The 5-hour and 7-day meters are rolling windows, not calendar buckets. The
percentage is
cost_5h_micros / credits_per_5h_micros(and the same for the week).oldest_5h/oldest_7dare when the oldest charge in each window ages out, i.e. when the percentage will start to fall even if you stop. period_endis the monthly reset.credits_remaining_microsis what is left in the shared pool right now.model_windowslists the per-model 5-hour request allowances, estimated from your plan's shared allowance and each model's rate, for models with traffic in the window;model_windowrepeats the one closest to its limit so a one-line badge does not have to pick.- Treat unknown fields as optional: new numbers may be added under the same
api_version.
Limits: this endpoint allows 60 requests per minute per account and the
response is cached for 10 seconds server-side (Cache-Control: private, max-age=5). Polling every 30-60 seconds is plenty. A faster poll still returns
the cached body; exceeding 60/min returns 429 with Retry-After.
Security: never embed a customer's key in a public web page or a shared binary. A plugin should ask the user for their key and store it in the OS keychain. The endpoint is read-only and cannot spend credit, but a leaked key can still be used for inference, so it must be revocable in the console.