全部文档
当前文档

暂无内容

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

文档中心

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

最近更新时间:2026-04-16 10:20:11

Anthropic生态的工具(如Claude Code)或SDK进行调用。

支持Anthropic协议的模型

金山云星流平台支持通过Anthropic协议调用的模型,具体分类如下:

模型类型

模型名称

DeepSeek系列

deepseek-v3.2、deepseek-v3.2-speciale、deepseek-v3.1、deepseek-v3-0324、deepseek-r1-0528

Qwen系列

qwen3-coder-480b-a35b-instruct、qwen3-235b-a22b-instruct-2507、qwen3-235b-a22b-thinking-2507

Kimi系列

kimi-k2-thinking-turbo、kimi-k2-thinking、kimi-k2-turbo-enterprise、kimi-k2-turbo-preview、kimi-k2-0905-preview、kimi-k2.5

GLM系列

glm-4.6、glm-4.7

MIMO系列

mimo-v2-flash

前提条件

确保已获取金山云星流平台的有效API密钥KSC_API_KEY)。

操作步骤

接入Claude Code工具

  1. 执行如下命令,安装Claude Code工具,具体操作可参考在Node.js环境中接入Claude Code工具相关内容。如遇问题,可参考Claude Code官方文档

    npm install -g @anthropic-ai/claude-code
  2. 在终端中执行以下命令,配置必要的环境变量。

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

     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
  3. 执行cd my-project命令,进入相应项目目录。

  4. 执行命令:claude,即可开始使用Claude Code工具。

通过Anthropic SDK调用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

    • Python代码示例:

      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')]
    • 输出示例:

      [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

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

纯净模式

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