Skip to content
Guides

Text & Chat ​

Generate completions, multi-turn conversations, summaries, and code across OpenAI, Anthropic, Google Gemini, DeepSeek, and Qwen through a consistent interface.

Core Conversation Pattern ​

Messages follow a strict role sequence (system or developer → alternating user / assistant / tool turns).

python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["VANIX_API_KEY"],
    base_url="https://api.vanix.io/v1",
)

response = client.chat.completions.create(
    model="gpt-4o",
    temperature=0.2,
    max_completion_tokens=800,
    messages=[
        {"role": "system", "content": "You are a principal cloud architect. Return concise markdown."},
        {"role": "user", "content": "Compare ALB least-outstanding-requests vs round-robin for LLM streaming."},
    ],
)

print(response.choices[0].message.content)
print("Usage:", response.usage)
ts
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.VANIX_API_KEY,
  baseURL: 'https://api.vanix.io/v1',
})

const response = await client.chat.completions.create({
  model: 'claude-sonnet-4-5',
  temperature: 0.2,
  max_tokens: 800,
  messages: [
    { role: 'system', content: 'You are a principal cloud architect. Return concise markdown.' },
    { role: 'user', content: 'Compare ALB least-outstanding-requests vs round-robin for LLM streaming.' },
  ],
})

console.log(response.choices[0].message.content)

Key Generation Parameters ​

ParameterGuidance
modelExact model ID from GET /v1/models (e.g., gpt-4o, gpt-5, claude-sonnet-4-5, gemini-2.5-pro, deepseek-chat).
temperature0.0–0.3 for deterministic extraction/coding; 0.7–1.0 for creative writing. Omit on reasoning models that disallow sampling parameters.
max_completion_tokensPrefer over legacy max_tokens on newer OpenAI reasoning models so output caps are respected cleanly.
stopUp to 4 stop sequences to halt generation at deterministic delimiters.
streamSet true with stream_options: {"include_usage": true} for low-TTFT user interfaces and exact billing telemetry.

Production Tips ​

  • Pin explicit model versions in mission-critical pipelines when output format stability matters.
  • Keep system prompts static at the prefix to maximize automatic Prompt Caching hit rates.
  • Inspect finish_reason: Handle length (output truncated) and tool_calls explicitly rather than assuming stop.

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