Chat Completions
For file inputs, upload through the Files API, then reference the returned file_id. The gateway converts the input; provider acceptance is determined upstream.
Use {"type":"file","file":{"file_id":"..."}} inside messages[].content. Images become image_url, videos the InOneAPI video_url extension, audio input_audio, and documents file.file_data. Keep ordinary text as type: text; content order is preserved.
Use POST /v1/chat/completions for OpenAI-compatible chat, tool calling, JSON output, and streaming. InOneAPI keeps the public request shape stable while routing by model to the selected provider mapping.
Endpoint
https://api.inoneapi.com/v1/chat/completions
# -H "X-APP-NAME: Your App Name"
# -H "X-APP-URL: https://your-app.example.com"
curl "https://api.inoneapi.com/v1/chat/completions" \
-H "Authorization: Bearer $INONEAPI_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "YOUR_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'Parameters
| Field | Type | Required | Details |
|---|---|---|---|
| model | string | yes | Public InOneAPI model ID. The gateway maps it to an enabled upstream model. |
| messages | array | yes | Ordered conversation messages. Roles normally include system, user, assistant, and tool. |
| temperature | number | no | Sampling randomness. Provider ranges differ; use 0-2 unless the model documents a narrower range. |
| top_p | number | no | Nucleus sampling. Usually set either temperature or top_p, not both. |
| max_tokens | number | no | Maximum generated tokens. Some providers use max_completion_tokens; mappings normalize where supported. |
| stream | boolean | no | When true, returns server-sent events with chat completion chunks. |
| tools | array | no | OpenAI-compatible tool definitions. Tool support depends on the selected model and mapping. |
| tool_choice | string/object | no | Controls automatic, required, or named tool calls. |
| response_format | object | no | Use for JSON object or JSON schema output when supported. |
| stop | string/array | no | Stop sequences. Support and maximum count are provider-specific. |
| user | string | no | End-user identifier for abuse tracing. Do not put secrets or personal data in this field. |
Message content
Text-only messages can use a string content. Multimodal models may accept an array of content parts such as text and image_url; unsupported parts are rejected or transformed according to the model mapping.
{
"role": "user",
"content": [
{ "type": "text", "text": "Describe this image." },
{ "type": "image_url", "image_url": { "url": "https://example.com/image.png" } }
]
}
Response
Non-streaming responses follow the OpenAI chat completion shape. Usage fields are calculated locally when possible and aligned to provider token rules configured for the model.
{
"id": "chatcmpl_...",
"object": "chat.completion",
"created": 1760000000,
"model": "YOUR_MODEL_ID",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "TTFT is the time until the first token is received." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 13,
"total_tokens": 31
}
}
Streaming
With stream: true, parse each data: line as a JSON chunk until data: [DONE]. The first chunk is the best client-side signal for TTFT, while the response header X-Gateway-Trace-ID links the request to gateway diagnostics.
Errors
Use 400 responses to fix invalid JSON, unsupported parameters, or mapping issues. Use 401/403 for key and permission checks. Use 429 with Retry-After for rate or budget pressure. Use 5xx and the trace ID when contacting support.
- Do not retry streaming requests blindly after partial output.
- Keep API keys server-side.
- Log
X-Gateway-Trace-ID, status, model, and timing, not prompt or completion content.
Response metadata
The response includes usage counters and a gateway trace ID for diagnostics.