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

# POST /v1/chat/completions：OpenAI 兼容的聊天推理

> 通过咏唱引擎 ROUTER 发送聊天补全请求。支持流式 SSE、工具调用与标准 OpenAI 参数。

使用标准 OpenAI API 形态向咏唱引擎 ROUTER 发送聊天补全请求。Router 将 `model` 字段匹配到一个配置的入口，然后经由语义或智能体引擎路由该请求。

## 接口

**POST** `/v1/chat/completions`

数据面接口。使用 `Authorization: Bearer <router-key>` 认证。

## 请求体

<ParamField body="model" type="string" required>
  要路由经过的入口名称（例如 `ariacompute/semantic-auto`）。必须与一个配置的入口匹配。
</ParamField>

<ParamField body="messages" type="array" required>
  带有 `role` 与 `content` 字段的消息对象数组，遵循 OpenAI 聊天格式。
</ParamField>

<ParamField body="stream" default="false" type="boolean">
  若为 `true`，响应以服务器推送事件（SSE）形式流式返回。
</ParamField>

<ParamField body="temperature" type="number">
  介于 0 与 2 之间的采样温度。
</ParamField>

<ParamField body="max_tokens" type="integer">
  生成的最大令牌数。
</ParamField>

<ParamField body="tools" type="array">
  用于函数调用的工具定义数组。
</ParamField>

## 响应

<ResponseField name="choices" type="array">
  生成的补全选项。具体形态遵循标准 OpenAI 聊天补全格式。
</ResponseField>

## 示例（非流式）

```bash theme={null}
curl -H 'Authorization: Bearer $ARIA_ROUTER_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "ariacompute/semantic-auto",
    "messages": [{"role": "user", "content": "Hello"}],
    "temperature": 0.7
  }' \
  http://<router-host>:8080/v1/chat/completions
```

```json theme={null}
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1710000000,
  "model": "ariacompute/semantic-auto",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ]
}
```

## 示例（流式）

```bash theme={null}
curl -H 'Authorization: Bearer $ARIA_ROUTER_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "ariacompute/semantic-auto",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": true
  }' \
  http://<router-host>:8080/v1/chat/completions
```

```text theme={null}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk", ... }

data: [DONE]
```
