Docs menuinvideo Platform docsQuickstartFor AI agentsAPI referenceAuthenticationRequestsFilesErrorsLimitsBilling and balanceCatalogueProvider keys (BYOK)Formats and model IDsChat completionsOpenAI ResponsesAnthropic MessagesGeminiStreaming chat answersTools (function calling)Structured output (JSON)VideoAudioUse your own SDKOpenAI mediaElevenLabsReplicatefalGemini mediaxAIRunwayLumaDeepgram and CartesiaMakers' own APIsVideo provider formatsImage provider formatsAudio provider formatsLLM provider formatsGenerate and edit imagesTest your integrationWorkspaces and membersSecurityService accountsModels
View as markdown

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:

bash
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

bash
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
  }'
python
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)
ts
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

FieldTypeNotes
modelstringA chat model id from GET /v1/models?modality=text, or one of its aliases (the provider's own id). Required.
messagesarrayThe conversation. Roles: system (or developer), user, assistant, tool. Required.
max_tokens / max_completion_tokensintegerThe 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.
temperaturenumber0 to 2. Default 1.
top_pnumberNucleus sampling, where the model has it.
stopstring or arrayStop sequences, where the model has them.
streambooleanSend the answer as it is written. See Streaming.
tools, tool_choicearray, string or objectFunction calling. See Tools.
response_formatobjectjson_object or json_schema. See Structured output.
reasoning_effortstringnone, 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

json
{
  "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 id is the Platform request ID and matches the x-request-id header. Look up that ID in Logs or call GET /v1/request/{id}.
  • model is the id you sent (ours or an alias).
  • finish_reason: stop (finished normally), length (it hit max_tokens), tool_calls (it called a tool) or content_filter (blocked).
  • message.reasoning_content is there when the model gave its reasoning.
  • cost_usd is what Platform charged. usage.invideo_cost shows the charge lines and total.
  • With stream: true, the same Platform request ID appears in each JSON chunk’s id. 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:

json
{
  "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:

json
{"error": {"type": "invalid_request_error", "code": "model_not_found", "message": "...", "param": "model"}}
HTTPcodeWhat to do
400invalid_requestFix the field named in param.
400max_tokens_too_lowThe model used up max_tokens before it answered (reasoning counts). Raise max_tokens.
400context_length_exceededSend fewer or shorter messages, or a lower max_tokens.
400content_filteredThe provider's filter or the model refused. Change the messages.
400model_not_chatUse POST /v1/request for this model.
404model_not_foundUse an id from GET /v1/models?modality=text; it must be on for your workspace.
422model_not_pricedUse another model.
429spend_limit_exceededRaise the spend limit in the console, or wait for the next month.
429rate_limitedYour requests-per-minute limit. Retry after a short wait.
429upstream_rate_limitedThe provider is busy. Retry, or use another model.
502upstream_errorThe request failed upstream. Retry the request.
504upstream_timeoutRetry, lower max_tokens, or stream.
500internal_errorRetry. 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.

All codes: Errors. Limits: Limits.