Skip to Content
OpenInfer Docs
Inference APIsOpenAI Compatibility

Chat Completions

POST /v1/chat/completions

POST https://api.openinfer.ai/v1/chat/completions

Request

curl https://api.openinfer.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENINFER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "@oi/Qwen3.5-9B",
    "messages": [
      { "role": "system", "content": "You are concise." },
      { "role": "user", "content": "What is a KV cache?" }
    ],
    "max_tokens": 256
  }'
FieldNotes
modelRequired. A slug from GET /v1/models.
messagesRequired. The conversation, oldest first. Text content only.
streamtrue returns text/event-stream. Add stream_options to include usage.
temperature, top_pSampling. top_p must be in (0, 1].
max_tokens, max_completion_tokensCap on generated tokens.
seed, stopReproducibility and stop sequences.
tools, tool_choiceFunction tool calling.
response_formatStructured output. Cannot be combined with callable tools.
nOnly 1 is supported.

Streaming

stream = client.chat.completions.create(
    model="@oi/Qwen3.5-9B",
    messages=[{"role": "user", "content": "Write a haiku."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

The stream ends with data: [DONE].

Tool calling

{
  "model": "@oi/Qwen3.5-9B",
  "messages": [{ "role": "user", "content": "Weather in Paris?" }],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "parameters": {
        "type": "object",
        "properties": { "city": { "type": "string" } },
        "required": ["city"]
      }
    }
  }]
}

The reply's choices[0].message.tool_calls carries the call. Send the result back as a tool message and call again.

On this page