Chat Completions

POST /v1/chat/completions -- OpenAI-compatible, works with any OpenAI SDK by changing baseURL and API key.

Request

Terminal
POST /v1/chat/completions
Authorization: Bearer llms_live_...
Content-Type: application/json

{
  "model": "studio/qwen3-0.6b",
  "messages": [
    {"role": "system", "content": "You are terse."},
    {"role": "user", "content": "Hello"}
  ],
  "stream": false,
  "temperature": 0.7,
  "max_tokens": 512
}

Response (non-streaming)

Terminal
{
  "id": "chatcmpl_...",
  "object": "chat.completion",
  "created": 1735689600,
  "model": "studio/qwen3-0.6b",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hi." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 18, "completion_tokens": 3, "total_tokens": 21 },
  "llm_studio": {
    "request_id": "req_...",
    "credits_consumed": 21
  }
}

llm_studio is additive metadata outside the compatibility-critical fields -- existing OpenAI SDKs ignore it safely. credits_consumed is 0 for BYOK models, since BYOK usage is billed by the provider directly and never draws down hosted credits.

Tool calling

Pass tools the same way as OpenAI's API. Only models with supports_tools: true (see Models) accept it -- sending tools to a model that doesn't support them returns 400 invalid_request_error before any request reaches the model.

Terminal
{
  "model": "openai/gpt-5.1",
  "messages": [{"role": "user", "content": "What's the weather in Paris?"}],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "parameters": { "type": "object", "properties": { "city": { "type": "string" } } }
      }
    }
  ]
}

Messages also support a tool role and tool_calls / tool_call_id, for feeding a tool's result back into the conversation -- the same shape as OpenAI's API. Image content parts ({"type": "image_url", "image_url": {"url": "..."}}) work the same way for models with supports_vision: true.

Idempotency

For non-streaming requests, pass an Idempotency-Key header to safely retry a request -- a replayed request with the same key returns the original response instead of generating again. Streaming requests don't support idempotency keys today.

See also

Streaming responses are documented separately -- see Streaming. Error shapes are documented under Errors. For OpenAI's newer Responses API shape, see Responses API.