# 原生 Claude 格式

來源: https://docs.aicentos.com/zh-TW/api/chat/claude

Language: zh-TW

聊天（Chat）

`POST /messages`

## 驗證

將 API Key 存入環境變數 `AICENTOS_API_KEY`；shell 範例會將其值展開至 `Authorization: Bearer` 標頭。

在控制台「權杖管理」取得的 API 金鑰

位置：`header`

## 請求主體

`application/json`

TypeScript 型別定義

在 TypeScript 中使用 request body 型別

## 回應主體

###

`application/json`

###

`application/json`

###

`application/json`

```bash
export AICENTOS_API_KEY="sk-your-aicentos-api-key"

curl -X POST "https://aicentos.com/v1/messages" \
  -H "Authorization: Bearer $AICENTOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{    "model": "claude-sonnet-4-6",    "max_tokens": 256,    "messages": [      {        "role": "user",        "content": "用一句話介紹你自己"      }    ]  }'
```

```bash
{
  "id": "string",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "string"
    }
  ],
  "model": "string",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

```bash
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```

```bash
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```