Model Studio cookbook
You can already send one request. These are problem-shaped. Activation is in the tutorial.
Move existing OpenAI code
Official rule: change the API key, base URL, and model name. Intro
- Read
process.env.DASHSCOPE_API_KEY. - Point
baseURLat that region's OpenAI-compatible host and fill{WorkspaceId}(Beijing / Singapore / Tokyo / Frankfurt). US Virginia follows the model list. - Use an ID from the list.
gpt-4owill not resolve. - Streaming and tools exist only if that model lists them. Compatible ≠ feature-parity.
Copy Node / Python / curl from First API call.
Do not mix the three credential pairs
This is the usual source of invalid_api_key and surprise invoices. Coding Plan, Token Plan
| Billing | Key looks like | Where the base URL comes from |
|---|---|---|
| Pay-as-you-go | sk- or sk-ws | First API call / Models |
| Coding Plan | sk-sp- from the plan page | OpenAI https://coding.dashscope.aliyuncs.com/v1; Anthropic https://coding.dashscope.aliyuncs.com/apps/anthropic |
| Token Plan | Dedicated key (official prefix sk-sp-) | Whatever the Token Plan console shows that day — not the Coding Plan host |
Official failure modes:
- PAYG key + plan host →
invalid_api_key. - PAYG key + PAYG host → no plan credit, PAYG bill.
- You bought Coding Plan and still see arrears: the tool still has
sk-anddashscope.aliyuncs.com.
Coding Plan is coding tools only (official examples: Claude Code, Qoder, Qoder CN, OpenClaw). Using the plan key as your app backend or for batch jobs is a policy violation.
Token Plan requires a real OpenAI or Anthropic protocol. A look-alike UI that does not speak those APIs cannot burn plan credits — use a PAYG sk- / sk-ws key instead.
When filling a client, open the official page for that client. Do not reconstruct screenshots here:
- Index: Clients and developer tools
- Examples: Claude Code, Chatbox
The full Qoder CN / Lingma IDE tutorial is #84. One official fact belongs here: personal Community / Pro can attach Model Studio; Enterprise cannot. Qoder CN
Stop PAYG after the new-user quota
China-site free quota:
- Beijing only. Valid 90 days from the later of activation, model launch, or approval.
- Realtime inference only. Not Batch, fine-tune, deploy, or custom models.
- Each model (including dated snapshots) has its own pool. The page says a model is "usually" 1 million tokens — believe the console row, not the marketing "70 million+" headline.
- Verified accounts: turn on Free quota only. Exhaustion returns
AllocationQuota.FreeTierOnly. - Unverified accounts already have that switch forced on.
- An overdue account cannot call any model, even one that still has free tokens.
The official page advises against Free-quota-only in production (the service just stops). Use spend alerts and key deletion there.
Token Plan / Coding Plan dedicated keys do not consume this free-tier pool.
No-code knowledge-base Q&A
- Open the console and confirm the region.
- Follow Build a Q&A app without code.
- Prefer Agent 2.0 when you have no 1.0 dependency. No in-place upgrade from 1.0.
- Publish before you call the app API or channels.
- Knowledge base billing is separate from model inference and does not use savings plans or resource packs. Intro
Fine-tune and dedicated deploy stay on the official pages: training, deploy.
Install the Model Studio CLI
This is Model Studio's own CLI (multimodal tools for local agents), not the Alibaba Cloud OpenAPI plugin aliyun bailian.
Official install: bailian.aliyun.com/cli/install.md
# Node.js ≥ 22.12.0 — npm only
npm install -g bailian-cli
bl --version
# Browser login (preferred)
bl auth login --console
# Smoke test
bl auth status --output json
bl text chat --message "ping" --non-interactive --output jsonCommands are bl and bailian. Official skills install: npx skills add modelstudioai/cli --all -g.
Headless / SSH: bl auth login --api-key <pasted-key>. Do not write the key into the repo or the chat log.
Region flag: --region cn|us|intl, default cn.