Inference APIsOpenAI Compatibility
Chat Completions
POST /v1/chat/completions
POST https://api.openinfer.ai/v1/chat/completionsRequest
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
}'| Field | Notes |
|---|---|
model | Required. A slug from GET /v1/models. |
messages | Required. The conversation, oldest first. Text content only. |
stream | true returns text/event-stream. Add stream_options to include usage. |
temperature, top_p | Sampling. top_p must be in (0, 1]. |
max_tokens, max_completion_tokens | Cap on generated tokens. |
seed, stop | Reproducibility and stop sequences. |
tools, tool_choice | Function tool calling. |
response_format | Structured output. Cannot be combined with callable tools. |
n | Only 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.