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

Only gemma4:31b has vision. Send images as image_url in messages using a base64-encoded data URI (external image URLs are not fetched). Vision requests run with a 16K context window.

python
response = client.chat.completions.create(
    model="gemma4:31b",
    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. The reasoning is delivered separately in choices[0].message.reasoning_content (non-streamed) or choices[0].delta.reasoning_content (streamed) — the answer itself stays clean.