Inference API
Console inference serves OpenAI, Anthropic, and Gemini-compatible APIs from https://opencode.ai/inference. Send a
JSON POST request to the endpoint that matches the model’s API family.
curl -X POST "https://opencode.ai/inference/openai/v1/chat/completions" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "kimi-k3",
"messages": [{ "role": "user", "content": "Say hi" }]
}'
Authentication
Replace <token> with a personal API key or a service account key created in the Console. Paid models
require the header. Free-tier chat models are only available from within OpenCode; other clients receive HTTP 403,
even with an API key. Use paid models or a Go subscription from other clients.
Authorization: Bearer <token>
Endpoints
| API | Path |
|---|---|
| OpenAI Chat Completions | /inference/openai/v1/chat/completions |
| OpenAI Responses | /inference/openai/v1/responses |
| Anthropic Messages | /inference/anthropic/v1/messages |
| Gemini | /inference/google/v1beta/models/<model>:generateContent |
Each model is served by one API family. See the model endpoints table, or fetch the live list:
curl https://opencode.ai/inference/v1/models
OpenAI Chat Completions
Open models such as kimi-k3, glm-5.3, minimax-m3, and the free models use the Chat Completions API.
curl -X POST "https://opencode.ai/inference/openai/v1/chat/completions" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3",
"messages": [{ "role": "user", "content": "Say hi" }]
}'
OpenAI Responses
GPT models use the Responses API.
curl -X POST "https://opencode.ai/inference/openai/v1/responses" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"input": "Say hi"
}'
Anthropic Messages
Claude and Qwen models use the Messages API. max_tokens is required.
curl -X POST "https://opencode.ai/inference/anthropic/v1/messages" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "Say hi" }]
}'
Gemini
Gemini models take the model and method in the path. Replace :generateContent with :streamGenerateContent to
stream the response.
curl -X POST "https://opencode.ai/inference/google/v1beta/models/gemini-4-argon:generateContent" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"contents": [{ "parts": [{ "text": "Say hi" }] }]
}'