Documentation renewed! For old docs, visit doc.newapi.pro
New APINew API
User GuideInstallationAPI ReferenceAI ApplicationsHelp & SupportBusiness Cooperation
AI Model APIClaude messages

Claude Chat

Requests in Anthropic Claude Messages API format. The anthropic-version header must be included in the request.

POST
/v1/messages

Authorization

BearerAuth

AuthorizationBearer <token>

使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx

In: header

Header Parameters

anthropic-version*string

Anthropic API 版本

x-api-key?string

Anthropic API Key (可选,也可使用 Bearer Token)

Request Body

application/json

model*string
messages*
system?string|
max_tokens*integer
Range1 <= value
temperature?number
Range0 <= value <= 1
top_p?number
top_k?integer
stream?boolean
stop_sequences?array<string>
tools?
tool_choice?
thinking?
metadata?

Response Body

application/json

curl -X POST "https://api.example.com/v1/messages" \  -H "anthropic-version: 2023-06-01" \  -H "Content-Type: application/json" \  -d '{    "model": "claude-3-opus-20240229",    "messages": [      {        "role": "user",        "content": "string"      }    ],    "max_tokens": 1  }'
{
  "id": "string",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "string",
      "text": "string"
    }
  ],
  "model": "string",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  }
}

How is this guide?

Last updated on