> 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.

# GPT Chat Completions

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

用一个 BeatAPI 密钥，通过同一个 OpenAI Chat Completions 端点调用 GPT-6.1 Sol、GPT-6 Astra、GPT-6 Sol 和 GPT-6 Luna。- 一个端点 `POST /v1/chat/completions` 覆盖当前所有 GPT 模型，改 `model` 即可切换。
- 支持文本与图片输入、文本输出、流式输出、函数调用、结构化输出和可配置的推理强度。
- 兼容 OpenAI SDK：改 base URL，换成 BeatAPI 密钥即可。
- 新的推理和工具调用集成，推荐使用 [OpenAI Responses](/text-api/gpt/responses)。文本请求建议使用 `https://direct.beatapi.io` 作为 base URL：它不受 Cloudflare 100 秒限制，长时间的非流式请求不会被中途切断。`https://api.beatapi.io` 同样可用；如果你的网络访问不了 `direct.beatapi.io`，请改用它作为备用。两个域名的密钥、模型和价格完全一致。图片和视频 API 只使用 `https://api.beatapi.io`。POST/v1/chat/completions试一试在调试窗口里打开本接口，填入你的 BeatAPI API 密钥即可发送。调用是真实的，费用从你自己的余额中扣除。## 模型把下列 ID 之一作为 `model` 发送。它们是各自独立的模型，不是互相的别名。| 模型 ID         | 上下文（tokens） | 最大输出（tokens） | 定位                                            | 输入，美元 / 100 万 tokens | 输出，美元 / 100 万 tokens | 说明                                           |
| ------------- | ----------- | ------------ | --------------------------------------------- | -------------------- | -------------------- | -------------------------------------------- |
| `gpt-6.1-sol` | 1,050,000   | 128,000      | GPT-6.1 Sol，面向编程、计算机操作与专业工作；工具调用请使用 Responses | \$0.80               | \$4.00               | 推理强度 `low` 到 `max`。输入超过 27.2 万 tokens 后费率更高。 |
| `gpt-6-astra` | 1,000,000   | 128,000      | 能力最强的 GPT 模型：复杂推理、编程、计算机操作、研究与文档创作            | \$4.00               | \$20.00              | 输入超过 27.2 万 tokens 后费率更高。                    |
| `gpt-6-sol`   | 1,050,000   | 128,000      | 中档 GPT-6 模型，以较低价格支持日常编程、研究与智能体任务              | \$0.80               | \$4.00               | 与 GPT-6.1 Sol、GPT-5.6 Sol 是不同的模型。            |
| `gpt-6-luna`  | 1,050,000   | 128,000      | 高性价比 GPT-6 模型，适合目标明确的大批量任务                    | \$0.04               | \$0.20               | 适合高频、目标明确的任务，如抽取、分类和路由。                      |- 价格为基础档，已计入折扣。长上下文档、缓存命中输入价和缓存写入价不在本表内，见[价格表](https://beatapi.io/pricing)。
- `—` 表示目录未公布该数字。本系列仍可调用的旧 ID 见[旧型号](/text-api/legacy-models)。## 快速开始在服务端安装 `openai` 包，把密钥放在 `BEATAPI_API_KEY`，不要把它写进浏览器代码。以下是请求示例，不是真实的模型输出记录。从 `choices[0].message.content` 读取答案，再检查 `finish_reason` 和 `usage`。HTTP 200 不能证明答案满足你的任务，请在应用里校验内容。文本请求直接返回，不要为它们轮询 `/v1/tasks`。```bash title="cURL"
curl --request POST \
  --url https://direct.beatapi.io/v1/chat/completions \
  --header "Authorization: Bearer $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}'
``````python title="Python"
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["BEATAPI_API_KEY"], base_url="https://direct.beatapi.io/v1")
completion = client.chat.completions.create(
    model="gpt-6-luna",
    messages=[
      {
        "role": "user",
        "content": "Design a resilient webhook retry strategy for a payments API."
      }
    ],
)
print(completion.choices[0].message.content)
``````javascript title="JavaScript"
import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.BEATAPI_API_KEY, baseURL: "https://direct.beatapi.io/v1" });
const completion = await client.chat.completions.create({
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
});
console.log(completion.choices[0].message.content);
```## 端点与鉴权`POST https://direct.beatapi.io/v1/chat/completions`Authorization
string
必需`Bearer <BEATAPI_API_KEY>`。密钥带不带 `sk-` 前缀都可以。## 请求参数接受标准的 OpenAI Chat Completions 字段。请求格式兼容并不意味着每个模型厂商特有的选项或工具都受支持，请测试你依赖的选项。model
string
必需准确的模型 ID。**可选值**：`gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`- 仍可调用的旧 ID（`gpt-5.6-sol`、`gpt-5.6-terra`、`gpt-5.6-luna`）见[旧型号](/text-api/legacy-models)。
- 用你的密钥调用 `GET /v1/models`，确认该密钥已开通哪些模型。messages
object[]
必需对话内容，最早的消息在前。每条消息有 `role` 和 `content`。`content` 可以是字符串，也可以是文本与图片的内容片段数组。- 本页所有 GPT 模型都支持图片输入。max_tokens
integer
可选生成 token 数的上限。- 网关接受的最大值是 1,073,741,823，更大的值返回 `400 bad_request`。
- 网关不会拿你的值与上表中的模型最大输出做比较，请自行保持在该数字以内。
- `max_tokens` 还用来估算请求需要的余额。过大的值即使实际输出很短，也可能被 `402 insufficient_credits` 拒绝。按实际需要设置。stream
boolean
可选默认值: false以服务端推送事件的形式返回答案。见下文的流式输出一节。**默认值**：`false`reasoning_effort
string
可选模型作答前的推理强度。建议从 `medium` 开始，再在你自己的负载上评估低一档和高一档的效果。**可选值**：`none`, `low`, `medium`, `high`, `xhigh`, `max`**各模型说明**- `gpt-6.1-sol`：`low`、`medium`、`high`、`xhigh`、`max`。不支持 `none` 和 `minimal`。
- `gpt-5.6-sol`：`none`、`low`、`medium`、`high`、`xhigh`、`max`。
- `gpt-5.6-terra`：`none`、`low`、`medium`、`high`、`xhigh`、`max`。
- `gpt-5.6-luna`：`none`、`low`、`medium`、`high`、`xhigh`、`max`。tools
object[]
可选模型可以调用的函数定义。工具结果放在后续的 `tool` 消息里返回。response_format
object
可选要求结构化输出，例如 JSON schema。## 响应非流式调用返回一个 JSON 对象。以下是节选示例。```json
{
  "id": "chatcmpl-example",
  "object": "chat.completion",
  "created": 1791993600,
  "model": "gpt-6-luna",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Retry with exponential backoff and jitter, and make every handler idempotent."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 16,
    "total_tokens": 35
  }
}
```### 响应字段| 字段                          | 类型       | 说明                                   |
| --------------------------- | -------- | ------------------------------------ |
| `id`                        | `string` | 补全 ID。请与请求 ID 一起记录，便于支持和账单核对。        |
| `model`                     | `string` | 实际作答的模型。                             |
| `choices[].message.content` | `string` | 答案文本。                                |
| `choices[].finish_reason`   | `string` | `stop` 表示答案完整。答案被截断或模型请求调用工具时需要单独处理。 |
| `usage`                     | `object` | token 数量。调用按实际 token 用量计费。           |## 流式输出设置 `"stream": true`。BeatAPI 原样转发服务端推送事件流，不做转换，事件对象与 OpenAI SDK 保持兼容。- 响应类型是 `text/event-stream`；不流式时是 `application/json`。
- 调用模型之前发生的失败，会以带 HTTP 状态码的普通 JSON 错误返回，而不是流事件。
- 设置明确的超时，并安全地重连流式响应。```text
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Retry"},"finish_reason":null}]}

data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" with backoff"},"finish_reason":null}]}

data: {"id":"chatcmpl-example","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]
```## 错误| 错误或现象                      | 原因                               | 处理                                |
| -------------------------- | -------------------------------- | --------------------------------- |
| `400`，推理强度该模型不支持           | 例如在 `gpt-6.1-sol` 上使用 `none`。    | 改用该模型支持的值，见上文 `reasoning_effort`。 |
| `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`。其余失败保持 OpenAI SDK 格式 `{"error": {"message", "type", "code"}}`：错误码在 `error.code`，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)。## 注意事项- GPT 模型也可在 [OpenAI Responses](/text-api/gpt/responses) 上调用。
- 输入超过 27.2 万 tokens 时，`gpt-6.1-sol` 和 `gpt-6-astra` 对整个请求使用更高的档位。规划长上下文负载前请查看[价格表](https://beatapi.io/pricing)。
- 密钥只放在可信的服务端，记录响应里的请求 ID，只对 `429`、`500` 和 `503` 重试。

Reference: https://docs.beatapi.io/api-reference/text-api/gpt-chat-completions

## 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（`gpt-5.6-sol`、`gpt-5.6-terra`、`gpt-5.6-luna`）见[旧型号](/text-api/legacy-models)。 用你的密钥调用 `GET /v1/models`，确认该密钥已开通哪些模型。 `gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`
  - Allowed values: `gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`
- `messages` (list of V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItems, required) — 对话内容，最早的消息在前。每条消息有 `role` 和 `content`。`content` 可以是字符串，也可以是文本与图片的内容片段数组。 本页所有 GPT 模型都支持图片输入。
- `max_tokens` (integer, optional) — 生成 token 数的上限。 网关接受的最大值是 1,073,741,823，更大的值返回 `400 bad_request`。 网关不会拿你的值与上表中的模型最大输出做比较，请自行保持在该数字以内。 `max_tokens` 还用来估算请求需要的余额。过大的值即使实际输出很短，也可能被 `402 insufficient_credits` 拒绝。按实际需要设置。
- `stream` (boolean, optional, default: false) — 以服务端推送事件的形式返回答案。见下文的流式输出一节。
- `reasoning_effort` (enum, optional) — 模型作答前的推理强度。建议从 `medium` 开始，再在你自己的负载上评估低一档和高一档的效果。 `gpt-6.1-sol`: `low`、`medium`、`high`、`xhigh`、`max`。不支持 `none` 和 `minimal`。 `gpt-5.6-sol`: `none`、`low`、`medium`、`high`、`xhigh`、`max`。 `gpt-5.6-terra`: `none`、`low`、`medium`、`high`、`xhigh`、`max`。 `gpt-5.6-luna`: `none`、`low`、`medium`、`high`、`xhigh`、`max`。 `none`, `low`, `medium`, `high`, `xhigh`, `max`
  - Allowed values: `none`, `low`, `medium`, `high`, `xhigh`, `max`
- `tools` (list of V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaToolsItems, optional) — 模型可以调用的函数定义。工具结果放在后续的 `tool` 消息里返回。
- `response_format` (V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaResponseFormat, optional) — 要求结构化输出，例如 JSON schema。

## Response

### 200

非流式调用返回一个 JSON 对象。以下是节选示例。

- `id` (string, optional) — 补全 ID。请与请求 ID 一起记录，便于支持和账单核对。
- `model` (string, optional) — 实际作答的模型。
- `choices` (list of V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItems, optional)
- `usage` (V1ChatCompletionsPostResponsesContentApplicationJsonSchemaUsage, optional) — token 数量。调用按实际 token 用量计费。

## Errors

### 400 Bad Request Error

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

- `map from string to any`

### 403 Forbidden Error

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

- `map from string to any`

## Types

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItems

- `role` (string, required)
- `content` (V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsContent, optional, nullable)
- `name` (string, optional)
- `tool_call_id` (string, optional)
- `tool_calls` (list of V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsToolCallsItems, optional)

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaToolsItems

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaResponseFormat

要求结构化输出，例如 JSON schema。

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItems

- `message` (V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItemsMessage, optional)
- `finish_reason` (string, optional) — `stop` 表示答案完整。答案被截断或模型请求调用工具时需要单独处理。

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaUsage

token 数量。调用按实际 token 用量计费。

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsContent

### V1ChatCompletionsPostRequestBodyContentApplicationJsonSchemaMessagesItemsToolCallsItems

### V1ChatCompletionsPostResponsesContentApplicationJsonSchemaChoicesItemsMessage

- `content` (string, optional) — 答案文本。

## Examples

**Request**

```json
{
  "model": "gpt-6-luna",
  "messages": [
    {
      "role": "user",
      "content": "Design a resilient webhook retry strategy for a payments API."
    }
  ]
}
```

**Response**

```json
{
  "id": "chatcmpl-example",
  "model": "gpt-6-luna",
  "choices": [
    {
      "message": {
        "content": "Retry with exponential backoff and jitter, and make every handler idempotent.",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0
    }
  ],
  "usage": {
    "completion_tokens": 16,
    "prompt_tokens": 19,
    "total_tokens": 35
  },
  "created": 1791993600,
  "object": "chat.completion"
}
```

**SDK Code**

```python 快速开始
import requests

url = "https://direct.beatapi.io/v1/chat/completions"

payload = {
    "model": "gpt-6-luna",
    "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/chat/completions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"gpt-6-luna","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/chat/completions"

	payload := strings.NewReader("{\n  \"model\": \"gpt-6-luna\",\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/chat/completions")

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\": \"gpt-6-luna\",\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/chat/completions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"gpt-6-luna\",\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/chat/completions', [
  'body' => '{
  "model": "gpt-6-luna",
  "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/chat/completions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"gpt-6-luna\",\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": "gpt-6-luna",
  "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/chat/completions")! 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()
```