Win11 环境下 VS Code 结合 Continue 插件配置阿里云 DashScope (qwen3.7-max) 笔记

一、 API 接口验证 (PowerShell 环境)

在 Windows 11 PowerShell 中,直接运行带 JSON Body 的 curl.exe 时,PowerShell 会预处理引号与反斜杠,导致 JSON 格式损坏(报错 Required body invalidbad range specification)。

正确的测试命令

使用 --%(停止解析符号)阻止 PowerShell 的二次转义,确保字符串原样传递给 curl.exe

curl.exe --% https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions -H "Authorization: Bearer sk-39950862d614412dbc04b231cdcb7d0A" -H "Content-Type: application/json" -d "{\"model\": \"qwen3.7-max\", \"messages\": [{\"role\": \"user\", \"content\": \"你好\"}]}"

验证成功的返回结果结构

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "你好!有什么我可以帮你的吗?",
        "reasoning_content": "...",
        "role": "assistant"
      }
    }
  ],
  "created": 1786360366,
  "id": "chatcmpl-c3d05dec-e0ca-9b12-a44d-a071e544bcfe",
  "model": "qwen3.7-max",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 180,
    "completion_tokens_details": {
      "reasoning_tokens": 167
    },
    "prompt_tokens": 11,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "total_tokens": 191
  }
}

二、 VS Code Continue 扩展配置文件

1. 关键参数对比

参数字段错误/不推荐写法正确写法说明
API Base URLapiBaseUrlapiBaseContinue 规范中使用 apiBase 指定兼容 Open AI 的接口根地址
非标准字段useResponsesApi移除schema: v1 规范无此字段,保留可能引发解析异常

2. Continue 配置文件 (config.yaml)

name: Main Config
version: 1.0.0
schema: v1
models:
  - name: qwen3.7-max
    provider: openai
    model: qwen3.7-max
    apiKey: sk-39950862d614412dbc04b231cdcb7d0A
    apiBase: https://dashscope.aliyuncs.com/compatible-mode/v1
    roles:
      - chat
      - edit

三、 排错与注意事项

  1. PowerShell 命令行调用转义问题
  2. 若不加 --%,PowerShell 会将 \" 替换并破坏 JSON 数据包。
  3. 也可选择切换至原生 CMD 运行,或在 PowerShell 中使用 Invoke-RestMethod 命令。
  4. 模型与接口兼容性
  5. 阿里云 DashScope OpenAI 兼容接口地址必须包含路径 /compatible-mode/v1
  6. provider 设置为 openai 即可无缝对接 DashScope 的 OpenAI 兼容模式。

标签: none

添加新评论