跳转至

MaaS_Cl_Opus_4.8/5

Claude-opus-4.8

基础信息

  • 基础URL:https://genaiapi.cloudsway.net

  • API请求端点POST

  • 身份验证:通过HTTP Bearer Token方式验证,需要在请求头中携带API密钥。

参数名 类型 必填 描述
Content-Type string 固定为 application/json
Authorization string Bearer {your_api_key}

核心参数说明

参数 类型 必选 描述
model string 要使用的模型ID
messages array 对话消息列表,包含roleuserassistant)和content
max_tokens integer 生成的最大token数
system string 系统提示词,用于设定助手的行为和背景
temperature number 采样温度,较高的值使输出更随机,较低的值使输出更确定,只支持固定值1
top_p number 核采样参数,模型考虑具有top_p概率质量的token的结果,只支持传固定值0.99
top_k integer 仅从每个步骤中概率最高的K个token中采样,opus 4.8不支持
stream boolean 是否启用流式传输,默认为false
stop_sequences array 自定义停止序列,当模型生成这些序列时停止

请求与响应示例

端点调用/v1/messages

curl --location --request POST 'https://genaiapi.cloudsway.net/{ENDPOINT}/v1/messages' \
--header 'Authorization: Bearer {Your AK}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "max_tokens": 2048,
    "stream": false,
    "messages": [
        {
            "role": "user",
            "content": "证明勾股定律"
        }
    ],
    "thinking": {
        "type": "adaptive"
    }
}'

Openai端点调用/chat/completions

curl --location --request POST 'https://genaiapi.cloudsway.net/v1/ai/{ENDPOINT}/chat/completions' \
--header 'Authorization: Bearer {Your AK}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "max_tokens": 2048,
    "stream": false,
    "messages": [
        {
            "role": "user",
            "content": "证明勾股定律"
        }
    ],
    "thinking": {
        "type": "adaptive"
    }
}'

统一域名调用 chat/completions

curl --location --request POST 'https://genaiapi.cloudsway.net/v1/chat/completions' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "MaaS_Cl_Opus_4.8_20260528",
    "stream": false,
    "messages": [
        {
            "role": "user",
            "content": "你是谁"
        }
    ],
    "thinking": {
        "type": "adaptive"
    }
}'

功能介绍

thinking

opus4.8不支持扩展思维预算,传入以下参数会报400

thinking: {"type": "enabled", "budget_tokens": N}

opus4.8只支持Adaptive这一种方式

thinking: {"type": "adaptive"}

最小缓存token

Claude Opus 4.8上的最小可缓存提示长度为1024token,无需更改代码。

Claude-opus-5 功能介绍

对话中途工具变更(测试版)

请求头必须携带:mid-conversation-tool-changes-2026-07-01 会话多轮之间动态增删工具,同时保留提示缓存。

{
    "model": "claude-opus-5",
    "max_tokens": 1024,
    "cache_control": {"type": "ephemeral"},
    "system": "You are a code review assistant. Be concise.",
    "messages": [
      {
        "role": "user",
        "content": "Review process() in utils.py for performance issues."
      },
      {
        "role": "assistant",
        "content": "The list comprehension is fine for small inputs. For large inputs, consider a generator to avoid materializing the full list."
      },
      {
        "role": "user",
        "content": "Now review the calling code that invokes process()."
      },
      {
        "role": "system",
        "content": "From now on, every suggestion must include explicit type annotations."
      }
    ]
  }'

默认开启思考

传入thinking: {"type": "adaptive"}等同于不传,都会在回复content里面有thinking。

提示缓存门槛下调

最小缓存 token:512(Opus4.8 为 1024),短提示可直接缓存,无需改动业务代码。

禁用思考需要 effort 为 high 或更低

(默认是high,不传effort也是high)在 Claude Opus 5 上,只有当 effort 级别为 high 或更低时,才接受 thinking: {"type": "disabled"}。在 effort 为 xhighmax 时设置 thinking: {"type": "disabled"} 会返回 400 错误。这是从 Claude Opus 5 开始正式可用的行为,在每个请求上强制执行