Anthropic 提供了一个兼容性层,使您能够使用 OpenAI SDK 来测试 Anthropic API。通过少量代码更改,您可以快速评估 Anthropic 模型的能力。
strict
参数被忽略,这意味着工具使用 JSON 不保证遵循提供的模式。\n
)分隔。然后将这个完整字符串作为单个系统消息提供在消息的开头。
thinking
参数来启用扩展思考功能。虽然这将改善 Claude 对复杂任务的推理,但 OpenAI SDK 不会返回 Claude 的详细思考过程。要获得完整的扩展思考功能,包括访问 Claude 的逐步推理输出,请使用原生 Anthropic API。
/v1/messages
端点的标准限制。
字段 | 支持状态 |
---|---|
model | 使用 Claude 模型名称 |
max_tokens | 完全支持 |
max_completion_tokens | 完全支持 |
stream | 完全支持 |
stream_options | 完全支持 |
top_p | 完全支持 |
parallel_tool_calls | 完全支持 |
stop | 所有非空白停止序列都有效 |
temperature | 在 0 和 1 之间(包含)。大于 1 的值被限制为 1。 |
n | 必须恰好为 1 |
logprobs | 忽略 |
metadata | 忽略 |
response_format | 忽略 |
prediction | 忽略 |
presence_penalty | 忽略 |
frequency_penalty | 忽略 |
seed | 忽略 |
service_tier | 忽略 |
audio | 忽略 |
logit_bias | 忽略 |
store | 忽略 |
user | 忽略 |
modalities | 忽略 |
top_logprobs | 忽略 |
reasoning_effort | 忽略 |
tools
/ functions
字段显示字段
tools[n].function
字段字段 | 支持状态 |
---|---|
name | 完全支持 |
description | 完全支持 |
parameters | 完全支持 |
strict | 忽略 |
messages
数组字段显示字段
messages[n].role == "developer"
的字段字段 | 支持状态 |
---|---|
content | 完全支持,但被提升 |
name | 忽略 |
字段 | 支持状态 |
---|---|
id | 完全支持 |
choices[] | 长度始终为 1 |
choices[].finish_reason | 完全支持 |
choices[].index | 完全支持 |
choices[].message.role | 完全支持 |
choices[].message.content | 完全支持 |
choices[].message.tool_calls | 完全支持 |
object | 完全支持 |
created | 完全支持 |
model | 完全支持 |
finish_reason | 完全支持 |
content | 完全支持 |
usage.completion_tokens | 完全支持 |
usage.prompt_tokens | 完全支持 |
usage.total_tokens | 完全支持 |
usage.completion_tokens_details | 始终为空 |
usage.prompt_tokens_details | 始终为空 |
choices[].message.refusal | 始终为空 |
choices[].message.audio | 始终为空 |
logprobs | 始终为空 |
service_tier | 始终为空 |
system_fingerprint | 始终为空 |
头部 | 支持状态 |
---|---|
x-ratelimit-limit-requests | 完全支持 |
x-ratelimit-limit-tokens | 完全支持 |
x-ratelimit-remaining-requests | 完全支持 |
x-ratelimit-remaining-tokens | 完全支持 |
x-ratelimit-reset-requests | 完全支持 |
x-ratelimit-reset-tokens | 完全支持 |
retry-after | 完全支持 |
request-id | 完全支持 |
openai-version | 始终为 2020-10-01 |
authorization | 完全支持 |
openai-processing-ms | 始终为空 |