APIReference

Create a chat completion

POST
/v1/chat/completions

Creates a model response for a conversation. Requires the inference:create scope.

Set stream: true to receive Server-Sent Events. The stream emits chat.completion.chunk objects and terminates with exactly one data: [DONE] marker. Pass stream_options.include_usage: true to receive a final chunk carrying the token usage block.

Requests that use a capability the target model does not support are rejected with unsupported_feature rather than silently degraded. Only n: 1 is supported.

AuthorizationBearer <token>

A Codius organization API key, sent as Authorization: Bearer codius_live_…. Keys carry a subset of the models:read, inference:create, and usage:read scopes — never billing or admin permissions.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

model*string

A public model ID from GET /v1/models.

Length1 <= length <= 256

Value in

  • "anthropic/claude-haiku-4.5"
  • "anthropic/claude-opus-4.7"
  • "anthropic/claude-opus-4.8"
  • "anthropic/claude-sonnet-4.6"
  • "deepseek/v4-flash"
  • "deepseek/v4-pro"
  • "google/gemini-3.1-flash-lite"
  • "google/gemini-3.1-pro"
  • "google/gemini-3.5-flash"
  • "google/gemini-3-flash"
  • "google/gemma-4-31b"
  • "minimax/m3"
  • "moonshotai/kimi-k2.6"
  • "moonshotai/kimi-k3"
  • "openai/gpt-5.4"
  • "openai/gpt-5.4-mini"
  • "openai/gpt-5.4-nano"
  • "xai/grok-4.3"
  • "zai/glm-5.1"
messages*array<||||>
Items1 <= items <= 2000
stream?boolean

Stream the response as Server-Sent Events.

Defaultfalse
stream_options?

Requires stream: true.

max_tokens?integer

Mutually exclusive with max_completion_tokens.

Range1 <= value
max_completion_tokens?integer

Mutually exclusive with max_tokens.

Range1 <= value
temperature?number
Range0 <= value <= 2
top_p?number
Range0 <= value <= 1
stop?string|array<string>
seed?integer
tools?array<>
Items1 <= items <= 128
tool_choice?|
parallel_tool_calls?boolean

Requires tools.

response_format?||
reasoning_effort?string

Requires a model with reasoning support.

Value in

  • "none"
  • "minimal"
  • "low"
  • "medium"
  • "high"
  • "xhigh"
frequency_penalty?number
Range-2 <= value <= 2
presence_penalty?number
Range-2 <= value <= 2
n?integer

Only a single choice is supported.

Default1

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "moonshotai/kimi-k3",    "messages": [      {        "role": "user",        "content": "Explain this function."      }    ]  }'
{  "id": "chatcmpl_0190d3a0",  "object": "chat.completion",  "created": 1753267200,  "model": "MODEL_ID",  "choices": [    {      "index": 0,      "message": {        "role": "assistant",        "content": "It memoizes the result of the previous render."      },      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 24,    "completion_tokens": 11,    "total_tokens": 35  }}