Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Chat completions

POST /v1/chat/completions — drop-in compatible with OpenAI's chat completions API. Send the same request body, get the same response shape.

Basic call

curl https://api.lazu.ai/v1/chat/completions \
  -H "Authorization: Bearer $LAZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Tell me a joke about Postgres."}
    ]
  }'
from openai import OpenAI
client = OpenAI(base_url="https://api.lazu.ai/v1", api_key="...")
 
resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": "You are concise."},
        {"role": "user", "content": "What's 2+2?"},
    ],
)
print(resp.choices[0].message.content)

Streaming

Add "stream": true. The response is text/event-stream SSE.

stream = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Count to 5"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)

Function / tool calling

Pass tools array; the response will include tool_calls when the model decides to invoke one.

{
  "model": "gpt-4o",
  "messages": [...],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "parameters": { "type": "object", "properties": { ... } }
    }
  }]
}

The model catalog's parameters.tools field tells you which models support this — see Catalog.

Vision (image input)

For chat/completions, embed images inline (data URL or HTTPS URL):

{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "What's in this image?" },
        {
          "type": "image_url",
          "image_url": { "url": "data:image/png;base64,..." }
        }
      ]
    }
  ]
}

For PDFs / large documents, use the Files API + Responses instead. Chat completions does not automatically dereference file_id references.

Supported models

Anything where the catalog lists chat in supported_endpoint_types:

  • OpenAI: gpt-4o, gpt-4o-mini, gpt-4.1, o1, o3-mini, gpt-5 family
  • Anthropic: claude-haiku-4-5-*, claude-sonnet-4-5-*, claude-opus-*
  • Google: gemini-2.5-flash, gemini-2.5-pro
  • DeepSeek: deepseek-chat, deepseek-v3, deepseek-reasoner
  • Moonshot: kimi-k2, kimi-k2-thinking
  • xAI: grok-4-*
  • Many more — read the catalog at runtime.

Request body fields

Standard OpenAI fields all work: model, messages, max_tokens, temperature, top_p, presence_penalty, frequency_penalty, stop, n, tools, tool_choice, response_format, seed, user, stream_options.

See the API reference for the full schema.

See also