Skip to content
API Reference

Chat Completions ​

Create a model response for a chat conversation across OpenAI, Anthropic, Gemini, DeepSeek, and Qwen models using the universal OpenAI schema.

POSThttps://api.vanix.io/v1/chat/completions
Interactive Try ItPOST /v1/chat/completions

Calls go directly from your browser to https://api.vanix.io. Key is kept in session memory only.

Enter your Vanix AI API key and click "Send Request" to run a live call against https://api.vanix.io.

Request Body Parameters ​

modelstringrequired
Target model ID returned by GET /v1/models (e.g., gpt-4o, gpt-4o-mini, claude-sonnet-4-5, gemini-2.5-pro, deepseek-chat).
messagesarray<object>required
Ordered conversation history. Each item has a role (system, developer, user, assistant, or tool) and string or multimodal array content.
streambooleanoptionaldefault: false
When true, tokens arrive incrementally as Server-Sent Events ending with data: [DONE].
stream_optionsobjectoptional
Pass {"include_usage": true} with stream: true to receive final token usage metrics.
temperaturenumberoptionaldefault: 1.0
Sampling randomness between 0.0 and 2.0. Omit for reasoning models that do not accept temperature.
max_completion_tokensintegeroptional
Maximum generated tokens (including reasoning tokens on reasoning models). Legacy max_tokens is also supported for non-reasoning models.
toolsarray<object>optional
Function tool schemas the model may invoke. Combine with tool_choice ("auto", "none", "required", or specific function).
response_formatobjectoptional
Constrain output to valid JSON via {"type": "json_object"} or strict schema via {"type": "json_schema", "json_schema": {...}}.
reasoning_effortstringoptional
Reasoning depth for supported models: "low", "medium", or "high".

Code Examples ​

bash
curl https://api.vanix.io/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $VANIX_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "system", "content": "Be concise."},
      {"role": "user", "content": "Reply with OK"}
    ],
    "max_completion_tokens": 32
  }'
python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["VANIX_API_KEY"], base_url="https://api.vanix.io/v1")
resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Reply with OK"}],
)
print(resp.choices[0].message.content)
ts
import OpenAI from 'openai'

const client = new OpenAI({ apiKey: process.env.VANIX_API_KEY, baseURL: 'https://api.vanix.io/v1' })
const resp = await client.chat.completions.create({
  model: 'gpt-4o-mini',
  messages: [{ role: 'user', content: 'Reply with OK' }],
})
console.log(resp.choices[0].message.content)

Response Example (200 OK) ​

json
{
  "id": "chatcmpl-9xK2mP",
  "object": "chat.completion",
  "created": 1764576000,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "OK" },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 1,
    "total_tokens": 13,
    "prompt_tokens_details": { "cached_tokens": 0 }
  }
}

Vanix AI Unified Model Gateway · https://api.vanix.io