POST
https://octopusx.ai
/
v1
/
chat
/
completions
curl -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 an API documentation assistant." },
      { "role": "user", "content": "Generate a summary of the API description." }
    ],
    "stream": false
  }'
{
  "id": "chatcmpl_abc123",
  "object": "chat.completion",
  "created": 1735689600,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This API accepts unified conversation messages and generates a complete response in a single shot based on the model."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "completion_tokens": 24,
    "total_tokens": 55
  }
}

General Chat Completions API (Default Non-Streaming)

Suitable for background tasks, structured output, short Q&A, and scenarios where real-time display of the generation process is not required. When stream is omitted or set to false, the API returns a complete chat.completion object in a single response.

Request Body

model
string
required
Model name. Can be queried via the model list.
messages
array<object>
required
An array of conversation messages. Each message must contain at least role and content.
stream
boolean
Non-streaming response when omitted or set to false.
response_format
object
Specifies the output format. Commonly used for JSON output or JSON Schema structured output.
tools
array<object>
A list of function calling tools.
tool_choice
string | object
Controls the tool calling strategy.
temperature
number
Sampling temperature. The default value is determined by the upstream model.
top_p
number
Nucleus sampling parameter.
max_tokens
integer
Maximum number of generated tokens.
seed
number
Random seed. When supported by the upstream model, this can improve reproducibility.

Request Example

curl -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 an API documentation assistant." },
      { "role": "user", "content": "Generate a summary of the API description." }
    ],
    "stream": false
  }'

Structured Output

curl -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": "Extract the topic and tone from this sentence: This version was released on a very steady cadence." }
    ],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "analysis",
        "schema": {
          "type": "object",
          "properties": {
            "topic": { "type": "string" },
            "tone": { "type": "string" }
          },
          "required": ["topic", "tone"]
        }
      }
    }
  }'

Response Example

{
  "id": "chatcmpl_abc123",
  "object": "chat.completion",
  "created": 1735689600,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This API accepts unified conversation messages and generates a complete response in a single shot based on the model."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "completion_tokens": 24,
    "total_tokens": 55
  }
}

Response Fields

choices[].message.content
string | null
The text content generated by the model. May be null when a tool call occurs.
choices[].message.tool_calls
array<object>
The function tools requested by the model.
usage
object
Token usage for this request.