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

FieldTypeRequiredDetails
modelstringyesPublic InOneAPI model ID. The gateway maps it to an enabled upstream model.
messagesarrayyesOrdered conversation messages. Roles normally include system, user, assistant, and tool.
temperaturenumbernoSampling randomness. Provider ranges differ; use 0-2 unless the model documents a narrower range.
top_pnumbernoNucleus sampling. Usually set either temperature or top_p, not both.
max_tokensnumbernoMaximum generated tokens. Some providers use max_completion_tokens; mappings normalize where supported.
streambooleannoWhen true, returns server-sent events with chat completion chunks.
toolsarraynoOpenAI-compatible tool definitions. Tool support depends on the selected model and mapping.
tool_choicestring/objectnoControls automatic, required, or named tool calls.
response_formatobjectnoUse for JSON object or JSON schema output when supported.
stopstring/arraynoStop sequences. Support and maximum count are provider-specific.
userstringnoEnd-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.

Chat Completions · Documentation · InOneAPI