Skip to navigation
DocsAPI reference

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.

Updated View .md
On this page

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.

FormatBase URLUsed by
OpenAIhttps://api.oneaiapikey.com/v1OpenAI SDKs, Codex CLI, Cursor, Cline, most editors
Anthropichttps://api.oneaiapikey.comAnthropic 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:

HeaderFormatNotes
Authorization: Bearer sk-…BothStandard for OpenAI clients. Claude Code sends this when you set ANTHROPIC_AUTH_TOKEN.
x-api-key: sk-…AnthropicWhat the Anthropic SDKs send by default.
anthropic-version: 2023-06-01AnthropicRequired by the Messages API. SDKs add it automatically.

Which endpoints are available?#

The gateway offers five endpoints, listed in the table below.

MethodPathFormatPurpose
POST/v1/chat/completionsOpenAIChat with any model. The most widely supported endpoint.
POST/v1/responsesOpenAIOpenAI Responses API, used by Codex CLI and newer OpenAI SDK features.
POST/v1/messagesAnthropicAnthropic Messages API, used by Claude Code and the Anthropic SDKs.
GET/v1/modelsOpenAIList the model ids your key can call.
POST/v1/embeddingsOpenAIVector embeddings, when an embedding model is enabled.

What is the chat completions endpoint?#

POSThttps://api.oneaiapikey.com/v1/chat/completionsOpenAI format

Chat 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.

FieldTypeRequiredDescription
modelstringYesExact model id, for example gpt-6-luna:free. See models by format.
messagesarrayYesConversation so far. Each item has a role (system, user, assistant, tool) and content.
streambooleanNoSend tokens as server-sent events. Recommended for long outputs.
stream_optionsobjectNo{"include_usage": true} adds a final chunk with token usage.
max_tokens / max_completion_tokensintegerNoUpper bound on generated tokens. Reasoning models prefer max_completion_tokens.
temperature, top_pnumberNoSampling controls. Some reasoning models ignore or reject them.
tools, tool_choicearray, string | objectNoFunction calling. See tool calling.
response_formatobjectNoAsk for JSON output ({"type": "json_object"} or a JSON schema) on models that support it.
stopstring | arrayNoStop 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.

Example request
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.

200 OK
{
  "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?#

POSThttps://api.oneaiapikey.com/v1/responsesOpenAI format

The 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?#

POSThttps://api.oneaiapikey.com/v1/messagesAnthropic format

The 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);
200 OK
{
  "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?#

GEThttps://api.oneaiapikey.com/v1/modelsOpenAI format

GET /v1/models returns the model ids your key is allowed to call. If a key has an allowed-model list, only those models appear.

Request
curl https://api.oneaiapikey.com/v1/models \
  -H "Authorization: Bearer $ONEAIAPIKEY_API_KEY"
200 OK (shortened)
{
  "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?#

POSThttps://api.oneaiapikey.com/v1/embeddingsOpenAI format

Yes, 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.

Example request
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 in message_start and message_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"
        ]
      }
    }
  ]
}
  1. The model replies with tool_calls (OpenAI) or a tool_use content block (Anthropic).
  2. Your code runs the tool and sends the result back: a tool role message with the matching tool_call_id, or a tool_result block with the matching tool_use_id.
  3. 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.

MeaningOpenAI formatAnthropic format
Input tokensusage.prompt_tokensusage.input_tokens
Output tokensusage.completion_tokensusage.output_tokens
Cached input readusage.prompt_tokens_details.cached_tokensusage.cache_read_input_tokens
Cache writen/ausage.cache_creation_input_tokens
Reasoning / thinkingIncluded in completion_tokensIncluded 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 429 or 503 and 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: true for 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 idOpenAIAnthropicIn / 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

↑ ↓ moveEnter openEsc close
New accounts$10 credit on sign-up
Claim $10 credit →