Chat API

Chat completions

The main endpoint. GPT-5.5, Claude Sonnet 5, Gemini 3 Flash and every other chat model below — all with the same request body.

POSThttps://api.oxyy.ai/v1/chat/completions

Parameters

ParameterTypeRequiredDescription
modelstringRequiredA model id from GET /v1/models, e.g. gpt-5.5, claude-sonnet-5, gemini-3-flash.
modelsarrayOptionalFallback model ids, tried in order when model fails. See below.
messagesarrayRequiredThe conversation. Each item has a role and content; content may be a string or an array of content parts. Roles:systemdeveloperuserassistanttoolfunction
temperaturenumberOptionalSampling temperature, 0–2. Higher is more random. Default the provider's own
max_tokensintegerOptionalMaximum tokens to generate, ≥ 1. Default the provider's own, or the model's default output limit where the provider requires a value
top_pnumberOptionalNucleus sampling, 0–1. Use this or temperature, not both.
top_kintegerOptionalSample from the k most likely tokens. Forwarded to the providers that support it.
nintegerOptionalHow many completions to generate, 1–128. Every choice is billed. Default 1
streambooleanOptionalStream the reply as server-sent events. See Streaming. Default false
stream_optionsobjectOptional{include_usage: true} adds a final chunk with token counts and cost.
stopstring|arrayOptionalUp to four sequences that end the generation.
seedintegerOptionalBest-effort determinism on the providers that support it.
frequency_penaltynumberOptional-2–2. Discourages repeating tokens by frequency. Default 0
presence_penaltynumberOptional-2–2. Discourages repeating any token already used. Default 0
toolsarrayOptionalFunction declarations. See Tool calling.
tool_choicestring|objectOptionalOne of:noneautorequired{type:"function",…} Default auto
parallel_tool_callsbooleanOptionalAllow several tool calls in one turn. Default true
response_formatobjectOptionalForce JSON output. See Structured outputs. Types:textjson_objectjson_schema
reasoning_effortstringOptionalHow much a reasoning model thinks; none turns thinking off where the model can. Mapped to the level the model uses for it where the model's levels are known (sometimes a higher level, or off; when it differs, dropped_params names the level used). See Reasoning. One of:noneminimallowmediumhighxhighmax
logprobsbooleanOptionalReturn log probabilities for the chosen tokens.
top_logprobsintegerOptionalHow many alternatives to report per position. Requires logprobs.
logit_biasobjectOptionalToken id to bias, -100–100.
userstringOptionalA stable id for your own end user. Helps you attribute usage.
modalitiesarrayOptionalWhat the model should return. Use ["image","text"] to have an image model answer over chat. One of:textimageaudio
image_configobjectOptionalPicture controls when a model answers with an image: {image_size, aspect_ratio}.
service_tierstringOptionalForwarded to providers that offer tiers, and echoed back on the response.
metadataobjectOptionalOpaque key/value pairs carried with the request.
Your own fallback models. Send models: ["a", "b"] beside model (OpenRouter's field). On chat and on the image, audio, video and embedding endpoints, the request moves on to a, then b, when every provider of model (and of its own fallback chain) fails. Without model, the first entry is the model. Up to three fallback models besides model(duplicates and model itself are ignored); more is a 400, and so is an entry that is not a model id (error.param names it, as in models[1]). Each id must be a model your key and tier may call and of the same kind as model; an unknown or forbidden one is refused up front (error.param is models). A fallback that has no provider at that moment is skipped. Each fallback model adds one provider attempt to the request's budget (by default five attempts, and at most fourteen). The budget is spent in order, not set aside per model, so a model whose providers fail one after another can still use it up before your list is reached. An asynchronous job (images or speech with async: true, and video unless it sends sync: true) runs on model alone: a job request that names models is refused with 400 unsupported_parameter; send it synchronously to have the list tried. You are billed for the model that answered, at its own price.

Code examples

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["OXYY_API_KEY"],
    base_url="https://api.oxyy.ai/v1"
)

response = client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Explain HTTP caching in two sentences."},
    ],
    temperature=0.7,
    max_tokens=4096
)

print(response.choices[0].message.content)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.OXYY_API_KEY,
  baseURL: 'https://api.oxyy.ai/v1'
});

const response = await client.chat.completions.create({
  model: 'claude-sonnet-5',
  messages: [
    { role: 'system', content: 'You are a concise assistant.' },
    { role: 'user', content: 'Explain HTTP caching in two sentences.' },
  ],
  temperature: 0.7,
  max_tokens: 4096
});

console.log(response.choices[0].message.content);
curl https://api.oxyy.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OXYY_API_KEY" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [{"role": "user", "content": "Explain HTTP caching."}],
    "temperature": 0.7,
    "max_tokens": 4096
  }'
// composer require openai-php/client
$client = OpenAI::factory()
    ->withApiKey(getenv('OXYY_API_KEY'))
    ->withBaseUri('https://api.oxyy.ai/v1')
    ->make();

$response = $client->chat()->create([
    'model' => 'claude-sonnet-5',
    'messages' => [['role' => 'user', 'content' => 'Hello!']],
    'temperature' => 0.7,
]);

echo $response->choices[0]->message->content;
// go get github.com/sashabaranov/go-openai
cfg := openai.DefaultConfig(os.Getenv("OXYY_API_KEY"))
cfg.BaseURL = "https://api.oxyy.ai/v1"
client := openai.NewClientWithConfig(cfg)

resp, err := client.CreateChatCompletion(context.Background(), openai.ChatCompletionRequest{
    Model: "claude-sonnet-5",
    Messages: []openai.ChatCompletionMessage{
        {Role: openai.ChatMessageRoleUser, Content: "Hello!"},
    },
})

Example response

Response
{
  "id": "chatcmpl-abc123def456",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "claude-sonnet-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?",
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 9,
    "total_tokens": 21,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0,
      "text_tokens": 12,
      "image_tokens": null,
      "audio_tokens": null
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "text_tokens": 9,
      "audio_tokens": null
    },
    "is_byok": false,
    "cost": 0.000106,
    "cost_details": { "currency": "USD", "input": 0.000036, "output": 0.00007 }
  }
}

finish_reason is one of stop, length, tool_calls, content_filter or function_call. When the provider reports something of its own, it is passed through beside it as native_finish_reason. An image answered over chat arrives on message.images.

Batch API

Many chat completions from one file, for work that does not need an answer right away. The shapes are OpenAI's, so client.batches.create, retrieve, list and cancel work unchanged. The gateway runs every line itself, through the same pipeline as a live request.

POSThttps://api.oxyy.ai/v1/filesthe input, purpose=batch
POSThttps://api.oxyy.ai/v1/batches
GEThttps://api.oxyy.ai/v1/batchesnewest first; limit, after
GEThttps://api.oxyy.ai/v1/batches/{id}
POSThttps://api.oxyy.ai/v1/batches/{id}/cancel
GEThttps://api.oxyy.ai/v1/files/{id}/contentthe results
StepDetail
Input fileJSONL uploaded to POST /v1/files with purpose=batch, one request per line: {"custom_id": "…", "method": "POST", "url": "/v1/chat/completions", "body": {…}}. Every custom_id is unique in the file, and stream: true is refused. Up to 50,000 lines; the file is held to the Files API upload limit.
CreatePOST /v1/batches with input_file_id, endpoint: "/v1/chat/completions", completion_window: "24h" (the only window) and optional metadata (up to 16 string pairs). Create it with an API key: every line runs as that key, with its scopes, model list and limits. Up to 5 unfinished batches per account; one more is a 429 batch_limit_exceeded.
EndpointsOnly /v1/chat/completions. /v1/responses, /v1/embeddings, /v1/completions and /v1/moderations are refused with a 400.
Statusvalidating, in_progress, finalizing, then completed. A file with an invalid line ends failed, its errors naming the lines; the 24-hour window ending first gives expired; a cancel gives cancelling, then cancelled. request_counts and usage show the progress.
ResultsWhen the batch ends, output_file_id holds one record per line that succeeded and error_file_id one per line that did not, in OpenAI's format: {"id": "batch_req_…", "custom_id", "response": {"status_code", "request_id", "body"}, "error"}. Download them with client.files.content and match them by custom_id. They are Files API files (purpose batch_output): they count toward your file storage and expire like your other files.
Lines with no answerA request that answered with an error is in the error file with its response. A line with none has response: null and an error.code: batch_expired (the window ended before it ran) or batch_line_interrupted (it was running when the gateway restarted; it may have run and been billed, so it is never run again — send it in a new batch if you still need it).
BillingEach line is billed exactly as the same live request, when it runs. There is no batch discount, and creating a batch costs nothing.
PaceLines share your rate limits and concurrency with your live traffic, and a batch leaves at least half of each to your live calls, so it runs at about half of your tier's requests per minute at most. A line refused by a rate limit or a temporary server error is tried again later.
CancelStops new lines. Lines already running finish and are billed, and their results are kept; lines that never started get no record.

Available models

57 models
Model
Model ID