全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

将金山云星流平台大模型能力接入Anthropic API生态

最近更新时间:2025-10-11 14:12:47

将API Token服务接入 Claude Code

1. 安装Claude Code工具

如您遇到问题,可参考Claude Code官方文档

npm install -g @anthropic-ai/claude-code

2. 配置环境变量

export ANTHROPIC_AUTH_TOKEN=${KSC_API_KEY}
export ANTHROPIC_MODEL=deepseek-v3.1
export ANTHROPIC_BASE_URL=https://kspmas.ksyun.com
export BASH_DEFAULT_TIMEOUT_MS=86400000   # 默认 60 s → 24 h
export BASH_MAX_TIMEOUT_MS=86400000  

注:设置BASH_DEFAULT_TIMEOUT_MSBASH_MAX_TIMEOUT_MS是为了防止输出过长,触发 Claude Code 客户端超时,这里设置的超时时间为 24小时。

3. 进入项目目录,执行 claude 命令,即可开始使用了。

cd my-project
claude

通过Anthropic API调用模型

1. 安装 Anthropic SDK

pip install anthropic

2. 配置环境变量

export ANTHROPIC_BASE_URL=https://kspmas.ksyun.com
export ANTHROPIC_API_KEY=${KSC_API_KEY}

3. 调用 API

import anthropic

client = anthropic.Anthropic()

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

# 输出example: [TextBlock(citations=None, text="Hey! I'm doing great, thanks for asking! ? How about you? What's on your mind today?", type='text')]

Anthropic API 兼容性细节

HTTP Header

Field

Support Status

anthropic-beta

Ignored

anthropic-version

Ignored

x-api-key

Supported

Simple Fields

Field

Support Status

model

deepseek-v3.1

kimi-k2-0905-preview

kimi-k2-turbo-preview

max_tokens

Fully Supported

container

Ignored

mcp_servers

Ignored

metadata

Ignored

service_tier

Ignored

stop_sequences

Fully Supported

stream

Fully Supported

system

Fully Supported

temperature

Fully Supported (range [0.0 ~ 2.0])

thinking

Ignored

top_k

Ignored

top_p

Fully Supported

Tool Fields

tools

Field

Support Status

name

Fully Supported

input_schema

Fully Supported

description

Fully Supported

cache_control

Ignored

tool_choice

Value

Support Status

none

Fully Supported

auto

Supported (disable_parallel_tool_use is ignored)

any

Supported (disable_parallel_tool_use is ignored)

tool

Supported (disable_parallel_tool_use is ignored)

Message Fields

Field

Variant

Sub-Field

Support Status

content

string

Fully Supported

array, type="text"

text

Fully Supported

cache_control

Ignored

citations

Ignored

array, type="image"

Not Supported

array, type = "document"

Not Supported

array, type = "search_result"

Not Supported

array, type = "thinking"

Ignored

array, type="redacted_thinking"

Not Supported

array, type = "tool_use"

id

Fully Supported

input

Fully Supported

name

Fully Supported

cache_control

Ignored

array, type = "tool_result"

tool_use_id

Fully Supported

content

Fully Supported

cache_control

Ignored

is_error

Ignored

array, type = "server_tool_use"

Not Supported

array, type = "web_search_tool_result"

Not 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

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈