Chat completions

Last updated:

On this page
text
POST https://api.staik.se/v1/chat/completions

Fully OpenAI-compatible — existing SDKs work directly with a new base_url.

python
from openai import OpenAI

client = OpenAI(api_key="sk-st-your-key", base_url="https://api.staik.se/v1")

response = client.chat.completions.create(
    model="qwen3.6:35b-a3b",
    messages=[
        {"role": "system", "content": "You are a helpful assistant that answers briefly."},
        {"role": "user", "content": "What is the difference between TCP and UDP?"},
    ],
    max_tokens=500,
    temperature=0.7,
)
print(response.choices[0].message.content)

Parameters

ParameterTypeDescription
modelstringModel id, see Models. Required.
messagesarrayThe conversation: system, user, assistant (and tool). Required.
max_tokensintRoom reserved for the reply. If omitted, a sensible per-model default is applied.
temperaturefloat0–2, higher = more creative.
streamboolToken-by-token via SSE — see Streaming.
tools / tool_choicearrayFunction calling — see Tool calling.
web_searchboolServer-side web search — see Web search.

Context and max_tokens

Your prompt plus max_tokens must fit within the model's context window (262K for the chat models). Exceeding it returns 400 — shorten the prompt or lower max_tokens.

Vision

All chat models read images: qwen3.6:35b-a3b, qwen3.5:9b, and gemma4:31b. Send images as image_url in messages using a base64-encoded data URI. External image URLs are not fetched and return 400. JPEG, PNG, and HEIC (iPhone) are supported, and images larger than 4096 px are scaled down automatically.

Invoices, receipts, and process maps

Choose qwen3.6:35b-a3b when numbers and small text must be exactly right. The Qwen models read the image at full resolution (a phone photo becomes up to about 12,000 tokens), while gemma4:31b uses a fixed, lower resolution (about 400 tokens per image). The image counts as prompt tokens.

python
response = client.chat.completions.create(
    model="qwen3.6:35b-a3b",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What does the image show?"},
            {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}},
        ],
    }],
)

Thinking mode

The aliases qwen3.6:35b-a3b-thinking and qwen3.5:9b-thinking run the same models with reasoning enabled, as do the version-neutral qwen-35b-latest-thinking and qwen-9b-latest-thinking. The reasoning is delivered separately in choices[0].message.reasoning (non-streamed) or choices[0].delta.reasoning (streamed), and the answer itself stays clean. staik automatically sets a thinking budget so the answer always fits within max_tokens. See Thinking and reasoning for the budget, code examples and recommendations.