> ## Documentation Index
> Fetch the complete documentation index at: https://doc.octopusx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# General Chat Completions API (Default Non-Streaming)

> Use the OpenAI Chat Completions-compatible format to initiate a conversation and return the full result in one response.

# 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

<ParamField body="model" type="string" required>
  Model name. Can be queried via the [model list](./models).
</ParamField>

<ParamField body="messages" type="array<object>" required>
  An array of conversation messages. Each message must contain at least `role` and `content`.
</ParamField>

<ParamField body="stream" type="boolean">
  Non-streaming response when omitted or set to `false`.
</ParamField>

<ParamField body="response_format" type="object">
  Specifies the output format. Commonly used for JSON output or JSON Schema structured output.
</ParamField>

<ParamField body="tools" type="array<object>">
  A list of function calling tools.
</ParamField>

<ParamField body="tool_choice" type="string | object">
  Controls the tool calling strategy.
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature. The default value is determined by the upstream model.
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling parameter.
</ParamField>

<ParamField body="max_tokens" type="integer">
  Maximum number of generated tokens.
</ParamField>

<ParamField body="seed" type="number">
  Random seed. When supported by the upstream model, this can improve reproducibility.
</ParamField>

## Request Example

<RequestExample>
  ```bash theme={null}
  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
    }'
  ```
</RequestExample>

### Structured Output

```bash theme={null}
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

<ResponseExample>
  ```json 200 theme={null}
  {
    "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
    }
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "message": "field model is required",
      "type": "invalid_request_error",
      "param": "",
      "code": "invalid_request"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "message": "Invalid API key provided",
      "type": "invalid_request_error",
      "param": "",
      "code": "invalid_api_key"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "message": "Insufficient user quota",
      "type": "new_api_error",
      "param": "",
      "code": "insufficient_user_quota"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "message": "The current request rate is too high. Please try again later.",
      "type": "new_api_error",
      "param": "",
      "code": "too_many_requests"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "message": "bad response body",
      "type": "new_api_error",
      "param": "",
      "code": "bad_response_body"
    }
  }
  ```
</ResponseExample>

## Response Fields

<ResponseField name="choices[].message.content" type="string | null">
  The text content generated by the model. May be `null` when a tool call occurs.
</ResponseField>

<ResponseField name="choices[].message.tool_calls" type="array<object>">
  The function tools requested by the model.
</ResponseField>

<ResponseField name="usage" type="object">
  Token usage for this request.
</ResponseField>

## Related APIs

* [General Chat Completions API (Default Streaming)](./chat-completions-stream)
* [OpenAI Multimodal Responses API](./openai-responses)
* [Text Completions API](./completions)
