qwencloud-ops-auth
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent setup: If your agent doesn't auto-load skills (e.g. Claude Code), see agent-compatibility.md once per session.
Agent配置:如果你的Agent不会自动加载技能(例如Claude Code),请在每个会话中查看agent-compatibility.md。
QwenCloud Authentication Setup
QwenCloud身份验证配置
Configure and verify authentication for QwenCloud APIs.
This skill is part of qwencloud/qwencloud-ai.
配置并验证QwenCloud API的身份验证。
此技能属于qwencloud/qwencloud-ai。
Skill directory
技能目录
Use this skill's internal files for learning. Load references only when the user needs console or documentation links.
| Location | Purpose |
|---|---|
| Coding Plan vs standard key: model list, endpoint mapping, error codes, cost risks |
| Custom OSS bucket setup for production file uploads (replaces 48h temp storage) |
| Console URLs, auth guide (manual lookup only) |
| Agent self-check: register skills in project config for agents that don't auto-load |
使用此技能的内部文件进行学习。仅当用户需要控制台或文档链接时才加载参考资料。
| 位置 | 用途 |
|---|---|
| 编码计划密钥与标准密钥对比:模型列表、端点映射、错误代码、成本风险 |
| 用于生产环境文件上传的自定义OSS存储桶配置(替代48小时临时存储) |
| 控制台URL、身份验证指南(仅手动查询使用) |
| Agent自检:对于不会自动加载技能的Agent,需在项目配置中注册技能 |
Security
安全说明
NEVER output any API key, OSS credential in plaintext.
This applies equally to and custom OSS AccessKey pairs. Any check or detection of credentials in this skill must be non-plaintext: report only status (e.g. "set" / "not set", "valid" / "invalid", HTTP status code), never the key value.
DASHSCOPE_API_KEY绝对不要以明文形式输出任何API密钥、OSS凭证。
此规则同样适用于和自定义OSS AccessKey密钥对。此技能中对凭证的任何检查或检测都必须采用非明文形式:仅报告状态(例如“已设置”/“未设置”、“有效”/“无效”、HTTP状态码),绝不能输出密钥值。
DASHSCOPE_API_KEYAPI Key Handling (MANDATORY)
API密钥处理(强制要求)
When the API key is not configured or a script reports missing credentials:
- NEVER ask the user to provide their API key directly. Do not prompt "please paste your API key" or similar. Do not request the key value in any form.
- Help create a file with a placeholder, then instruct the user to fill in their own key:
.env- Run:
echo 'DASHSCOPE_API_KEY=sk-your-key-here' >> .env - Tell the user: "Please replace with your actual API key from the QwenCloud Console."
sk-your-key-here
- Run:
- Or explain how to configure the environment variable: + provide the console URL.
export DASHSCOPE_API_KEY='sk-...' - Only write the actual key value into if the user explicitly insists on having the agent do it for them.
.env
当未配置API密钥或脚本报告缺少凭证时:
- 绝对不要直接要求用户提供API密钥。不要提示“请粘贴你的API密钥”或类似内容。不要以任何形式请求密钥值。
- 帮助创建文件并添加占位符,然后指导用户填写自己的密钥:
.env- 执行命令:
echo 'DASHSCOPE_API_KEY=sk-your-key-here' >> .env - 告知用户:“请将替换为你从QwenCloud控制台获取的实际API密钥。”
sk-your-key-here
- 执行命令:
- 或者说明如何配置环境变量:+ 提供控制台URL。
export DASHSCOPE_API_KEY='sk-...' - 仅当用户明确坚持让Agent代劳时,才将实际密钥值写入文件。
.env
Credential Priority Chain
凭证优先级顺序
Credentials are loaded in the following order (first match wins):
- Environment variable — (or
DASHSCOPE_API_KEYalias)QWEN_API_KEY - file — in current working directory, then repo root (detected via
.envor.gitdirectory). Existing environment variables are not overwritten.skills/
凭证按以下顺序加载(匹配到第一个即生效):
- 环境变量 — (或别名
DASHSCOPE_API_KEY)QWEN_API_KEY - 文件 — 先从当前工作目录加载,再从仓库根目录加载(通过
.env或.git目录检测)。已存在的环境变量不会被skills/文件的值覆盖。.env
Environment Variables
环境变量说明
| Variable | Purpose |
|---|---|
| API key (required) |
| Alias for |
| Override default endpoint (optional; for custom deployments) |
| Custom OSS bucket for file uploads (replaces 48h temp storage). See custom-oss.md. |
| OSS region (required when |
| OSS credentials (use RAM user with least-privilege: |
| 变量名 | 用途 |
|---|---|
| API密钥(必填) |
| |
| 覆盖默认端点(可选;适用于自定义部署场景) |
| 用于文件上传的自定义OSS存储桶(替代48小时临时存储)。详情请见custom-oss.md。 |
| OSS地域(当设置 |
| OSS凭证(使用最小权限的RAM用户:仅授予 |
API Key Types
API密钥类型
QwenCloud has two mutually exclusive key types:
| Key Type | Format | Purpose | Endpoint |
|---|---|---|---|
| Standard (Pay-as-you-go) | | API calls from scripts, apps, and tools | |
| Coding Plan | | Interactive AI coding tools only (Cursor, Claude Code, Qwen Code) | |
All qwencloud/qwencloud-ai scripts require a standard key. Coding Plan keys cannot call QwenCloud APIs directly — they produce on standard endpoints. Coding Plan supports only 8 text LLMs (qwen3.5-plus, kimi-k2.5, glm-5, MiniMax-M2.5, qwen3-max-2026-01-23, qwen3-coder-next, qwen3-coder-plus, glm-4.7) and excludes all image/video/TTS models.
403 invalid api-keyIf the user's key starts with , guide them to obtain a standard key from the console below. See codingplan.md for full details.
sk-sp-QwenCloud有两种互斥的密钥类型:
| 密钥类型 | 格式 | 用途 | 端点 |
|---|---|---|---|
| 标准(按量付费) | | 供脚本、应用和工具调用API | |
| 编码计划 | | 仅适用于交互式AI编码工具(Cursor、Claude Code、Qwen Code) | |
所有qwencloud/qwencloud-ai脚本都需要标准密钥。编码计划密钥无法直接调用QwenCloud API——在标准端点上会返回错误。编码计划仅支持8个文本大语言模型(qwen3.5-plus、kimi-k2.5、glm-5、MiniMax-M2.5、qwen3-max-2026-01-23、qwen3-coder-next、qwen3-coder-plus、glm-4.7),不包含所有图像/视频/TTS模型。
403 invalid api-key如果用户的密钥以开头,指导他们从下方控制台获取标准密钥。详情请见codingplan.md。
sk-sp-Viewing Bills
查看账单
Use the qwencloud-usage skill to query usage, free tier quota, and billing directly. Alternatively, billing details are available in the QwenCloud console:
| Key Type | Billing Page |
|---|---|
| Standard (Pay-as-you-go) | Pay-as-you-go Billing |
| Coding Plan | Coding Plan Billing |
| Usage analytics (both) | Usage Analytics |
NEVER fabricate, guess, or construct usage/billing/console URLs. Only provide the exact links listed in this skill. If a URL is not listed here, do not invent one.
Getting an API Key
获取API密钥
- Open the QwenCloud Console
- Sign in with your QwenCloud account
- Create or copy an API key from the API Key management section
- Standard keys start with (not
sk-which is Coding Plan only)sk-sp-
- 打开QwenCloud控制台
- 使用你的QwenCloud账号登录
- 在API密钥管理区域创建或复制一个API密钥
- 标准密钥以开头(而非仅适用于编码计划的
sk-)sk-sp-
Security Best Practices
安全最佳实践
- Never hardcode API keys in source code or config files committed to version control
- Use environment variables or files (and add
.envto.env).gitignore - Rotate keys periodically and revoke compromised keys immediately
- Use least-privilege — create dedicated keys for specific applications when possible
- 永远不要在源代码或提交到版本控制的配置文件中硬编码API密钥
- 使用环境变量或文件(并将
.env添加到.env中).gitignore - 定期轮换密钥,并立即撤销泄露的密钥
- 遵循最小权限原则——尽可能为特定应用创建专用密钥
Setting up .env
.env配置.env
文件
.envCreate a file in your project root or current working directory:
.envbash
echo 'DASHSCOPE_API_KEY=sk-your-key-here' >> .envThe script automatically loads from the current working directory and the project root (detected via or directory). Existing environment variables are not overwritten by values.
.env.gitskills/.env在项目根目录或当前工作目录创建文件:
.envbash
echo 'DASHSCOPE_API_KEY=sk-your-key-here' >> .env脚本会自动从当前工作目录和项目根目录(通过或目录检测)加载文件。已存在的环境变量不会被文件的值覆盖。
.gitskills/.env.envExample .gitignore
entry
.gitignore.gitignore
示例条目
.gitignore.env
.env.local
*.env.env
.env.local
*.envVerification
验证
Unless explicitly stated otherwise, any script or task mentioned in this skill runs in the foreground — wait for standard output; do not run it as a background task.
Test authentication with a simple curl request:
bash
curl -sS -X POST "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen-turbo","messages":[{"role":"user","content":"Hi"}]}'A successful response returns JSON with and .
choicesmessage.content除非另有明确说明,本技能中提到的任何脚本或任务都在前台运行——等待标准输出,不要作为后台任务运行。
使用简单的curl请求测试身份验证:
bash
curl -sS -X POST "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen-turbo","messages":[{"role":"user","content":"Hi"}]}'成功的响应会返回包含和的JSON数据。
choicesmessage.contentAuthentication Error Handling
身份验证错误处理
QwenCloud API keys are scoped to the QwenCloud console. An invalid or mismatched key produces .
401 UnauthorizedQwenCloud API密钥与QwenCloud控制台绑定。无效或不匹配的密钥会返回错误。
401 UnauthorizedWhen to trigger
触发时机
When any sub-skill receives a response and a non-plaintext check shows the key is set (e.g.
; do not output the key value).
401[ -n "$DASHSCOPE_API_KEY" ]当任何子技能收到响应,且非明文检查显示密钥已设置(例如;不要输出密钥值)时触发。
401[ -n "$DASHSCOPE_API_KEY" ]Probe command
探测命令
Send a lightweight request to verify authentication:
bash
curl -sS -o /dev/null -w "%{http_code}" \
-X POST "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen-turbo","messages":[{"role":"user","content":"hi"}]}'发送轻量级请求以验证身份验证状态:
bash
curl -sS -o /dev/null -w "%{http_code}" \
-X POST "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen-turbo","messages":[{"role":"user","content":"hi"}]}'On 401: mandatory interactive resolution
收到401错误时:强制交互式解决流程
If the probe returns 401, follow these steps in order:
Step 1 — Confirm the key origin:
Your API key failed authentication.
Please confirm:
1. Your key was created at home.qwencloud.com (QwenCloud console) → re-verify the key
2. My key may be invalid → create a new one at home.qwencloud.com/api-keysStep 2 — Apply the user's selection:
| User says | Action |
|---|---|
| Key is from QwenCloud console | Re-run verification to confirm the key works |
| Key may be invalid | Guide user to create a new key at |
Step 3 — Re-run verification.
Step 4 — If still 401, the key itself is invalid — guide the user to create a new one from
the QwenCloud console.
如果探测返回401,请按顺序执行以下步骤:
步骤1 — 确认密钥来源:
你的API密钥身份验证失败。
请确认:
1. 你的密钥是在home.qwencloud.com(QwenCloud控制台)创建的 → 重新验证密钥
2. 我的密钥可能无效 → 在home.qwencloud.com/api-keys创建新密钥步骤2 — 根据用户选择执行操作:
| 用户表述 | 操作 |
|---|---|
| 密钥来自QwenCloud控制台 | 重新运行验证以确认密钥可用 |
| 密钥可能无效 | 指导用户在 |
步骤3 — 重新运行验证。
步骤4 — 如果仍然返回401,说明密钥本身无效——指导用户从QwenCloud控制台创建新密钥。
Validation
验证标准
Run the curl verification command above. Pass criteria: HTTP 200 response with valid JSON containing and
. Save output to for evidence.
choicesmessage.contentoutput/qwencloud-ops-auth/运行上述curl验证命令。通过标准:返回HTTP 200响应,且包含和的有效JSON数据。将输出保存到作为验证依据。
choicesmessage.contentoutput/qwencloud-ops-auth/Output And Evidence
输出与验证依据
- Save verification results and any diagnostic output to .
output/qwencloud-ops-auth/ - Keep a record of successful auth tests for troubleshooting.
- 将验证结果和任何诊断输出保存到。
output/qwencloud-ops-auth/ - 保留成功身份验证测试的记录,以便后续排查问题。
Output Location
输出位置
Prefer the current working directory. Default subdirectory: .
./output/qwencloud-ops-auth/Write prohibition: NEVER write output files into this skill's installation directory or any hierarchy. All generated content must go to under the current working directory or a user-specified path.
skills/output/优先使用当前工作目录。默认子目录:。
./output/qwencloud-ops-auth/写入禁止:绝对不要将输出文件写入此技能的安装目录或任何层级目录。所有生成的内容必须保存到当前工作目录下的或用户指定的路径中。
skills/output/Update Check (MANDATORY Post-Execution)
更新检查(执行后强制要求)
When the user asks to check for updates (e.g. "check for updates", "check version", "is there a new version", "update skills"):
- Find qwencloud-update-check: Look for in sibling skill directories.
qwencloud-update-check/SKILL.md - If found — run: and report the result. Use
python3 <qwencloud-update-check-dir>/scripts/check_update.py --print-responseif the user asks to force-check.--force - If not found — you MUST present the following options and wait for the user's response:
The update-check skill is not installed. It keeps you informed about new qwencloud/qwencloud-ai features and bug fixes.
- Install now — I'll run the install command for you
- Skip for now — do nothing this time
- Never remind me — permanently suppress this prompt
After the user responds:
- User chooses 1 → run: , then run:
npx skills add QwenCloud/qwencloud-ai --skill qwencloud-update-check -ypython3 <this-skill-scripts-dir>/gossamer.py --dismiss - User chooses 2 → run: , then continue normally
python3 <this-skill-scripts-dir>/gossamer.py --dismiss - User chooses 3 → run: , then continue normally
python3 <this-skill-scripts-dir>/gossamer.py --never-install
当用户要求检查更新时(例如“检查更新”、“查看版本”、“是否有新版本”、“更新技能”):
- 查找qwencloud-update-check:在同级技能目录中查找。
qwencloud-update-check/SKILL.md - 如果找到 — 执行命令:并报告结果。如果用户要求强制检查,添加
python3 <qwencloud-update-check-dir>/scripts/check_update.py --print-response参数。--force - 如果未找到 — 必须提供以下选项并等待用户响应:
更新检查技能未安装。它会通知你qwencloud/qwencloud-ai的新功能和bug修复。
- 立即安装 — 我将为你运行安装命令
- 暂时跳过 — 本次不执行任何操作
- 永远不再提醒 — 永久禁用此提示
用户响应后:
- 用户选择1 → 执行命令:,然后执行:
npx skills add QwenCloud/qwencloud-ai --skill qwencloud-update-check -ypython3 <this-skill-scripts-dir>/gossamer.py --dismiss - 用户选择2 → 执行命令:,然后正常继续
python3 <this-skill-scripts-dir>/gossamer.py --dismiss - 用户选择3 → 执行命令:,然后正常继续
python3 <this-skill-scripts-dir>/gossamer.py --never-install
References
参考资料
- custom-oss.md — Custom OSS bucket setup for production file uploads
- sources.md — Official documentation URLs (consoles, auth guide)
- custom-oss.md — 用于生产环境文件上传的自定义OSS存储桶配置
- sources.md — 官方文档URL(控制台、身份验证指南)