原生Claude格式
Anthropic Claude Messages API 格式的请求。 需要在请求头中包含 `anthropic-version`。
POST
https://api.xiexus.cn/v1/messages
请求体:可选
接口信息
方法
POST路径
/v1/messages完整地址
https://api.xiexus.cn/v1/messages请求体
可选
标签
聊天(Chat)
响应码
200
静态文件
当前接口页内已嵌入 OpenAPI JSON;如果需要查看总文件,可直接打开固定静态文件
relay.json。当前 JSON
../../openapi/generated/ai-model/聊天(Chat)/post-v1-messages-createmessage-383826476.json总文件
../../openapi/relay.jsonOpenAPI JSON
已将服务地址固定为
https://api.xiexus.cn,其余结构保持和源文档一致。{
"openapi": "3.1.0",
"info": {
"title": "原生Claude格式",
"version": "1.0.0",
"description": "Anthropic Claude Messages API 格式的请求。\n需要在请求头中包含 `anthropic-version`。\n"
},
"tags": [
{
"name": "聊天(Chat)"
}
],
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer",
"description": "使用 Bearer Token 认证。\n格式: `Authorization: Bearer sk-xxxxxx`\n"
}
}
},
"paths": {
"/v1/messages": {
"post": {
"tags": [
"聊天(Chat)"
],
"summary": "原生Claude格式",
"description": "Anthropic Claude Messages API 格式的请求。\n需要在请求头中包含 `anthropic-version`。\n",
"operationId": "createmessage",
"parameters": [
{
"name": "anthropic-version",
"in": "header",
"required": true,
"description": "Anthropic API 版本",
"schema": {
"type": "string",
"examples": [
"2023-06-01"
]
}
},
{
"name": "x-api-key",
"in": "header",
"required": false,
"description": "Anthropic API Key (可选,也可使用 Bearer Token)",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"model",
"messages",
"max_tokens"
],
"properties": {
"model": {
"type": "string",
"examples": [
"claude-3-opus-20240229"
]
},
"messages": {
"type": "array",
"items": {
"type": "object",
"required": [
"role",
"content"
],
"properties": {
"role": {
"type": "string",
"enum": [
"user",
"assistant"
]
},
"content": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"text",
"image",
"tool_use",
"tool_result"
]
},
"text": {
"type": "string"
},
"source": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"base64",
"url"
]
},
"media_type": {
"type": "string"
},
"data": {
"type": "string"
},
"url": {
"type": "string"
}
},
"x-apifox-orders": [
"type",
"media_type",
"data",
"url"
]
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"input": {
"type": "object",
"properties": {},
"x-apifox-orders": []
},
"tool_use_id": {
"type": "string"
},
"content": {
"type": "string"
}
},
"x-apifox-orders": [
"type",
"text",
"source",
"id",
"name",
"input",
"tool_use_id",
"content"
]
}
}
]
}
},
"x-apifox-orders": [
"role",
"content"
]
}
},
"system": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "object",
"properties": {},
"x-apifox-orders": []
}
}
]
},
"max_tokens": {
"type": "integer",
"minimum": 1
},
"temperature": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"top_p": {
"type": "number"
},
"top_k": {
"type": "integer"
},
"stream": {
"type": "boolean"
},
"stop_sequences": {
"type": "array",
"items": {
"type": "string"
}
},
"tools": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"input_schema": {
"type": "object",
"properties": {},
"x-apifox-orders": []
}
},
"x-apifox-orders": [
"name",
"description",
"input_schema"
]
}
},
"tool_choice": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"auto",
"any",
"tool"
]
},
"name": {
"type": "string"
}
},
"x-apifox-orders": [
"type",
"name"
]
}
]
},
"thinking": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"enabled",
"disabled"
]
},
"budget_tokens": {
"type": "integer"
}
},
"x-apifox-orders": [
"type",
"budget_tokens"
]
},
"metadata": {
"type": "object",
"properties": {
"user_id": {
"type": "string"
}
},
"x-apifox-orders": [
"user_id"
]
}
},
"x-apifox-orders": [
"model",
"messages",
"system",
"max_tokens",
"temperature",
"top_p",
"top_k",
"stream",
"stop_sequences",
"tools",
"tool_choice",
"thinking",
"metadata"
]
}
}
}
},
"security": [
{
"BearerAuth": []
}
],
"responses": {
"200": {
"description": "成功创建响应",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string",
"examples": [
"message"
]
},
"role": {
"type": "string",
"examples": [
"assistant"
]
},
"content": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"text": {
"type": "string"
}
},
"x-apifox-orders": [
"type",
"text"
]
}
},
"model": {
"type": "string"
},
"stop_reason": {
"type": "string",
"enum": [
"end_turn",
"max_tokens",
"stop_sequence",
"tool_use"
]
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer"
},
"output_tokens": {
"type": "integer"
},
"cache_creation_input_tokens": {
"type": "integer"
},
"cache_read_input_tokens": {
"type": "integer"
}
},
"x-apifox-orders": [
"input_tokens",
"output_tokens",
"cache_creation_input_tokens",
"cache_read_input_tokens"
]
}
},
"x-apifox-orders": [
"id",
"type",
"role",
"content",
"model",
"stop_reason",
"usage"
]
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://api.xiexus.cn",
"description": "固定生产地址"
}
]
}