Chat completions
Call any language model in the catalogue with one OpenAI-compatible endpoint and a Platform API key.
POST /v1/chat/completions runs one turn of a chat model. The request and the
answer have the same shape as OpenAI's Chat Completions API, so the OpenAI SDKs
work as they are: set the base URL to https://platform-api.invideo.io/v1 and
use your Platform API key.
OpenAI Chat accepts every chat model. Platform sends requests unchanged to models that use this format and translates them for other models. To use Anthropic cache breakpoints and thinking or Gemini parts, choose the provider’s format in Formats and model IDs.
Every call is one request in Logs, with its messages, its answer, its tokens and what it cost.
Find a model
List the chat models your workspace can call:
curl https://platform-api.invideo.io/v1/models?modality=text \
-H "Authorization: Bearer $INVIDEO_API_KEY"Each model has its id, provider, a chat object (context_window,
capabilities, token_prices) and endpoint: "/v1/chat/completions". A model
must be on for your workspace; staff and owners turn models on in the console
(Manage → Models).
Send a request
curl https://platform-api.invideo.io/v1/chat/completions \
-H "Authorization: Bearer $INVIDEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-carbon",
"messages": [
{"role": "system", "content": "You write short product names."},
{"role": "user", "content": "Name a video app for cooks."}
],
"max_tokens": 200
}'from openai import OpenAI
import os
client = OpenAI(base_url="https://platform-api.invideo.io/v1", api_key=os.environ["INVIDEO_API_KEY"])
answer = client.chat.completions.create(
model="gemini-4-carbon",
messages=[{"role": "user", "content": "Name a video app for cooks."}],
)
print(answer.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://platform-api.invideo.io/v1", apiKey: process.env.INVIDEO_API_KEY });
const answer = await client.chat.completions.create({
model: "gemini-4-carbon",
messages: [{ role: "user", content: "Name a video app for cooks." }],
});
console.log(answer.choices[0].message.content);Request body
| Field | Type | Notes |
|---|---|---|
model | string | A chat model id from GET /v1/models?modality=text, or one of its aliases (the provider's own id). Required. |
messages | array | The conversation. Roles: system (or developer), user, assistant, tool. Required. |
max_tokens / max_completion_tokens | integer | The most tokens of the answer. Without it, the model's maximum (see Max length below). Models in the OpenAI format go through unchanged. OpenAI's newer models refuse max_tokens: send max_completion_tokens to them. |
temperature | number | 0 to 2. Default 1. |
top_p | number | Nucleus sampling, where the model has it. |
stop | string or array | Stop sequences, where the model has them. |
stream | boolean | Send the answer as it is written. See Streaming. |
tools, tool_choice | array, string or object | Function calling. See Tools. |
response_format | object | json_object or json_schema. See Structured output. |
reasoning_effort | string | none, minimal, low, medium, high, xhigh or max, for models that reason. |
With no system message, the model gets the system prompt You are a helpful assistant. (a few input tokens).
Max length. Set a max length (max_tokens / max_completion_tokens / max_output_tokens / maxOutputTokens). Without it we hold the model's full maximum; if your spend limit can't cover that, we lower the max to what it can.
A user message's content is a string or a list of parts: {"type": "text", "text": "..."} and, for models with vision, {"type": "image_url", "image_url": {"url": "https://..."}} (an https link, or a
data:image/png;base64,... URL; PNG, JPEG, GIF or WebP; 20 MB an image, 50 MB in
all). An https link must be public; it is fetched once, before the call.
Answer
{
"id": "0193b0c4-7640-72d1-91e7-e11f44de3708",
"object": "chat.completion",
"created": 1795680000,
"model": "gemini-4-carbon",
"choices": [
{"index": 0, "message": {"role": "assistant", "content": "SimmerCut"}, "finish_reason": "stop"}
],
"usage": {
"prompt_tokens": 31,
"completion_tokens": 6,
"total_tokens": 37,
"prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 0},
"cost": "0.000271",
"cost_usd": "0.000271",
"invideo_cost": {
"lines": [
{"item": "request", "quantity": "1", "unit_price_usd": "0.000271", "amount_usd": "0.000271"}
],
"total_usd": "0.000271"
}
},
"cost_usd": "0.000271"
}- For JSON responses, the body’s
idis the Platform request ID and matches thex-request-idheader. Look up that ID in Logs or callGET /v1/request/{id}. modelis the id you sent (ours or an alias).finish_reason:stop(finished normally),length(it hitmax_tokens),tool_calls(it called a tool) orcontent_filter(blocked).message.reasoning_contentis there when the model gave its reasoning.cost_usdis what Platform charged.usage.invideo_costshows the charge lines and total.- With
stream: true, the same Platform request ID appears in each JSON chunk’sid. See Streaming for the event sequence.
Pricing
A chat model is priced per million tokens of each kind: input, output, cached input (prompt tokens read from the provider's cache) and, for some models, cache write. Some models charge more per token when the prompt is over a size (the long-context tier). Each call is charged its exact tokens at these prices; reasoning tokens count as output.
The prices of each model are in chat.token_prices of GET /v1/models (your
workspace's prices) and in the public catalogue:
{
"input_per_m": "4.68",
"output_per_m": "23.4",
"cache_read_per_m": "0.468",
"cache_write_per_m": "5.85",
"long_context_above": 271630,
"long_input_per_m": "9.36",
"long_output_per_m": "35.1"
}A field is null when the model has no such price.
Before a call runs, what it can cost is held under your spend limit: its
prompt and max_tokens at the model's prices (an image counts as 1,500
tokens). A call whose hold is over what is left of the limit is refused with
spend_limit_exceeded. The charge is the exact amount afterwards. A call that
fails is free, unless your request caused it (see Errors below). If you close a stream
early, the model finishes the answer in the background and you are charged for it.
Errors
Errors have OpenAI's shape, so the SDKs raise the usual exceptions:
{"error": {"type": "invalid_request_error", "code": "model_not_found", "message": "...", "param": "model"}}| HTTP | code | What to do |
|---|---|---|
| 400 | invalid_request | Fix the field named in param. |
| 400 | max_tokens_too_low | The model used up max_tokens before it answered (reasoning counts). Raise max_tokens. |
| 400 | context_length_exceeded | Send fewer or shorter messages, or a lower max_tokens. |
| 400 | content_filtered | The provider's filter or the model refused. Change the messages. |
| 400 | model_not_chat | Use POST /v1/request for this model. |
| 404 | model_not_found | Use an id from GET /v1/models?modality=text; it must be on for your workspace. |
| 422 | model_not_priced | Use another model. |
| 429 | spend_limit_exceeded | Raise the spend limit in the console, or wait for the next month. |
| 429 | rate_limited | Your requests-per-minute limit. Retry after a short wait. |
| 429 | upstream_rate_limited | The provider is busy. Retry, or use another model. |
| 502 | upstream_error | The request failed upstream. Retry the request. |
| 504 | upstream_timeout | Retry, lower max_tokens, or stream. |
| 500 | internal_error | Retry. Nothing was charged. |
A failure your own request caused is charged for the tokens the model used
before it stopped: max_tokens_too_low (the model used all of max_tokens,
reasoning included, before it answered) and content_filtered. The error then
has charged_usd, and its message says what was charged and why, for example
Charged $0.0123 for 4,096 tokens used before max_tokens was reached. The
request log shows the charge. Every other failure (ours or the provider's:
outages, 5xx, timeouts, rate limits) is free.