> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Qwen Messages

POST https://direct.beatapi.io/v1/messages
Content-Type: application/json

用一个 BeatAPI 密钥，以 Anthropic Messages 格式调用 Qwen3.8 Max 和 Qwen3.8 Flash。- 一个端点 `POST /v1/messages` 覆盖当前所有 Qwen 模型，改 `model` 即可切换。
- 支持流式输出和工具调用。两个模型在整个 100 万 token 窗口内都按统一单价计费。
- 兼容 Anthropic SDK：改 base URL，换成 BeatAPI 密钥即可。每个请求都要带 `anthropic-version` 请求头。
- `tool_choice` 会传给模型，但不是每个模型都执行；`thinking` 不生效。详见下面的请求参数。文本请求建议使用 `https://direct.beatapi.io` 作为 base URL：它不受 Cloudflare 100 秒限制，长时间的非流式请求不会被中途切断。`https://api.beatapi.io` 同样可用；如果你的网络访问不了 `direct.beatapi.io`，请改用它作为备用。两个域名的密钥、模型和价格完全一致。图片和视频 API 只使用 `https://api.beatapi.io`。POST/v1/messages试一试在调试窗口里打开本接口，填入你的 BeatAPI API 密钥即可发送。调用是真实的，费用从你自己的余额中扣除。## 模型把下列 ID 之一作为 `model` 发送。它们是各自独立的模型，不是互相的别名。| 模型 ID           | 上下文（tokens） | 最大输出（tokens） | 定位                                          | 输入，美元 / 100 万 tokens | 输出，美元 / 100 万 tokens | 说明                                                                              |
| --------------- | ----------- | ------------ | ------------------------------------------- | -------------------- | -------------------- | ------------------------------------------------------------------------------- |
| `qwen3.8-max`   | 1,000,000   | 128,000      | 2.4 万亿参数的 MoE 旗舰模型，面向编程、专业工作、多模态理解与长程智能体工作流 | \$1.40               | \$4.20               | 2.4 万亿参数的 MoE 旗舰模型，面向编程、专业工作、多模态理解与长程智能体工作流。上下文 100 万 token，最大输出 128,000 token。 |
| `qwen3.8-flash` | —           | —            | Qwen 视觉语言模型，面向视觉推理、文档与智能体任务                 | \$0.105              | \$0.329              | 速度快、价格低的版本，适合大批量任务。视觉语言模型，面向视觉推理、文档与智能体任务。                                      |- 价格为基础档，已计入折扣。长上下文档、缓存命中输入价和缓存写入价不在本表内，见[价格表](https://beatapi.io/pricing)。
- `—` 表示目录未公布该数字。## 快速开始在服务端安装 `@anthropic-ai/sdk` 或 `anthropic` 包，把密钥放在 `BEATAPI_API_KEY`，不要把它写进浏览器代码。SDK 会自动带上 `anthropic-version` 请求头。以下是请求示例，不是真实的模型输出记录。从 `content` 里的 `text` 块读取答案，再检查 `stop_reason` 和 `usage`。HTTP 200 不能证明答案满足你的任务，请在应用里校验内容。文本请求直接返回，不要为它们轮询 `/v1/tasks`。```bash title="cURL"
curl --request POST \
  --url https://direct.beatapi.io/v1/messages \
  --header "x-api-key: $BEATAPI_API_KEY" \
  --header 'anthropic-version: 2023-06-01' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "qwen3.8-max",
  "max_tokens": 2000,
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}'
``````python title="Python"
import os
from anthropic import Anthropic

client = Anthropic(api_key=os.environ["BEATAPI_API_KEY"], base_url="https://direct.beatapi.io")
message = client.messages.create(
    model="qwen3.8-max",
    max_tokens=2000,
    messages=[
      {
        "role": "user",
        "content": "Design a resilient webhook retry strategy for a payments API."
      }
    ],
)
print(message.content[0].text)
``````javascript title="JavaScript"
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ apiKey: process.env.BEATAPI_API_KEY, baseURL: "https://direct.beatapi.io" });
const message = await client.messages.create({
  "model": "qwen3.8-max",
  "max_tokens": 2000,
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
});
console.log(message.content[0].text);
```## 端点与鉴权`POST https://direct.beatapi.io/v1/messages`x-api-key
string
必需你的 BeatAPI 密钥。也接受 `Authorization: Bearer <BEATAPI_API_KEY>`。每个请求都要带 `anthropic-version` 请求头（例如 `2023-06-01`），Anthropic SDK 会自动添加。鉴权可以用 `x-api-key`，也可以用 `Authorization: Bearer <BEATAPI_API_KEY>`。## 请求参数请求使用 Anthropic Messages 的格式。下列字段会生效；最后两个字段 SDK 可以发送，但不会改变结果。本页没有列出的字段，不保证有任何效果。model
string
必需准确的模型 ID。**可选值**：`qwen3.8-max`, `qwen3.8-flash`- 每个 ID 都是独立的模型，不是其他模型的别名。
- 用你的密钥调用 `GET /v1/models`，确认该密钥已开通哪些模型。max_tokens
integer
必需生成 token 数的上限，包含推理部分。- 网关不会拿你的值去和上面表格里的最大输出比较，请自己控制在该数字以内。
- `max_tokens` 也用来估算一次请求需要多少余额。值特别大时，即使实际输出很短，也可能被 `402 insufficient_credits` 拒绝。按实际需要设置即可。推理型号会先输出推理内容。`max_tokens` 太小时，推理可能把额度用完：`text` 块为空，`stop_reason` 是 `max_tokens`。请给推理和正文都留出空间，看到 `max_tokens` 就调大。messages
object[]
必需对话内容，最早的消息在前。每条消息有 `role`（`user` 或 `assistant`）和 `content`：字符串，或内容块数组。- 文本块（`text`）、模型发出的工具请求（`tool_use`）和你返回的结果（`tool_result`）会生效。
- `tool_result` 块必须带上它所回应的 `tool_use` 块的 `tool_use_id`。system
string | object[]
可选系统提示词：字符串，或文本块数组。多个文本块会拼成一段系统提示词。stream
boolean
可选默认值: false以服务端推送事件（SSE）返回答案。见下文「流式输出」。**默认值**：`false`temperature
number
可选采样温度。它和 `top_p` 调一个就行，不要两个一起改。top_p
number
可选核采样阈值。stop_sequences
string[]
可选停止序列，生成到这些序列时停止。tools
object[]
可选模型可以调用的工具定义。每个工具通过 `name`、`description` 和 `input_schema` 生效。模型会用 `tool_use` 块作答；把结果放进下一条 `user` 消息的 `tool_result` 块里传回。tool_choice
object
可选模型如何使用 `tools`。`{"type": "auto"}` 由模型决定（默认），`{"type": "any"}` 要求它调用其中一个工具，`{"type": "tool", "name": "..."}` 要求它调用指定工具，`{"type": "none"}` 禁止调用工具。`disable_parallel_tool_use: true` 限定每次回答只调用一个工具。没有 `tools` 时忽略。这个设置会传给模型，但不是每个模型都会执行：我们实测（2026-10-15）DeepSeek 不理会它，Qwen 会执行 `any`、不执行指定工具。请以回答里是否有 `tool_use` 块为准，不要预设一定会调用。thinking
object
可选不生效。它既不会开启也不会关闭推理，也不会设置推理预算。默认就推理的模型会继续推理，推理内容以 `thinking` 块返回。## 响应非流式调用返回一个 JSON 对象。以下是精简后的示例。```json
{
  "id": "msg_example",
  "type": "message",
  "role": "assistant",
  "model": "qwen3.8-max",
  "content": [
    {
      "type": "text",
      "text": "Retry with exponential backoff and jitter, and make every handler idempotent."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 19,
    "output_tokens": 16
  }
}
```### 响应字段| 字段               | 类型         | 说明                                                                                              |
| ---------------- | ---------- | ----------------------------------------------------------------------------------------------- |
| `id`             | `string`   | 消息 ID。请连同请求 ID 一起记录，方便售后和对账。                                                                    |
| `model`          | `string`   | 实际作答的模型。                                                                                        |
| `content[]`      | `object[]` | 内容块：`thinking`（推理型号会在答案之前返回）、`text` 和 `tool_use`。                                               |
| `content[].text` | `string`   | `text` 块的答案文本。                                                                                  |
| `stop_reason`    | `string`   | `end_turn` 表示完整作答，`tool_use` 表示要调用工具，`max_tokens` 表示达到了 `max_tokens`，`stop_sequence` 表示命中了停止序列。 |
| `usage`          | `object`   | `input_tokens` 和 `output_tokens`。推理部分计入输出。调用按实际 token 用量计量。                                     |## 流式输出设置 `"stream": true`。流以 `message_start` 开始，以 `message_stop` 结束；中间的内容块通过 `content_block_start`、`content_block_delta` 和 `content_block_stop` 事件到达，`message_delta` 携带 `stop_reason`。- 响应类型是 `text/event-stream`；不流式时是 `application/json`。
- 文本通过 `text_delta` 事件到达。推理型号会在文本块之前，先用 `thinking_delta` 事件发送一个 `thinking` 块。工具参数通过 `input_json_delta` 事件到达。
- 调用模型之前就失败的请求，返回的是带 HTTP 状态码的普通 JSON 错误，而不是流事件。
- 请设置明确的超时，并安全地重连流式响应。```text
event: message_start
data: {"type":"message_start","message":{"id":"msg_example","type":"message","role":"assistant","content":[],"usage":{"input_tokens":19,"output_tokens":1}}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Retry"}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" with backoff"}}

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":16}}

event: message_stop
data: {"type":"message_stop"}
```## 错误| 错误或现象                                   | 原因                                  | 处理                            |
| --------------------------------------- | ----------------------------------- | ----------------------------- |
| `text` 块为空，`stop_reason` 是 `max_tokens` | 推理型号把整个 `max_tokens` 额度都用在了推理上。     | 调大 `max_tokens`，但不要超过模型的最大输出。 |
| `402 insufficient_credits`              | 余额低于这次请求的价格，常见原因是 `max_tokens` 特别大。 | 充值，或调小 `max_tokens`。          |
| `403 forbidden`                         | 账户只有免费额度而该模型不在免费列表里，或该模型不在密钥所属分组内。  | 充值、改用免费模型，或换一把分组能访问该模型的密钥。    |
| `404 not_found`                         | 模型 ID 不存在，或该密钥没有开通。                 | 用 `GET /v1/models` 列出已开通的模型。  |
| `429 rate_limit_exceeded`               | 达到账户或免费模型的频率限制。                     | 等待 `Retry-After` 指定的时间后重试。    |### HTTP 错误速查认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。| HTTP 状态码 | 错误码                                                      | 怎么做                                             |
| -------- | -------------------------------------------------------- | ----------------------------------------------- |
| 400      | `bad_request`、`content_policy_violation`                 | 修正请求或输入，不要原样重发。                                 |
| 401      | `missing_api_key`、`invalid_api_key`                      | 检查密钥，不要重试。                                      |
| 402      | `insufficient_credits`                                   | 充值，或提高密钥额度。过大的 `max_tokens` 也可能触发。              |
| 403      | `forbidden`                                              | 模型不在该密钥的分组或 IP 白名单内，或免费额度不能调用该模型。               |
| 404      | `not_found`                                              | 模型不存在：用 `GET /v1/models` 查看已开通的模型。              |
| 429      | `rate_limit_exceeded`                                    | 等待 `Retry-After` 或 `retry_after_seconds` 后退避重试。 |
| 500      | `internal_error`、`temporary_error`                       | 退避后重试一两次。                                       |
| 503      | `model_unavailable`、`upstream_timeout`、`temporary_error` | 退避重试，或换用其他模型。                                   |完整的错误码表和重试策略见[错误码](/errors#text-endpoints)。## 注意事项- Qwen 模型也可以用 [Chat Completions](/text-api/qwen/chat-completions) 和 [OpenAI Responses](/text-api/qwen/responses) 调用。
- 缓存输入的价格和新输入分开计。重复的提示词前缀会自动按缓存费率计费，没有需要调用的缓存接口；是否命中请看 `usage` 里的缓存输入数量。
- 每个请求都要带 `anthropic-version`。不要依赖 `thinking`：它不生效。
- 密钥只放在可信的服务端，记录响应里的请求 ID，只对 `429`、`500` 和 `503` 重试。

Reference: https://docs.beatapi.io/api-reference/text-api/qwen-messages

## Authentication

- `Authorization` header (bearer token, required) — Send your API key as `Authorization: Bearer <BEATAPI_API_KEY>`.

## Servers

- `https://direct.beatapi.io` (Direct, default)
- `https://api.beatapi.io` (API)

## Request

### Body (application/json)

This endpoint expects an object.

- `model` (enum, required) — 准确的模型 ID。 每个 ID 都是独立的模型，不是其他模型的别名。 用你的密钥调用 `GET /v1/models`，确认该密钥已开通哪些模型。 `qwen3.8-max`, `qwen3.8-flash`
  - Allowed values: `qwen3.8-max`, `qwen3.8-flash`
- `max_tokens` (integer, required) — 生成 token 数的上限，包含推理部分。 网关不会拿你的值去和上面表格里的最大输出比较，请自己控制在该数字以内。 `max_tokens` 也用来估算一次请求需要多少余额。值特别大时，即使实际输出很短，也可能被 `402 insufficient_credits` 拒绝。按实际需要设置即可。 推理型号会先输出推理内容。`max_tokens` 太小时，推理可能把额度用完：`text` 块为空，`stop_reason` 是 `max_tokens`。请给推理和正文都留出空间，看到 `max_tokens` 就调大。
- `messages` (list of V1MessagesPostRequestBodyContentApplicationJsonSchemaMessagesItems, required) — 对话内容，最早的消息在前。每条消息有 `role`（`user` 或 `assistant`）和 `content`：字符串，或内容块数组。 文本块（`text`）、模型发出的工具请求（`tool_use`）和你返回的结果（`tool_result`）会生效。 `tool_result` 块必须带上它所回应的 `tool_use` 块的 `tool_use_id`。
- `system` (V1MessagesPostRequestBodyContentApplicationJsonSchemaSystem, optional) — 系统提示词：字符串，或文本块数组。多个文本块会拼成一段系统提示词。
- `stream` (boolean, optional, default: false) — 以服务端推送事件（SSE）返回答案。见下文「流式输出」。
- `temperature` (double, optional) — 采样温度。它和 `top_p` 调一个就行，不要两个一起改。
- `top_p` (double, optional) — 核采样阈值。
- `stop_sequences` (list of string, optional) — 停止序列，生成到这些序列时停止。
- `tools` (list of V1MessagesPostRequestBodyContentApplicationJsonSchemaToolsItems, optional) — 模型可以调用的工具定义。每个工具通过 `name`、`description` 和 `input_schema` 生效。模型会用 `tool_use` 块作答；把结果放进下一条 `user` 消息的 `tool_result` 块里传回。
- `tool_choice` (V1MessagesPostRequestBodyContentApplicationJsonSchemaToolChoice, optional) — 模型如何使用 `tools`。`{"type": "auto"}` 由模型决定（默认），`{"type": "any"}` 要求它调用其中一个工具，`{"type": "tool", "name": "..."}` 要求它调用指定工具，`{"type": "none"}` 禁止调用工具。`disable_parallel_tool_use: true` 限定每次回答只调用一个工具。没有 `tools` 时忽略。这个设置会传给模型，但不是每个模型都会执行：我们实测（2026-10-15）DeepSeek 不理会它，Qwen 会执行 `any`、不执行指定工具。请以回答里是否有 `tool_use` 块为准，不要预设一定会调用。
- `thinking` (V1MessagesPostRequestBodyContentApplicationJsonSchemaThinking, optional) — 不生效。它既不会开启也不会关闭推理，也不会设置推理预算。默认就推理的模型会继续推理，推理内容以 `thinking` 块返回。

## Response

### 200

非流式调用返回一个 JSON 对象。以下是精简后的示例。

- `id` (string, optional) — 消息 ID。请连同请求 ID 一起记录，方便售后和对账。
- `model` (string, optional) — 实际作答的模型。
- `content` (list of V1MessagesPostResponsesContentApplicationJsonSchemaContentItems, optional) — 内容块：`thinking`（推理型号会在答案之前返回）、`text` 和 `tool_use`。
- `stop_reason` (string, optional) — `end_turn` 表示完整作答，`tool_use` 表示要调用工具，`max_tokens` 表示达到了 `max_tokens`，`stop_sequence` 表示命中了停止序列。
- `usage` (V1MessagesPostResponsesContentApplicationJsonSchemaUsage, optional) — `input_tokens` 和 `output_tokens`。推理部分计入输出。调用按实际 token 用量计量。

## Errors

### 400 Bad Request Error

`bad_request`、`content_policy_violation` 修正请求或输入，不要原样重发。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

### 401 Unauthorized Error

`missing_api_key`、`invalid_api_key` 检查密钥，不要重试。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

### 402 Payment Required Error

`insufficient_credits` 充值，或提高密钥额度。过大的 `max_tokens` 也可能触发。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

### 403 Forbidden Error

`forbidden` 模型不在该密钥的分组或 IP 白名单内，或免费额度不能调用该模型。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

### 404 Not Found Error

`not_found` 模型不存在：用 `GET /v1/models` 查看已开通的模型。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

### 429 Too Many Requests Error

`rate_limit_exceeded` 等待 `Retry-After` 或 `retry_after_seconds` 后退避重试。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

### 500 Internal Server Error

`internal_error`、`temporary_error` 退避后重试一两次。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

### 503 Service Unavailable Error

`model_unavailable`、`upstream_timeout`、`temporary_error` 退避重试，或换用其他模型。 认证、路由、限速和未知模型这几类失败发生在调用模型之前，返回 BeatAPI 信封：`error.code`、`error.message`、`retryable`、`request_id`。其余失败保持 Anthropic 格式 `{"type": "error", "error": {"type", "message"}}`：错误码在 `error.type`，request id 附在 `message` 末尾。详见[错误码](/errors#text-endpoints)。

- `map from string to any`

## Types

### V1MessagesPostRequestBodyContentApplicationJsonSchemaMessagesItems

- `role` (string, required)
- `content` (V1MessagesPostRequestBodyContentApplicationJsonSchemaMessagesItemsContent, required)

### V1MessagesPostRequestBodyContentApplicationJsonSchemaSystem

系统提示词：字符串，或文本块数组。多个文本块会拼成一段系统提示词。

### V1MessagesPostRequestBodyContentApplicationJsonSchemaToolsItems

### V1MessagesPostRequestBodyContentApplicationJsonSchemaToolChoice

模型如何使用 `tools`。`{"type": "auto"}` 由模型决定（默认），`{"type": "any"}` 要求它调用其中一个工具，`{"type": "tool", "name": "..."}` 要求它调用指定工具，`{"type": "none"}` 禁止调用工具。`disable_parallel_tool_use: true` 限定每次回答只调用一个工具。没有 `tools` 时忽略。这个设置会传给模型，但不是每个模型都会执行：我们实测（2026-10-15）DeepSeek 不理会它，Qwen 会执行 `any`、不执行指定工具。请以回答里是否有 `tool_use` 块为准，不要预设一定会调用。

### V1MessagesPostRequestBodyContentApplicationJsonSchemaThinking

不生效。它既不会开启也不会关闭推理，也不会设置推理预算。默认就推理的模型会继续推理，推理内容以 `thinking` 块返回。

### V1MessagesPostResponsesContentApplicationJsonSchemaContentItems

- `text` (string, optional) — `text` 块的答案文本。

### V1MessagesPostResponsesContentApplicationJsonSchemaUsage

`input_tokens` 和 `output_tokens`。推理部分计入输出。调用按实际 token 用量计量。

### V1MessagesPostRequestBodyContentApplicationJsonSchemaMessagesItemsContent

## Examples

**Request**

```json
{
  "model": "qwen3.8-max",
  "max_tokens": 2000,
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}
```

**Response**

```json
{
  "id": "msg_example",
  "model": "qwen3.8-max",
  "content": [
    {
      "text": "Retry with exponential backoff and jitter, and make every handler idempotent.",
      "type": "text"
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 19,
    "output_tokens": 16
  },
  "role": "assistant",
  "stop_sequence": null,
  "type": "message"
}
```

**SDK Code**

```python 快速开始
import requests

url = "https://direct.beatapi.io/v1/messages"

payload = {
    "model": "qwen3.8-max",
    "max_tokens": 2000,
    "messages": [
        {
            "role": "user",
            "content": "Design a resilient webhook retry strategy for a payments API."
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript 快速开始
const url = 'https://direct.beatapi.io/v1/messages';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"qwen3.8-max","max_tokens":2000,"messages":[{"role":"user","content":"Design a resilient webhook retry strategy for a payments API."}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go 快速开始
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://direct.beatapi.io/v1/messages"

	payload := strings.NewReader("{\n  \"model\": \"qwen3.8-max\",\n  \"max_tokens\": 2000,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby 快速开始
require 'uri'
require 'net/http'

url = URI("https://direct.beatapi.io/v1/messages")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"qwen3.8-max\",\n  \"max_tokens\": 2000,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java 快速开始
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://direct.beatapi.io/v1/messages")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"qwen3.8-max\",\n  \"max_tokens\": 2000,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}")
  .asString();
```

```php 快速开始
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://direct.beatapi.io/v1/messages', [
  'body' => '{
  "model": "qwen3.8-max",
  "max_tokens": 2000,
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp 快速开始
using RestSharp;

var client = new RestClient("https://direct.beatapi.io/v1/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"qwen3.8-max\",\n  \"max_tokens\": 2000,\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Design a resilient webhook retry strategy for a payments API.\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift 快速开始
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "qwen3.8-max",
  "max_tokens": 2000,
  "messages": [
    [
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://direct.beatapi.io/v1/messages")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```