POST
https://octopusx.ai
/
v1
/
chat
/
completions
curl -N -X POST https://octopusx.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      { "role": "system", "content": "You are a concise technical assistant." },
      { "role": "user", "content": "Explain the role of an API gateway in three points." }
    ],
    "stream": true,
    "stream_options": {
      "include_usage": true
    }
  }'
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" gateway"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}

data: [DONE]

Chat Completions API (Default Streaming)

Use a unified conversation format to call upstream models such as OpenAI, Claude, Gemini, DeepSeek, and Qwen. This document uses streaming output as the default, making it suitable for chat, Agent, and long-text generation scenarios where output needs to be displayed as it is generated.
If stream is not provided in this project’s route, it is handled as non-streaming. If you want to always receive a streaming response, explicitly pass "stream": true.

Request Body

model
string
required
Model name. You can check the models available to the current API Key via Model List.
messages
array<object>
required
Conversation messages arranged in chronological order. Common roles are system, user, assistant, and tool.
messages[].content
string | array
required
Message content. A string indicates plain text; an array indicates multimodal content and supports text, image_url, input_audio, file, and video_url.
stream
boolean
required
When set to true, the response is text/event-stream, with each chunk pushed as data: and data: [DONE] returned at the end.
stream_options.include_usage
boolean
Includes token usage statistics in the last message of the stream. Supported by only some upstream models.
max_tokens
integer
Limits the maximum number of generated tokens. For some reasoning models, it is recommended to use max_completion_tokens instead.
max_completion_tokens
integer
Limits the maximum number of completion tokens, including reasoning tokens. Suitable for models that support reasoning.
temperature
number
Sampling temperature, commonly in the range 0 to 2. Lower values are more stable, higher values are more diverse.
top_p
number
Nucleus sampling parameter, commonly in the range 0 to 1. It is generally not recommended to adjust temperature and top_p significantly at the same time.
tools
array<object>
Function-calling tool list, compatible with OpenAI tools.
tool_choice
string | object
Controls whether the model calls tools. Common values are auto, none, and required; you can also specify a particular function.
response_format
object
Specifies the output format, such as { "type": "json_object" } or json_schema.
reasoning_effort
string
Reasoning effort. Common values are low, medium, and high; whether it takes effect depends on the model.

Request Example

curl -N -X POST https://octopusx.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      { "role": "system", "content": "You are a concise technical assistant." },
      { "role": "user", "content": "Explain the role of an API gateway in three points." }
    ],
    "stream": true,
    "stream_options": {
      "include_usage": true
    }
  }'

Multimodal Streaming

curl -N -X POST https://octopusx.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Summarize the main conclusions of this chart." },
          { "type": "image_url", "image_url": { "url": "https://.../chart.png", "detail": "high" } }
        ]
      }
    ],
    "stream": true
  }'

Response Example

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":"API"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":" gateway"},"finish_reason":null}]}

data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","created":1735689600,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":26,"completion_tokens":38,"total_tokens":64}}

data: [DONE]

Response Fields

id
string
The response ID generated for this request.
object
string
The streaming response is always chat.completion.chunk.
choices[].delta
object
Incremental content. May include role, content, reasoning_content, or tool_calls.
choices[].finish_reason
string
Reason for completion. Common values are stop, length, and tool_calls.
usage
object
Usage statistics. It is guaranteed to appear only when the upstream returns usage data and stream_options.include_usage is enabled.