Reference
API reference
In short: The gateway supports OpenAI- and Anthropic-compatible endpoints; this reference covers base URLs, auth headers, streaming, tool calls and billing fields.
On this page
- What are the base URLs?
- How do I authenticate requests?
- Which endpoints are available?
- What is the chat completions endpoint?
- What goes in the request body?
- What does the chat response look like?
- What is the Responses API?
- What is the Messages endpoint?
- How do I list the models my key can call?
- Can I create embeddings?
- How does streaming work?
- Is tool calling supported?
- How is usage billed?
- What are the rate limits and timeouts?
- Which model ids work with each format?
The gateway is an implementation of the public OpenAI and Anthropic HTTP APIs, so official SDKs and most third-party clients work unchanged. This page lists what is supported, the fields that matter, and where behaviour differs from calling a provider directly.
What are the base URLs?#
The gateway has two base URLs: one for OpenAI-format clients and one for Anthropic-format clients.
| Format | Base URL | Used by |
|---|---|---|
| OpenAI | https://api.oneaiapikey.com/v1 | OpenAI SDKs, Codex CLI, Cursor, Cline, most editors |
| Anthropic | https://api.oneaiapikey.com | Anthropic SDKs, Claude Code |
All endpoints use HTTPS, accept and return JSON (UTF-8), and stream with server-sent events when stream is true.
How do I authenticate requests?#
You authenticate with an API key created in the console. A key works for both formats; send it in whichever header your client uses:
| Header | Format | Notes |
|---|---|---|
Authorization: Bearer sk-… | Both | Standard for OpenAI clients. Claude Code sends this when you set ANTHROPIC_AUTH_TOKEN. |
x-api-key: sk-… | Anthropic | What the Anthropic SDKs send by default. |
anthropic-version: 2023-06-01 | Anthropic | Required by the Messages API. SDKs add it automatically. |
Which endpoints are available?#
The gateway offers five endpoints, listed in the table below.
| Method | Path | Format | Purpose |
|---|---|---|---|
POST | /v1/chat/completions | OpenAI | Chat with any model. The most widely supported endpoint. |
POST | /v1/responses | OpenAI | OpenAI Responses API, used by Codex CLI and newer OpenAI SDK features. |
POST | /v1/messages | Anthropic | Anthropic Messages API, used by Claude Code and the Anthropic SDKs. |
GET | /v1/models | OpenAI | List the model ids your key can call. |
POST | /v1/embeddings | OpenAI | Vector embeddings, when an embedding model is enabled. |
What is the chat completions endpoint?#
https://api.oneaiapikey.com/v1/chat/completionsOpenAI formatChat completions is the universal endpoint. Every model in the catalogue that supports the OpenAI format can be called here, including Claude models, which the gateway translates for you.
What goes in the request body?#
The request body takes the fields below; only model and messages are required.
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Exact model id, for example gpt-6-luna:free. See models by format. |
messages | array | Yes | Conversation so far. Each item has a role (system, user, assistant, tool) and content. |
stream | boolean | No | Send tokens as server-sent events. Recommended for long outputs. |
stream_options | object | No | {"include_usage": true} adds a final chunk with token usage. |
max_tokens / max_completion_tokens | integer | No | Upper bound on generated tokens. Reasoning models prefer max_completion_tokens. |
temperature, top_p | number | No | Sampling controls. Some reasoning models ignore or reject them. |
tools, tool_choice | array, string | object | No | Function calling. See tool calling. |
response_format | object | No | Ask for JSON output ({"type": "json_object"} or a JSON schema) on models that support it. |
stop | string | array | No | Stop generating when one of these strings appears. |
Other standard OpenAI parameters are forwarded when the target model supports them. Unsupported parameters are either ignored or rejected with a 400 by the upstream model.
curl https://api.oneaiapikey.com/v1/chat/completions \
-H "Authorization: Bearer $ONEAIAPIKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna:free",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Give me three names for a CLI tool."}
],
"max_tokens": 200
}'What does the chat response look like?#
A successful call returns a 200 OK JSON body with the generated message and a usage object.
{
"id": "chatcmpl-9f2c…",
"object": "chat.completion",
"created": 1760000000,
"model": "gpt-6-luna:free",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "1. shipit\n2. tern\n3. relay"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 27,
"completion_tokens": 14,
"total_tokens": 41
}
}finish_reason is stop for a natural end, length when max_tokens was hit, and tool_calls when the model wants you to run a tool.
What is the Responses API?#
https://api.oneaiapikey.com/v1/responsesOpenAI formatThe Responses API is OpenAI's newer request shape (input instead of messages, typed output items). Codex CLI uses it by default. It is available for GPT-family models; for other families use chat completions.
curl https://api.oneaiapikey.com/v1/responses \
-H "Authorization: Bearer $ONEAIAPIKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna:free",
"input": "Summarise the Unix philosophy in one line."
}'resp = client.responses.create(
model="gpt-6-luna:free",
input="Summarise the Unix philosophy in one line.",
)
print(resp.output_text)const resp = await client.responses.create({
model: "gpt-6-luna:free",
input: "Summarise the Unix philosophy in one line.",
});
console.log(resp.output_text);What is the Messages endpoint?#
https://api.oneaiapikey.com/v1/messagesAnthropic formatThe Messages endpoint is the native Anthropic format, used by Claude Code and the Anthropic SDKs. Use it for models marked Anthropic format. Prefer it for Claude when you need Anthropic-specific features such as prompt caching controls, extended thinking blocks or exact stop_reason values.
Required fields: model, max_tokens and messages. Optional: system, stream, temperature, stop_sequences, tools, tool_choice, thinking. anthropic-beta headers are forwarded to the upstream.
curl https://api.oneaiapikey.com/v1/messages \
-H "x-api-key: $ONEAIAPIKEY_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "qwen-qwen3.8-27b:free",
"max_tokens": 1024,
"system": "You are a senior code reviewer.",
"messages": [{"role": "user", "content": "Review: def add(a, b): return a - b"}]
}'import os
import anthropic
client = anthropic.Anthropic(base_url="https://api.oneaiapikey.com", api_key=os.environ["ONEAIAPIKEY_API_KEY"])
msg = client.messages.create(
model="qwen-qwen3.8-27b:free",
max_tokens=1024,
system="You are a senior code reviewer.",
messages=[{"role": "user", "content": "Review: def add(a, b): return a - b"}],
)
print(msg.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.oneaiapikey.com", apiKey: process.env.ONEAIAPIKEY_API_KEY });
const msg = await client.messages.create({
model: "qwen-qwen3.8-27b:free",
max_tokens: 1024,
system: "You are a senior code reviewer.",
messages: [{ role: "user", content: "Review: def add(a, b): return a - b" }],
});
console.log(msg.content[0].text);{
"id": "msg_01H…",
"type": "message",
"role": "assistant",
"model": "qwen-qwen3.8-27b:free",
"content": [
{
"type": "text",
"text": "Bug: the function subtracts instead of adding. Use `return a + b`."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 31,
"output_tokens": 19,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}How do I list the models my key can call?#
https://api.oneaiapikey.com/v1/modelsOpenAI formatGET /v1/models returns the model ids your key is allowed to call. If a key has an allowed-model list, only those models appear.
curl https://api.oneaiapikey.com/v1/models \
-H "Authorization: Bearer $ONEAIAPIKEY_API_KEY"{
"object": "list",
"data": [
{
"id": "claude-opus-5-5",
"object": "model"
},
{
"id": "claude-sonnet-5",
"object": "model"
},
{
"id": "claude-haiku-4-5",
"object": "model"
}
]
}Can I create embeddings?#
https://api.oneaiapikey.com/v1/embeddingsOpenAI formatYes, when an embedding model is enabled for your account: the endpoint accepts the standard OpenAI embeddings request. It only works with embedding models; chat models return an error here. Check GET /v1/models to see whether an embedding model is enabled for your account before building on it.
curl https://api.oneaiapikey.com/v1/embeddings \
-H "Authorization: Bearer $ONEAIAPIKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<embedding-model-id>",
"input": ["first document", "second document"]
}'How does streaming work?#
Streaming works by setting "stream": true and reading the response as text/event-stream. Official SDKs handle parsing for you. If you parse by hand, split on blank lines, read the data: field, and ignore event types you do not recognise (for example keep-alive ping events).
data: {"id":"chatcmpl-1","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":""}}]}
data: {"id":"chatcmpl-1","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hel"}}]}
data: {"id":"chatcmpl-1","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"lo"}}]}
data: {"id":"chatcmpl-1","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-1","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":2,"total_tokens":14}}
data: [DONE]event: message_start
data: {"type":"message_start","message":{"id":"msg_1","role":"assistant","content":[],"usage":{"input_tokens":12,"output_tokens":1}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":2}}
event: message_stop
data: {"type":"message_stop"}- OpenAI format ends with
data: [DONE]. Add"stream_options": {"include_usage": true}to receive token usage in the last chunk. - Anthropic format ends with
message_stop; token usage arrives inmessage_startandmessage_delta. - An error that happens mid-stream arrives as an error event; treat the partial output as incomplete.
Is tool calling supported?#
Yes. Function and tool calling work on models that support them upstream (all current Claude and GPT models in the catalogue). Send tool definitions in the format of the endpoint you are calling; the gateway translates between formats when a Claude model is called through the OpenAI endpoint.
{
"model": "gpt-6-luna:free",
"messages": [
{
"role": "user",
"content": "What is the weather in Pune?"
}
],
"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"
}{
"model": "qwen-qwen3.8-27b:free",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "What is the weather in Pune?"
}
],
"tools": [
{
"name": "get_weather",
"description": "Current weather for a city",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
]
}- The model replies with
tool_calls(OpenAI) or atool_usecontent block (Anthropic). - Your code runs the tool and sends the result back: a
toolrole message with the matchingtool_call_id, or atool_resultblock with the matchingtool_use_id. - The model continues with the result. Each round trip is a separate, separately billed request.
How is usage billed?#
Usage is billed by tokens: every successful response reports the tokens you were charged for. Your prepaid balance is reduced by input tokens × input rate + output tokens × output rate, using the per-million-token rates on the models page. Cached input tokens are billed at the lower cached rate where a model has one.
| Meaning | OpenAI format | Anthropic format |
|---|---|---|
| Input tokens | usage.prompt_tokens | usage.input_tokens |
| Output tokens | usage.completion_tokens | usage.output_tokens |
| Cached input read | usage.prompt_tokens_details.cached_tokens | usage.cache_read_input_tokens |
| Cache write | n/a | usage.cache_creation_input_tokens |
| Reasoning / thinking | Included in completion_tokens | Included in output_tokens |
Worked example. A Qwen3.8 27B request with 12,000 input tokens and1,500 output tokens costs $0.0168 for input ($1.40 per 1M) plus$0.0105 for output ($7 per 1M), so $0.0273 in total.
The console shows your live balance and a per-request log with model, tokens and cost, so you can reconcile any charge. Requests rejected by the gateway (invalid key, no balance, unknown model) are not charged.
What are the rate limits and timeouts?#
Rate limits apply per account and per key, and a silent non-streaming connection is closed after about 100 seconds.
- Rate limits. Requests are rate-limited per account and per key to keep shared capacity fair. Interactive use and coding agents stay well inside the limits. If you exceed them you receive
429; back off and retry as described in Errors & limits. - Upstream limits. Providers occasionally throttle a model under heavy load. These also surface as
429or503and are safe to retry. - Non-streaming timeout. Network proxies close connections that stay silent for about 100 seconds. A long non-streaming request can therefore fail even though the model was still working. Use
stream: truefor long outputs and reasoning models. - Client timeouts. When streaming, set your HTTP client timeout to several minutes so slow but healthy streams are not cut short by your own code.
Planning sustained high volume (batch jobs, many parallel agents)? Email support@oneaiapikey.com before launch so we can confirm capacity.
Which model ids work with each format?#
The table lists the exact ids to send in the model field, and which endpoint family each one accepts. Rates are USD per 1M tokens. "Unavailable" models are listed with their rate but have no working upstream right now, so requests to them fail.
| Model id | OpenAI | Anthropic | In / Out |
|---|---|---|---|
| claude-opus-5-5ClaudeUnavailable | ✓ | ✓ | $2.80 / $14 |
| claude-sonnet-5ClaudeUnavailable | ✓ | ✓ | $2 / $10 |
| claude-haiku-4-5ClaudeUnavailable | ✓ | ✓ | $1 / $5 |
| gpt-6.1-solGPTUnavailable | ✓ | – | $0.70 / $3.50 |
| gpt-6-astraGPTUnavailable | ✓ | – | $3.50 / $17.50 |
| gpt-5.6-solGPTUnavailable | ✓ | – | $4 / $20 |
| gpt-5.6-terraGPTUnavailable | ✓ | – | $2 / $12 |
| grok-4.6GrokUnavailable | ✓ | – | $2 / $6 |
| claude-sonnet-5-5ClaudeUnavailable | ✓ | ✓ | $1.40 / $7 |
| grok-4.7GrokUnavailable | ✓ | – | $1.40 / $4.20 |
| deepseek-v4-flashDeepSeekUnavailable | ✓ | – | $0.0392 / $0.0784 |
| deepseek-v4-proDeepSeekUnavailable | ✓ | – | $0.49 / $0.98 |
| kimi-k3KimiUnavailable | ✓ | – | $0.353 / $5.67 |
| glm-5.3GLMUnavailable | ✓ | – | $0.396 / $0.77 |
| minimax-m3MiniMaxUnavailable | ✓ | – | $0.161 / $0.672 |
| glm-5.3-flashGLMUnavailable | ✓ | – | $0.07 / $0.21 |
| qwen3.8-27b:freeQwenUnavailable | ✓ | – | $0.00 / $0.00 |
| qwen3.8-27b-1:freeQwenUnavailable | ✓ | – | $0.00 / $0.00 |
| stepaudio-3-chat-preview:freeStep | ✓ | – | $0.00 / $0.00 |
| step-5:freeStep | ✓ | – | $0.00 / $0.00 |
| gpt-6-luna:freeGPT | ✓ | – | $0.00 / $0.00 |
| gpt-6.2-astra:freeGPTUnavailable | ✓ | – | $0.00 / $0.00 |
| gpt-6-luna-1:freeGPTUnavailable | ✓ | – | $0.00 / $0.00 |
| gpt-6.2-astra-1:freeGPTUnavailable | ✓ | – | $0.00 / $0.00 |
| nvidia-deepseek-v4-1-flash:freeDeepSeek | ✓ | – | $0.00 / $0.00 |
| minimaxai-minimax-m3-1-flash:freeMiniMax | ✓ | – | $0.00 / $0.00 |
| deepseek-v4-flash-0731-thinking:freeDeepSeek | ✓ | – | $0.00 / $0.00 |
| deepseek-v4-flash-0731:freeDeepSeek | ✓ | – | $0.00 / $0.00 |
| deepseek-v4-flash-0731-1:freeDeepSeek | ✓ | – | $0.00 / $0.00 |
| beam-1-0:freeBeam | ✓ | – | $0.00 / $0.00 |
| qwen-qwen3.8-27b:freeQwen | ✓ | – | $0.00 / $0.00 |
| qwen3.8-27b-uncensored:freeQwen | ✓ | – | $0.00 / $0.00 |
| dealignai-glm-5.3-flash-uncensored-fp8:freeGLM | ✓ | – | $0.00 / $0.00 |
| nvidia-nemotron-3-ultra-550b-a55b:freeNemotron | ✓ | – | $0.00 / $0.00 |
| z-ai-glm-5.3:freeGLM | ✓ | – | $0.00 / $0.00 |
| deepseek-deepseek-v4.1-flash:freeDeepSeek | ✓ | – | $0.00 / $0.00 |
| z-ai-glm-5.3-flash:freeGLM | ✓ | – | $0.00 / $0.00 |
| ernie-5.5-flash-preview:freeERNIE | ✓ | – | $0.00 / $0.00 |
| glm-4.6v-flash:freeGLM | ✓ | – | $0.00 / $0.00 |
| glm-4.7-flash:freeGLM | ✓ | – | $0.00 / $0.00 |
| hy4-flash:freeHunyuan | ✓ | – | $0.00 / $0.00 |
| dealignai-deepseek-v4.1-flash-uncensored-fp8:freeDeepSeek | ✓ | – | $0.00 / $0.00 |
| dealignai-glm-5.3-uncensored-fp8:freeGLM | ✓ | – | $0.00 / $0.00 |
| moonshotai-kimi-k3.1-pro:freeKimi | ✓ | – | $0.00 / $0.00 |
| deepseek-v4-flash:freeDeepSeek | ✓ | – | $0.00 / $0.00 |
| ernie-5.5-flash-preview-1:freeERNIE | ✓ | – | $0.00 / $0.00 |
| ernie-5.5-flash-preview-2:freeERNIE | ✓ | – | $0.00 / $0.00 |
| gemma-4-31b-it:freeGemma | ✓ | – | $0.00 / $0.00 |
| gemma4-31b:freeGemma | ✓ | – | $0.00 / $0.00 |
| laguna-xs-2.1:freeLaguna | ✓ | – | $0.00 / $0.00 |
| lfm-3-1-7b:freeLFM | ✓ | – | $0.00 / $0.00 |
| longcat-2.5:freeLongCat | ✓ | – | $0.00 / $0.00 |
| laguna-xs-2.1-1:freeLaguna | ✓ | – | $0.00 / $0.00 |
| laguna-xs-2.1-uncensored:freeLaguna | ✓ | – | $0.00 / $0.00 |
| llama-3.3-70b-instruct:freeLlama | ✓ | – | $0.00 / $0.00 |
| nemotron-3-nano-omni-30b-a3b-reasoning:freeNemotron | ✓ | – | $0.00 / $0.00 |
| nemotron-3.5-super-vl:freeNemotron | ✓ | – | $0.00 / $0.00 |
| nemotron-3-5-lightning:freeNemotron | ✓ | – | $0.00 / $0.00 |
| nvidia-nemotron-3-ultra-550b-a55b-1:freeNemotron | ✓ | – | $0.00 / $0.00 |
| solar-mini4:freeSolar | ✓ | – | $0.00 / $0.00 |
| nemotron-3-ultra-550b-a55b-uncensored:freeNemotron | ✓ | – | $0.00 / $0.00 |
| jais-3-mova-36b-a4b:freeJais | ✓ | – | $0.00 / $0.00 |
| nvidia-mistral-large-4-1t-a52b:freeMistral | ✓ | – | $0.00 / $0.00 |
| k2-horizon-375b-a23b-uncensored:freeK2 | ✓ | – | $0.00 / $0.00 |
| k2-horizon-375b-a23b:freeK2 | ✓ | – | $0.00 / $0.00 |
| glm-4.6v-flash-1:freeGLM | ✓ | – | $0.00 / $0.00 |
| glm-4.7-flash-1:freeGLM | ✓ | – | $0.00 / $0.00 |
| grok-4.7-fast:freeGrok | ✓ | – | $0.00 / $0.00 |
| roleplay-chat:freeRoleplay | ✓ | – | $0.00 / $0.00 |
| claude-fable-5-1ClaudeUnavailable | ✓ | – | $7 / $35 |
| gemini-4-argonGeminiUnavailable | ✓ | – | $0.525 / $2.63 |
| muse-wonderMuseUnavailable | ✓ | – | $2.80 / $14 |
| mimo-v2.6-proMiMoUnavailable | ✓ | – | $0.3045 / $0.609 |
| step-5-previewStepUnavailable | ✓ | – | $0.70 / $1.89 |
| claude-haiku-5-5ClaudeUnavailable | ✓ | – | $0.07 / $0.35 |
| muse-spark-openMuseUnavailable | ✓ | – | $0.875 / $2.98 |
| mistral-large-4MistralUnavailable | ✓ | – | $0.476 / $1.43 |
| gpt-6-lunaGPTUnavailable | ✓ | – | $0.035 / $0.175 |