Skip to main content
POST
cURL
POST /v1/messages Use this endpoint for Claude Code, the Anthropic SDK, and applications that use the Anthropic Messages API.
For an SDK, use https://bettertoken.ai as the Base URL. A manual request and the Playground use the full https://bettertoken.ai/v1/messages path.

Test in the Playground

In the Playground on the right, enter your API Key in the x-api-key field, leave anthropic-version as claude-cli/2.0.76 (external, cli), choose an available Claude provider model, and send the request.
Do not use Authorization: Bearer ... for this endpoint. It requires the x-api-key header.

Авторизации

x-api-key
string
header
обязательно

Use your BetterToken API Key in the x-api-key header for Anthropic-compatible requests.

Заголовки

anthropic-version
string
по умолчанию:claude-cli/2.0.76 (external, cli)
обязательно

Anthropic API version header.

Пример:

"claude-cli/2.0.76 (external, cli)"

Тело

application/json
model
string
обязательно

Claude 提供商中可用的模型 ID。

Пример:

"YOUR_MODEL_ID"

max_tokens
integer
по умолчанию:1024
обязательно

单次响应允许生成的最大 token 数。

Требуемый диапазон: x >= 1
Пример:

1024

messages
object[]
обязательно

Anthropic 格式的消息数组。每项应包含 role 和 content。

Minimum array length: 1

Ответ

Claude 提供商模型返回的 Anthropic Messages API 响应。

Anthropic-compatible Messages API 响应。实际字段会随所选模型和请求参数变化。