LinkexLinkex Docs
API ReferenceGeneratedClaude messages

Claude 聊天

POST
/v1/messages

Anthropic Claude Messages API 格式的请求。 需要在请求头中包含 anthropic-version

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

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/v1/messages" \  -H "anthropic-version: " \  -H "x-api-key: " \  -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  }}