Messages(Claude 格式)
curl --request POST \
--url https://zero.cat/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'anthropic-version: <anthropic-version>' \
--data '
{
"model": "claude-3-opus-20240229",
"messages": [
{
"content": "<string>"
}
],
"max_tokens": 2,
"system": "<string>",
"temperature": 0.5,
"top_p": 123,
"top_k": 123,
"stream": true,
"stop_sequences": [
"<string>"
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": {
"name": "<string>"
},
"thinking": {
"budget_tokens": 123
},
"metadata": {
"user_id": "<string>"
}
}
'import requests
url = "https://zero.cat/v1/messages"
payload = {
"model": "claude-3-opus-20240229",
"messages": [{ "content": "<string>" }],
"max_tokens": 2,
"system": "<string>",
"temperature": 0.5,
"top_p": 123,
"top_k": 123,
"stream": True,
"stop_sequences": ["<string>"],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": { "name": "<string>" },
"thinking": { "budget_tokens": 123 },
"metadata": { "user_id": "<string>" }
}
headers = {
"anthropic-version": "<anthropic-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'anthropic-version': '<anthropic-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'claude-3-opus-20240229',
messages: [{content: '<string>'}],
max_tokens: 2,
system: '<string>',
temperature: 0.5,
top_p: 123,
top_k: 123,
stream: true,
stop_sequences: ['<string>'],
tools: [{name: '<string>', description: '<string>', input_schema: {}}],
tool_choice: {name: '<string>'},
thinking: {budget_tokens: 123},
metadata: {user_id: '<string>'}
})
};
fetch('https://zero.cat/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "<string>",
"type": "message",
"role": "assistant",
"content": [
{
"type": "<string>",
"text": "<string>"
}
],
"model": "<string>",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123
}
}聊天
Messages(Claude 格式)
Anthropic Claude Messages API 格式的请求。
需要在请求头中包含 anthropic-version。
POST
/
v1
/
messages
Messages(Claude 格式)
curl --request POST \
--url https://zero.cat/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'anthropic-version: <anthropic-version>' \
--data '
{
"model": "claude-3-opus-20240229",
"messages": [
{
"content": "<string>"
}
],
"max_tokens": 2,
"system": "<string>",
"temperature": 0.5,
"top_p": 123,
"top_k": 123,
"stream": true,
"stop_sequences": [
"<string>"
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": {
"name": "<string>"
},
"thinking": {
"budget_tokens": 123
},
"metadata": {
"user_id": "<string>"
}
}
'import requests
url = "https://zero.cat/v1/messages"
payload = {
"model": "claude-3-opus-20240229",
"messages": [{ "content": "<string>" }],
"max_tokens": 2,
"system": "<string>",
"temperature": 0.5,
"top_p": 123,
"top_k": 123,
"stream": True,
"stop_sequences": ["<string>"],
"tools": [
{
"name": "<string>",
"description": "<string>",
"input_schema": {}
}
],
"tool_choice": { "name": "<string>" },
"thinking": { "budget_tokens": 123 },
"metadata": { "user_id": "<string>" }
}
headers = {
"anthropic-version": "<anthropic-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'anthropic-version': '<anthropic-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'claude-3-opus-20240229',
messages: [{content: '<string>'}],
max_tokens: 2,
system: '<string>',
temperature: 0.5,
top_p: 123,
top_k: 123,
stream: true,
stop_sequences: ['<string>'],
tools: [{name: '<string>', description: '<string>', input_schema: {}}],
tool_choice: {name: '<string>'},
thinking: {budget_tokens: 123},
metadata: {user_id: '<string>'}
})
};
fetch('https://zero.cat/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "<string>",
"type": "message",
"role": "assistant",
"content": [
{
"type": "<string>",
"text": "<string>"
}
],
"model": "<string>",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123
}
}授权
ZeroCat API 密钥(sk- 开头),在控制台「API 密钥」页面创建。
格式:Authorization: Bearer sk-xxxxxx
请求头
Anthropic API 版本
示例:
"2023-06-01"
Anthropic API Key (可选,也可使用 Bearer Token)
请求体
application/json
示例:
"claude-3-opus-20240229"
Show child attributes
Show child attributes
必填范围:
x >= 1必填范围:
0 <= x <= 1Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes

