Chat Completions

Full API reference for the POST /v1/chat/completions endpoint

POST/v1/chat/completions

Create a chat completion. Compatible with the OpenAI Chat Completions API.

Request Parameters#

Message Format#

Each message in the messages array has:

FieldTypeDescription
rolestringOne of: system, user, assistant
contentstringThe message text content

Request Examples#

Python
from openai import OpenAI
 
client = OpenAI(
    base_url="https://api.foza.ai/v1",
    api_key="sk-foza-xxxxx",
)
 
response = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in 3 sentences."},
    ],
    temperature=0.7,
    max_tokens=200,
)
 
print(response.choices[0].message.content)
Node.js
import OpenAI from "openai";
 
const client = new OpenAI({
  baseURL: "https://api.foza.ai/v1",
  apiKey: "sk-foza-xxxxx",
});
 
const response = await client.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Explain quantum computing in 3 sentences." },
  ],
  temperature: 0.7,
  max_tokens: 200,
});
 
console.log(response.choices[0].message.content);
cURL
curl https://api.foza.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-foza-xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in 3 sentences."}
    ],
    "temperature": 0.7,
    "max_tokens": 200
  }'

Response Format#

Streaming#

Set stream: true to receive Server-Sent Events. See the Streaming guide for details.