使用原生登录 access_token 直接扣减本人钱包调用 Anthropic Messages JSON/SSE(需提供 anthropic-version: 2023-06-01)。支持稳定 Idempotency-Key 持久化意图;同一意图重试须保持 Anthropic-Version 与 Anthropic-Beta 头一致。
POST
/pg/messages身份验证
Authorizationstring必填使用登录取得的 native access_token(身份要求:登录 access_token),按路由校验本人归属与受信任浏览器 Origin;生成写入按钱包规则扣费,只读查询不重新预扣;不得使用推理 API Key(sk-…)或 PAT(nap_…)。
Authorization: Bearer $ONEASTER_ACCESS_TOKEN
参数
Idempotency-Keystringheader · 每次新发起的 /pg 生成提交建议由前端生成并持久化稳定的 1–100 位无空格可打印 ASCII 标识(推荐 UUID),断线重试保持原标识与原请求字节。同账号跨所有 /pg POST 协议共用一个命名空间;省略时后端兼容生成并通过 X-OneAster-Intent-ID 返回,但若响应头丢失将无法按意图恢复。
请求正文 · application/json
modelstring必填messagesarray必填systemoneOfcache_controlobjectinference_geostringmax_tokensinteger必填temperaturenumbertop_pnumbertop_kintegerstreambooleanstop_sequencesarraytoolsarraytool_choiceoneOfthinkingobjectcontext_managementobjectoutput_configobjectoutput_formatobjectcontaineroneOfmcp_serversarraymetadataobjectspeedstringservice_tierstringJSON Schema
{
"type": "object",
"required": [
"model",
"messages",
"max_tokens"
],
"properties": {
"model": {
"type": "string",
"example": "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"
}
}
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"input": {
"type": "object",
"properties": {}
},
"tool_use_id": {
"type": "string"
},
"content": {
"type": "string"
}
}
}
}
]
}
}
}
},
"system": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "object",
"properties": {}
}
}
]
},
"cache_control": {
"type": "object",
"properties": {}
},
"inference_geo": {
"type": "string"
},
"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": {}
}
}
}
},
"tool_choice": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"auto",
"any",
"tool",
"none"
]
},
"name": {
"type": "string"
}
}
}
]
},
"thinking": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"enabled",
"disabled"
]
},
"budget_tokens": {
"type": "integer"
}
}
},
"context_management": {
"type": "object",
"properties": {}
},
"output_config": {
"type": "object",
"properties": {}
},
"output_format": {
"type": "object",
"properties": {}
},
"container": {
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {}
}
]
},
"mcp_servers": {
"type": "array",
"items": {
"type": "object",
"properties": {}
}
},
"metadata": {
"type": "object",
"properties": {
"user_id": {
"type": "string"
}
}
},
"speed": {
"type": "string",
"enum": [
"standard",
"fast"
]
},
"service_tier": {
"type": "string",
"enum": [
"auto",
"standard_only"
]
}
}
}