OpenAI Responses
Use the OpenAI SDK's Responses API with Platform: POST /v1/responses, passthrough for models in this format, translated for every other chat model.
POST /v1/responses takes OpenAI's Responses format, so client.responses
in the OpenAI SDKs works as it is. Set the base URL to
https://platform-api.invideo.io/v1 and use your Platform API key.
- Native format (passthrough). Your body goes to OpenAI unchanged (reasoning,
instructions,text.format, function tools, images,input_fileinline) and the answer and its stream events come back as OpenAI sends them. - Other models: translated.
inputtext and images,instructionsand function tools carry over; the answer is built as a Responses object.input_file(PDF) works only with models in this format; on others it is refused (HTTP 400unsupported_parameter).
Send the whole conversation in input. Platform refuses previous_response_id and conversation. Use background: true for a response that continues after you disconnect. Set store: false to opt out of stored response retrieval. See Formats and model IDs for model IDs and aliases.
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.
Send a request
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.responses.create(
model="gemini-4-carbon",
instructions="You write short product names.",
input="Name a video app for cooks.",
reasoning={"effort": "low"},
)
print(answer.output_text)
print(answer.usage) # input, cached, output and reasoning tokens, and cost_usdimport OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://platform-api.invideo.io/v1", apiKey: process.env.INVIDEO_API_KEY });
const answer = await client.responses.create({ model: "gemini-4-carbon", input: "Name a video app for cooks." });
console.log(answer.output_text);curl https://platform-api.invideo.io/v1/responses \
-H "Authorization: Bearer $INVIDEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gemini-4-carbon", "input": "Name a video app for cooks."}'A conversation goes in input as a list:
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.responses.create(
model="gemini-4-carbon", # any chat model
input=[
{"role": "user", "content": "Name a video app for cooks."},
{"role": "assistant", "content": "SimmerCut"},
{"role": "user", "content": "Another one, shorter."},
],
)
print(answer.output_text)Streaming
With stream=True, the answer comes as the Responses events
(response.created, response.output_text.delta, ..., response.completed).
response.completed has the usage, with cost_usd.
from openai import OpenAI
import os
client = OpenAI(base_url="https://platform-api.invideo.io/v1", api_key=os.environ["INVIDEO_API_KEY"])
stream = client.responses.create(model="gemini-4-carbon", input="Write a haiku about soup.", stream=True)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)Recover a chat answer
Keep the Platform request ID from the x-request-id header or JSON id field.
GET /v1/chat/completions/{id}returns the stored Chat Completion.GET /v1/responses/{id}returns the Response and its current status.GET /v1/request/{id}returns the request status and, when available, the answer inoutput.message.content. Use this endpoint for Anthropic, Gemini, and other chat formats.
Use the same workspace and service account that submitted the request. Retrieval does not run the model again or charge for another generation.
Resume a Responses stream
Call POST /v1/responses with background: true and stream: true. Keep the Response ID from response.created and the sequence_number of the last event you processed. Reconnect with GET /v1/responses/{id}?stream=true&starting_after=N. Platform sends events after N, then sends new events as they arrive. The stream buffer expires 10 minutes after the final event. After expiry, retrieve the Response without streaming.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["INVIDEO_API_KEY"],
base_url="https://platform-api.invideo.io/v1",
)
with client.responses.create(
model="gemini-3-1-flash-lite",
input="Explain why ice floats.",
background=True,
stream=True,
) as stream:
event = next(stream)
response_id = event.response.id
last_sequence = event.sequence_number
with client.responses.retrieve(
response_id, stream=True, starting_after=last_sequence
) as stream:
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
print(client.responses.retrieve(response_id).output_text)curl -NsS -X POST https://platform-api.invideo.io/v1/responses \
-H "Authorization: Bearer $INVIDEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gemini-3-1-flash-lite","input":"Explain why ice floats.","background":true,"stream":true}'
From the events already processed, set RESPONSE_ID to the response ID and LAST_SEQUENCE to the last sequence_number processed. Then run the second command.
curl -NsS "https://platform-api.invideo.io/v1/responses/$RESPONSE_ID?stream=true&starting_after=$LAST_SEQUENCE" \
-H "Authorization: Bearer $INVIDEO_API_KEY"To start a background Response without opening a stream, send background: true and omit stream. Poll the Response ID until it reaches a terminal status. To cancel a background Response, call POST /v1/responses/{id}/cancel or client.responses.cancel(response_id).
Background mode and replay require retention. Platform never saves answers or stream events for zero data retention requests. A request with store: false does not have a stored OpenAI-format response.
Answer
{
"id": "0193b0c4-...",
"object": "response",
"status": "completed",
"model": "gemini-4-carbon",
"output": [{"type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "SimmerCut"}]}],
"usage": {
"input_tokens": 12,
"input_tokens_details": {"cached_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"reasoning_tokens": 0},
"total_tokens": 18,
"cost_usd": "0.000021"
}
}idis the request's id in Logs (also thex-request-idheader).modelis the id you sent.status:completed, orincompletewithincomplete_details.reason(max_output_tokens: it hit the limit;content_filter: blocked).
Errors
OpenAI's shape, as on Chat completions:
{"error": {"message", "type", "param", "code"}}. Server-side tools
(web_search, file_search, code_interpreter, image_generation, mcp,
computer_use) and file_id inputs are refused with unsupported_parameter.
All codes: Errors.