创建格式化输出 Claude原生

Claude Formatted Output

POST https://api.apizt.com/v1/messages 在线调试 →

Claude Sonnet 5.5 默认启用 adaptive thinking。不要使用 thinking.type: disabled/enabled 或 budget_tokens。最低前置思考模式为 between_tools,effort 仅可为 low/medium/high。查看迁移与响应解析。

▼ Authorization

在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token

示例: Authorization: Bearer ********************

请求参数

Header 参数
Authorizationstring必需
Bearer Token;从环境变量 tokenba_API_KEY 读取。
Content-Typestring必需
示例:application/json
anthropic-versionstring必需
示例:2023-06-01
Body 参数application/json
modelstring必需
示例:claude-sonnet-5-5
max_tokensnumber必需
示例:4096
messagesarray必需
结构见完整 JSON 示例。
output_configobject可选
结构见完整 JSON 示例。

完整 JSON 请求体

{
  "model": "claude-sonnet-5-5",
  "max_tokens": 4096,
  "messages": [
    {
      "role": "user",
      "content": "Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
    }
  ],
  "output_config": {
    "format": {
      "type": "json_schema",
      "schema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "plan_interest": {
            "type": "string"
          },
          "demo_requested": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "email",
          "plan_interest",
          "demo_requested"
        ],
        "additionalProperties": false
      }
    },
    "effort": "high"
  }
}

请求示例代码

curl --fail-with-body --request POST 'https://api.apizt.com/v1/messages' \
  --header "Authorization: Bearer ${tokenba_API_KEY}" \
  --header 'Content-Type: application/json' \
  --header 'anthropic-version: 2023-06-01' \
  --data-raw '{
  "model": "claude-sonnet-5-5",
  "max_tokens": 4096,
  "messages": [
    {
      "role": "user",
      "content": "Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
    }
  ],
  "output_config": {
    "format": {
      "type": "json_schema",
      "schema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "plan_interest": {
            "type": "string"
          },
          "demo_requested": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "email",
          "plan_interest",
          "demo_requested"
        ],
        "additionalProperties": false
      }
    },
    "effort": "high"
  }
}'
async function main() {
  const headers = {
  "Authorization": "Bearer " + process.env.tokenba_API_KEY,
  "anthropic-version": "2023-06-01",
  "Content-Type": "application/json"
};
  const body = JSON.stringify({
  "model": "claude-sonnet-5-5",
  "max_tokens": 4096,
  "messages": [
    {
      "role": "user",
      "content": "Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm."
    }
  ],
  "output_config": {
    "format": {
      "type": "json_schema",
      "schema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "plan_interest": {
            "type": "string"
          },
          "demo_requested": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "email",
          "plan_interest",
          "demo_requested"
        ],
        "additionalProperties": false
      }
    },
    "effort": "high"
  }
});
  const response = await fetch("https://api.apizt.com/v1/messages", { method: "POST", headers, body });
  if (!response.ok) throw new Error("HTTP " + response.status + ": " + await response.text());
  const result = await response.json();
  for (const block of result.content || []) {
    if (block.type === "text") console.log(block.text);
    else if (block.type === "tool_use") console.log(JSON.stringify(block));
  }
}
main().catch(console.error);
import os
import requests

headers = {"Authorization": "Bearer " + os.environ["tokenba_API_KEY"]}
headers.update({'anthropic-version': '2023-06-01'})
payload = {'model': 'claude-sonnet-5-5',
 'max_tokens': 4096,
 'messages': [{'role': 'user',
               'content': 'Extract the key information from this email: John Smith '
                          '([email protected]) is interested in our Enterprise plan and '
                          'wants to schedule a demo for next Tuesday at 2pm.'}],
 'output_config': {'format': {'type': 'json_schema',
                              'schema': {'type': 'object',
                                         'properties': {'name': {'type': 'string'},
                                                        'email': {'type': 'string'},
                                                        'plan_interest': {'type': 'string'},
                                                        'demo_requested': {'type': 'boolean'}},
                                         'required': ['name',
                                                      'email',
                                                      'plan_interest',
                                                      'demo_requested'],
                                         'additionalProperties': False}},
                   'effort': 'high'}}
response = requests.post('https://api.apizt.com/v1/messages', headers=headers, json=payload, timeout=120)
response.raise_for_status()
result = response.json()
for block in result.get("content", []):
    if block.get("type") == "text":
        print(block["text"])
    elif block.get("type") == "tool_use":
        print(block)

返回响应

按 content[].type 读取文本、思考或工具块;thinking 可能出现在首位。工具循环需原样保留思考块与签名,再提交 tool_result。max_tokens 同时覆盖思考和文本。

以下为结构示例,不代表实际调用结果。

{
  "id": "msg_demo",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5-5",
  "content": [
    {
      "type": "text",
      "text": "{\"name\": \"John Smith\", \"email\": \"[email protected]\", \"plan_interest\": \"Enterprise\", \"demo_requested\": true}"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 10,
    "output_tokens": 8
  }
}

当前模型与版本

依据 apizt 价格页,同步于 。以下型号按目录声明的协议与本页用途筛选;不代表所有参数和功能通用。切换前请核对型号说明、令牌分组与参数差异。Gemini 原生接口需同时替换 URL 中的模型 ID。

模型 ID能力标签支持分组
claude-sonnet-5-5对话,识图,工具
分组(6)

AWS-Bedrock-2、AWS-Claude-2、AWS-Claude-3、Claude-Code-1、Claude-Code-2、Kiro-Claude-1

claude-opus-5-5对话,工具,识图
分组(6)

AWS-Bedrock-2、AWS-Claude-2、AWS-Claude-3、Claude-Code-1、Claude-Code-2、Kiro-Claude-1

claude-sonnet-5对话,识图,工具
分组(8)

AWS-Bedrock-2、AWS-Claude-2、AWS-Claude-3、Anthropic-Claude-1、Claude-Code-1、Claude-Code-2、Kiro-Claude-1、Vertex-Claude-1

claude-fable-5-1对话,识图,工具
分组(5)

AWS-Claude-2、AWS-Claude-3、Anthropic-Claude-1、Claude-Code-1、Claude-Code-2

claude-opus-5对话,工具,识图
分组(7)

AWS-Bedrock-2、AWS-Claude-2、AWS-Claude-3、Anthropic-Claude-1、Claude-Code-1、Claude-Code-2、Kiro-Claude-1

claude-opus-4-8对话,识图,工具
分组(8)

AWS-Bedrock-2、AWS-Claude-2、AWS-Claude-3、Anthropic-Claude-1、Claude-Code-1、Claude-Code-2、Kiro-Claude-1、Vertex-Claude-1

claude-opus-4-6对话,识图,工具
分组(10)

AWS-Bedrock-1、AWS-Bedrock-2、AWS-Claude-1、AWS-Claude-2、AWS-Claude-3、Anthropic-Claude-1、Claude-Code-1、Claude-Code-2、Kiro-Claude-1、Vertex-Claude-1

claude-opus-4-7对话,识图,工具
分组(8)

AWS-Bedrock-2、AWS-Claude-2、AWS-Claude-3、Anthropic-Claude-1、Claude-Code-1、Claude-Code-2、Kiro-Claude-1、Vertex-Claude-1

共列入 15 个候选型号。查看完整模型、版本与接口目录。