Text models
POST /v1/chat/completions answers with text. It takes and returns the OpenAI chat shape, so an OpenAI SDK works with two changes: the base URL and the key. The same VidLab key and the same prepaid balance as every other model.
| Model | Maker | Reads | Longest answer | Reasoning effort |
|---|---|---|---|---|
claude-opus-5.5 | Anthropic | 1,000,000 tokens | 64,000 tokens | low, medium, high, xhigh, max |
claude-fable-5.2 | Anthropic | 1,000,000 tokens | 64,000 tokens | low, medium, high, xhigh, max |
gemini-4-neon | 1,048,576 tokens | 64,000 tokens | low, medium, high, xhigh |
Live prices are on GET /v1/models?kind=text, in dollars per 1 million tokens: prices.input, prices.output, prices.cache_read and prices.cache_write.
Call it
curl https://vidlab.ai/v1/chat/completions \
-H "Authorization: Bearer $VIDLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5.5",
"max_tokens": 2000,
"messages": [{"role": "user", "content": "Write one headline for a red running shoe."}]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://vidlab.ai/v1", api_key=os.environ["VIDLAB_API_KEY"])
r = client.chat.completions.create(
model="claude-opus-5.5",
max_tokens=2000,
messages=[{"role": "user", "content": "Write one headline for a red running shoe."}],
)
print(r.choices[0].message.content, r.usage)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://vidlab.ai/v1", apiKey: process.env.VIDLAB_API_KEY });
const r = await client.chat.completions.create({
model: "claude-opus-5.5",
max_tokens: 2000,
messages: [{ role: "user", content: "Write one headline for a red running shoe." }],
});
console.log(r.choices[0].message.content, r.usage);The answer is a chat.completion. usage has the tokens and price_usd, what the call cost:
{
"id": "chatcmpl_4fQ0c8mB7s2KxZr1TnVw9aLe",
"object": "chat.completion",
"created": 1763900000,
"model": "claude-opus-5.5",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Run like the light just changed.", "refusal": null },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 9,
"total_tokens": 27,
"prompt_tokens_details": { "cached_tokens": 0, "cache_write_tokens": 0 },
"price_usd": "what the call cost, in dollars (a number)"
}
}These models reason before they answer. Reasoning tokens are output tokens: they count in completion_tokens and toward max_tokens. An answer that comes back empty with finish_reason: "length" used its whole limit on reasoning: raise max_tokens or lower reasoning_effort.
Fields
| Field | What it does |
|---|---|
model | The model's id. |
messages | system, developer, user, assistant and tool messages. Content is text, or text and image_url parts (images in user messages). |
max_tokens | The most output tokens, reasoning included, up to 64,000. max_completion_tokens is the same limit. Left out: 8,192. |
stream, stream_options | stream: true sends server events. stream_options: {"include_usage": true} adds a last chunk with usage. |
reasoning_effort | One of the model's efforts, or reasoning: {"effort": ...}. Left out: the model's own default. |
tools, tool_choice | Functions the model may call. The two Claude models take tool_choice auto or none; gemini-4-neon also takes required or a named function. |
response_format | text, json_object or json_schema. |
stop | A string, or up to 4. |
user, parallel_tool_calls | Accepted. user is not passed on. parallel_tool_calls: false asks for one tool call an answer on the Claude models; gemini-4-neon does not take it. |
temperature, top_p, seed | gemini-4-neon only. The Claude models do not take them. |
Any other field is refused with 400, never dropped, and so is anything the model does not take, before anything is held.
Images: up to 20 a call, as a public https link or inline as a base64 data URL: PNG, JPEG, WebP or GIF, up to 5 MB and 4,096 pixels a side each, 20 MB together. Moving images (an animated GIF, WebP or PNG) are not taken. We fetch a link ourselves and send the picture on: 30 seconds for all of a call's links. A request is at most 20 MB. Audio, video and files are not taken.
{"role": "user", "content": [
{"type": "text", "text": "What is on the label?"},
{"type": "image_url", "image_url": {"url": "https://example.com/bottle.jpg"}}
]}Stream
stream = client.chat.completions.create(
model="gemini-4-neon",
stream=True,
stream_options={"include_usage": True},
messages=[{"role": "user", "content": "Three hooks for a hydration drink."}],
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
if chunk.usage:
print(chunk.usage)Lines that start with : are keep-alive comments: a model can think for minutes before its first word. If an answer breaks after it began, the last event is an error instead of a finish.
Use stream: true for anything that can take over a minute. Without it, an answer that takes over 88 seconds has to start its body before it is done: the status is already 200, blanks come while it is made (JSON allows them, so a parser still reads it), and a failure that late is an error object with status 200. Check for error in the body, not only the status. A stream has neither problem.
A call runs 45 minutes at most. One that reaches it is returned as it stands, with finish_reason: "length", and is charged.
Tools
Send back the assistant message exactly as you received it, reasoning_details included: it carries the model's reasoning, sealed, to the next turn. A sealed block opens only for your account and the model that made it. Leaving it out is allowed; the model then starts its reasoning over.
tools = [{"type": "function", "function": {
"name": "get_weather",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
}}]
messages = [{"role": "user", "content": "Is it raining in Oslo?"}]
first = client.chat.completions.create(model="claude-opus-5.5", messages=messages, tools=tools)
reply = first.choices[0].message
messages.append(reply.model_dump(exclude_none=True))
for call in reply.tool_calls or []:
messages.append({"role": "tool", "tool_call_id": call.id, "content": "Light rain, 6 C"})
second = client.chat.completions.create(model="claude-opus-5.5", messages=messages, tools=tools)
print(second.choices[0].message.content)What a call costs
Each token is paid once, at its own price:
| Tokens | Where they are in usage | Price |
|---|---|---|
| Input | prompt_tokens, less the cached and written ones | prices.input |
| Read from cache | prompt_tokens_details.cached_tokens | prices.cache_read |
| Written to cache | prompt_tokens_details.cache_write_tokens | prices.cache_write. On gemini-4-neon it is added to prices.input (cache_write_billing: added). |
| Output, reasoning included | completion_tokens | prices.output |
- Held. Before a call is sent, the most it can cost is held on your balance: your request at its largest, plus
max_tokensof output. A lowermax_tokensholds less. If the balance does not cover it:429 api_wallet_exhausted, and nothing is sent. - Charged. Once, for the tokens used, rounded up to the micro-dollar, never more than was held. The rest of the hold is released at once. These models are sold at the same price to every account: wholesale rates do not apply to them.
- A call that fails after the model has run is billed for what it used, whole or streamed, and whether your connection broke or the model's. Its error carries
price_usd, and it is in your logs. When the model's own count is not known, it is your request and what the model can have made while it was answering, its reasoning included. Never more than was held. - Free. A call that is refused, or that ends before the model gave anything, costs nothing.
- Cut short. When part of an answer came and its count is known, that part is your answer, with
finish_reason: "length". - If you leave. A call goes on when your connection closes, and is charged for what it used.
- Cache. On the Claude models, mark a text part with
"cache_control": {"type": "ephemeral"}to keep the prompt up to it for 5 minutes.gemini-4-neoncaches by itself and ignores the marker.
Every call is in your logs with its tokens and cost. Prompts and answers are not kept.
Retries. Send an Idempotency-Key to make a retry safe: a key that already made a call answers 409, and nothing is sent or charged again. Answers are not kept, so the first one cannot be sent again. A call that was never run frees its key; one that failed after it ran, or may have, keeps it, and a repeat answers 409: use a new key.
Errors
The shape is the same as everywhere. The ones of this endpoint:
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | A field is wrong, not taken, or not taken by this model. The message names it. |
| 400 | not_a_text_model | The model makes images, videos or sound: POST /v1/generations. |
| 400 | context_length_exceeded | The request is longer than the model reads. |
| 400 | invalid_image | An image could not be read. |
| 400 | content_policy | The request was blocked by a content policy. |
| 400 | invalid_reasoning_details | A sealed block is not this account's, not this model's, or was changed. |
| 409 | idempotency_key_in_progress, idempotency_key_used | The key already made a call. call has its id and status. |
| 429 | api_wallet_exhausted, rate_limited | Not enough balance for the hold, or too many calls at once. |
| 429 | too_many_running_calls | Your account has 20 text calls running, the most at once. Wait for one to finish. |
| 429 | text_calls_paused | Several of your latest calls ended without a whole answer, so text calls are paused for up to an hour. None of those was charged. |
| 502 | answer_interrupted | The answer was cut off. price_usd is there when it was charged. |
| 503 | model_busy, model_unavailable | Try again after Retry-After. |
| 504 | timeout | The model did not answer in time. |
POST /v1/generations with a text model answers 400 use_chat_completions.