跳到主要内容

Anthropic API

为了满足大家对 Anthropic API 生态的使用需求,我们的 API 新增了对 Anthropic API 格式的支持,其 base_url 为 https://yuansuo.top/anthropic。

通过简单的配置,即可将 SpAk 的能力,接入到 Anthropic API 生态中。


将 SpAk 模型接入 Claude Code​

请参考接入 Agent 工具

通过 Anthropic API 调用 SpAk 模型​

  1. 安装 Anthropic SDK
pip install anthropic
  1. 配置环境变量
export ANTHROPIC_BASE_URL=https://yuansuo.top/anthropic
export ANTHROPIC_API_KEY=${YOUR_API_KEY}
  1. 调用 API
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
model="SpAk-Aster-V1-MOE",
max_tokens=1000,
system="You are a helpful assistant.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hi, how are you?"
}
]
}
]
)
print(message.content)

注意:当您给 SpAk 的 Anthropic API 传入不支持的模型名时,API 后端会自动将其映射到 SpAk-Aster-V1-MOE 模型。


Anthropic 模型映射​

您在使用 Anthropic API 时,我们会对您传入的 claude 模型名进行映射:

  • claude-opus 开头的模型,会映射到 SpAk-Aster-V1-MOE
  • claude-haiku、claude-sonnet 开头的模型,会映射到 SpAk-Aster-V1-MOE

通过这样的映射,您在使用新版 Claude Desktop APP 的 developer 模式时,可以绕过 APP 对模型名的限制,只需改动 base_url 和 api_key,即可在其中接入 SpAk 模型。


Anthropic API 兼容性细节​

HTTP Header​

FieldSupport Status
anthropic-betaIgnored
anthropic-versionIgnored
x-api-keyFully Supported

Simple Fields​

FieldSupport Status
modelUse SpAk Model Instead
max_tokensFully Supported
containerIgnored
mcp_serversIgnored
metadatauser_id is supported, others are ignored Please refer to Rate Limit & Isolation for more information about user_id parameter.
service_tierIgnored
stop_sequencesFully Supported
streamFully Supported
systemFully Supported
temperatureFully Supported (range [0.0 ~ 2.0])
thinkingSupported (budget_tokens is ignored)
output_configOnly effort is supported
top_kIgnored
top_pFully Supported

Tool Fields​

tools​

FieldSupport Status
nameFully Supported
input_schemaFully Supported
descriptionFully Supported
cache_controlIgnored

tool_choice​

ValueSupport Status
noneFully Supported
autoSupported (disable_parallel_tool_use is ignored)
anySupported (disable_parallel_tool_use is ignored)
toolSupported (disable_parallel_tool_use is ignored)

Message Fields​

FieldSub-FieldSupport Status
content (string)Fully Supported
array, type="text"textFully Supported
cache_controlIgnored
citationsIgnored
array, type="image"Not Supported
array, type = "document"Not Supported
array, type = "search_result"Not Supported
array, type = "thinking"Supported
array, type="redacted_thinking"Not Supported
array, type = "tool_use"idFully Supported
inputFully Supported
nameFully Supported
cache_controlIgnored
array, type = "tool_result"tool_use_idFully Supported
contentFully Supported
cache_controlIgnored
is_errorIgnored
array, type = "server_tool_use"Supported
array, type = "web_search_tool_result"Supported
array, type = "code_execution_tool_result"Not Supported
array, type = "mcp_tool_use"Not Supported
array, type = "mcp_tool_result"Not Supported
array, type = "container_upload"Not Supported