Contents
Qwen Code takes any OpenAI-compatible API through its modelProviders setting: add our three models under the openai key in ~/.qwen/settings.json, with baseUrl set to https://api.solcardinference.ai/v1 and envKey naming the variable that holds your key. Qwen Code’s README calls it “the open-source AI coding agent for your terminal, editor, desktop, browser, and chat.” Its /auth menu lists Qwen and Alibaba sign-ins and a few built-in providers, so ours goes in as a custom provider. The part that trips people up is where the key is read from, and this guide spends most of its time there.
What you need
- A SolCard Inference API key. Make one on the dashboard’s API keys page. Keys start with
sk-si-and are shown once. - Some balance or a plan. One prepaid USD balance pays for every key and model; see how billing works.
- Qwen Code. The README installs it with
npm install -g @qwen-code/qwen-code@latestand asks for Node.js 22 or later.
The settings.json block
Per Qwen Code’s model providers page, ~/.qwen/settings.json applies to every project and .qwen/settings.json in a repository applies to that one. Add this to the user file:
{
"modelProviders": {
"openai": [
{
"id": "solcard-inference-fast",
"name": "SolCard Inference Fast",
"baseUrl": "https://api.solcardinference.ai/v1",
"envKey": "SOLCARD_INFERENCE_API_KEY",
"generationConfig": { "contextWindowSize": 1048576 }
},
{
"id": "solcard-inference-large",
"name": "SolCard Inference Large",
"baseUrl": "https://api.solcardinference.ai/v1",
"envKey": "SOLCARD_INFERENCE_API_KEY",
"generationConfig": { "contextWindowSize": 1000000 }
},
{
"id": "solcard-inference-base",
"name": "SolCard Inference Base",
"baseUrl": "https://api.solcardinference.ai/v1",
"envKey": "SOLCARD_INFERENCE_API_KEY",
"generationConfig": { "contextWindowSize": 262144 }
}
]
},
"security": { "auth": { "selectedType": "openai" } },
"model": { "name": "solcard-inference-fast" }
}
If modelProviders.openai already lists other models, add these three to the same array. Here openai names the request format, not the company the request goes to.
| Field | What it does, per Qwen Code’s docs |
|---|---|
id | Sent to the API as the model. Must match ours exactly. |
name | The label in the /model picker. |
baseUrl | The docs say to set it to the API’s /v1 root. Ours is https://api.solcardinference.ai/v1; don’t add /chat/completions. |
envKey | The docs say it holds “the name of an environment variable, not the actual API key value.” |
contextWindowSize | The docs say to set it “to the server’s maximum model length”. Ours come from our models page. |
selectedType | Picks the openai protocol at startup. |
model.name | The default model. It has to match one of the id values. |
Put contextWindowSize in each entry, not at the top level. The docs say “the modelProvider layer is impermeable”: a provider model doesn’t inherit generation settings from elsewhere in the file, and top-level model.generationConfig is ignored for it.
Leave out wireApi. The docs say an openai entry without it uses Chat Completions, which is what this block expects.
Where the key goes
Put the key in ~/.qwen/.env, then check that nothing earlier in Qwen Code’s search order shadows it.
echo 'SOLCARD_INFERENCE_API_KEY=sk-si-...' >> ~/.qwen/.env
The docs say “Credentials are never persisted in settings; the runtime reads them from process.env[envKey].” Where that variable comes from follows the order on the authentication page:
| Priority | Source |
|---|---|
| 1 | CLI flags such as --openai-api-key |
| 2 | Your shell’s environment (export) |
| 3 | A .env file |
| 4 | The env block in settings.json |
Two rules on that page catch people out:
- Only one
.envfile loads. Qwen Code “auto-loads the first.envfile it finds,” and variables are “not merged across multiple files.” It looks for.qwen/.env, then.env, walking up from the current directory, before it falls back to~/.qwen/.envand~/.env. A project with its own.envfile means~/.qwen/.envnever loads, so your key goes missing in that repo. - A shell export always beats a file. A stale
SOLCARD_INFERENCE_API_KEYin your shell overrides the one you just saved.
The env block in settings.json also works, but the auth page notes keys there sit in plain text. Keep the key out of any .env you commit.
Check it works
Start qwen; with selectedType set, the auth page says there’s no /auth step. Then:
- Run
/model. Our three models should show in the list. The docs say/modelpersistsmodel.name, so your pick carries into the next session. - Run
/doctorto see which authentication Qwen Code is using.
For a one-shot check from the shell, the headless page documents --prompt (-p), and the auth page documents --model:
qwen --model solcard-inference-fast -p "Say hello in five words."
If nothing comes back, test the key and URL without Qwen Code:
curl https://api.solcardinference.ai/v1/models \
-H "Authorization: Bearer $SOLCARD_INFERENCE_API_KEY"
Scripts and CI
Headless mode is where an API key beats a browser sign-in. Qwen Code’s headless page says it lets you “run Qwen Code programmatically from command line scripts and automation tools”, and it accepts piped input:
cat src/auth.py | qwen --model solcard-inference-fast \
-p "Review this authentication code for security issues" \
--output-format json > review.json
The JSON output’s last entry carries stats with token counts, though the page says those totals don’t guarantee complete accounting. What you’re charged follows how billing works.
Be careful with --yolo. The page says headless runs with it “auto-approve every tool call”, and that --yolo doesn’t turn on a sandbox.
Switching models and cost
Start on Fast and switch in /model when a change needs planning. For a single terminal, qwen --model solcard-inference-large overrides the default without touching the file. Large costs three times as much as Fast on input and always reasons, so expect more output tokens per turn. Fast, Large or Base compares the three.
An agent resends the conversation on each request. If one request resends 80,000 tokens, 75,000 of them cached, and writes 1,500, it’s about $0.019 on Fast and about $0.056 on Large plus its reasoning.
Our models stop at 32,768 output tokens per request. If you add samplingParams.max_tokens, keep it at or below that. The model providers page warns that setting samplingParams on an OpenAI-compatible provider can drop a configured reasoning field, which is one more reason this block leaves reasoning out.
Troubleshooting
- Qwen Code still asks you to sign in: the auth page says provider-specific keys “do not select the auth type by themselves”. Check
security.auth.selectedTypeisopenai. - Models missing from
/model: checkmodel.namematches anidand the JSON parses. - 401
invalid_api_key: the variable is empty, stale or shadowed. Walk through the.envorder above. - 400
model_not_found: anidis wrong. Usesolcard-inference-fast,-largeor-base. - 400
unsupported_content: an image reached the model. Ours take text only, so don’t addmodalities.imageor avisioncapability.
The codes are from our errors page; Qwen Code may word them differently.
FAQ
Can I keep my Qwen account sign-in too?
Yes. The /auth menu still offers it, and the docs say /model and /auth persist security.auth.selectedType, so whichever you pick last is what the next session starts with.
Can I use the Responses API instead?
Qwen Code’s docs offer "wireApi": "responses" on openai entries, and our API speaks OpenAI Responses. This guide keeps the default, Chat Completions, which needs no extra field.
Does a per-repo settings file work?
Yes. Put the same block in .qwen/settings.json at the repository root to use our models only there.
Are my prompts stored? Not on our side. Prompts and responses are never logged or stored; keeps nothing follows one request through.