Qwen Code API Configuration for Custom Endpoints
Coding agents and IDE tools almost all share one configuration shape: a base URL, a key and a model name. Here is how to set those for Qwen Code, Cursor and LangChain, plus the parameters and limits that matter once an agent starts running.
Updated

Key points
- Qwen Code reads OPENAI_API_KEY, OPENAI_BASE_URL and OPENAI_MODEL, so three exports are enough.
- Use base URL https://api.uncensoredqwen.cc/v1 and model uncensored in every tool.
- Cap agent parallelism at 8 to stay inside the concurrency limit, and retry 429 after 5 seconds.
- Tool calling is supported, so agent loops that need functions work against this endpoint.
The three values every tool wants
Qwen code api configuration comes down to three settings, whichever tool you use. You need a base URL, a key and a model name.
OPENAI_BASE_URL(or the tool's "base URL" field):https://api.uncensoredqwen.cc/v1OPENAI_API_KEY: your key, sent asAuthorization: Bearer <key>OPENAI_MODEL(or the "model" field):uncensored
The endpoint is OpenAI-compatible and implements POST /v1/chat/completions and GET /v1/models. That is what coding agents call. A short note on naming: this service is a hosted open-weight model from an independent provider, not the official API of the vendor behind Qwen or any other model family. Tools named after a model family, such as Qwen Code, simply let you point them at any OpenAI-style server. If you still need a key, the API key page covers sign-up and the one-click trial credit.
Qwen Code from the terminal
Qwen Code is a command-line coding agent that can use an OpenAI-compatible provider through environment variables. In a shell session:
export OPENAI_API_KEY="YOUR_API_KEY"
export OPENAI_BASE_URL="https://api.uncensoredqwen.cc/v1"
export OPENAI_MODEL="uncensored"
cd your-project
qwen
Run it from the project folder and ask for something small first, such as explaining a file. If the reply streams back, the connection works. To avoid typing the exports each time, put the same three lines in a .env file in the project or in your shell profile. The tool's own documentation lists where it looks for settings, and that can change between releases, so check it if the variables seem to be ignored. A common cause is an older value set in another profile file that overrides yours; run env | grep OPENAI to see what the process actually has.
A coding agent works best with a short system instruction that states the language, the test command and the files it may change. A model tuned to skip refusals does not change that advice: clear instructions give better patches than any parameter does. If the agent asks for permission before running shell commands, leave that prompt on until you trust a task.
Cursor and other IDE tools
Cursor and similar editors have a model settings page with an override for the OpenAI base URL. Turn on the OpenAI API key option, paste your key, enable the base URL override and enter https://api.uncensoredqwen.cc/v1. Then add a custom model named uncensored. Menu labels move around between versions, so look for the words "OpenAI API Key" and "Override OpenAI Base URL".
Two practical notes. First, some editor features, such as tab completion, run on the vendor's own models and ignore a custom endpoint, so expect your model to appear only in chat and agent panels. Second, verify the key with curl first. When the editor says "model unavailable", the cause is usually a typo in the model name or a base URL without /v1, and curl tells you in seconds which one.
curl https://api.uncensoredqwen.cc/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"
For the general setup values in one place, the docs quickstart is the reference.
For team setups, give every developer their own key instead of one shared value. Limits apply per key, so one person's batch job then cannot starve everyone else's editor, and you can see which key spends what.
LangChain and the OpenAI SDK in your own agents
If you write the agent yourself, the same three values go into the client constructor. With LangChain in Python:
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://api.uncensoredqwen.cc/v1",
api_key="YOUR_API_KEY",
model="uncensored",
temperature=0.2,
max_retries=2,
)
print(llm.invoke("List three risks of editing a lockfile by hand.").content)
With the plain Node SDK:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uncensoredqwen.cc/v1",
apiKey: process.env.UNCENSORED_KEY,
});
const res = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Write a regex that matches ISO dates." }],
stream: false,
});
console.log(res.choices[0].message.content);
Both libraries already retry some failures by default. Keep that on, but add your own handling for 429, covered below.
Parameters that change agent behavior
The API passes these through to the model: temperature, top_p, stop, seed, and the frequency and presence penalties. For coding agents these settings are the useful ones:
- temperature: 0.0 to 0.3 for edits and patches, higher for brainstorming. Agents that loop over many steps drift less at low values.
- seed: set it when you want repeatable runs in a test of your agent. Treat it as a best effort, not a guarantee.
- stop: useful when your agent parses a fixed format and you want generation to end at a marker.
- max_tokens: optional here. Without it, the completion can use whatever is left of the 100,000-token window, so set a ceiling for steps that should stay short.
- response_format:
{"type":"json_object"}turns on JSON mode when the agent expects machine-readable output. Say "JSON" in your prompt too.
Streaming works with stream: true over server-sent events, and usage is reported at the end, which lets an agent log cost per step.
Tool calling for agent loops
Most coding agents run on function calls: the model asks to read a file, run a test or search, and your code answers. The endpoint accepts tools and tool_choice, streams tool_calls, and takes results back as messages with role: "tool".
curl https://api.uncensoredqwen.cc/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "What is in README.md?"}],
"tools": [{
"type": "function",
"function": {
"name": "read_file",
"description": "Read a text file from the project",
"parameters": {
"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"]
}
}
}],
"tool_choice": "auto"
}'
The reply holds a tool_calls entry with the function name and JSON arguments. Run it, append the model's message and a role: "tool" message with the result and the matching tool_call_id, and call the API again. Validate arguments before you act on them. A model can return malformed JSON or a path you did not expect, so keep file access inside the project folder.
Common failures in agent setups
Most broken setups come from five causes, and each takes a minute to check.
- Base URL without /v1. The tool then calls a path that does not exist and reports a 404. Use the URL exactly as written in this article.
- Wrong model string. The only model ID is
uncensored. A name copied from another provider's docs fails. - Old variables winning. A stale
OPENAI_API_KEYin a shell profile or a project.envoverrides the new one. Print the variables in the same terminal that launches the tool. - Proxy or workspace settings. Corporate proxies sometimes strip the Authorization header. A curl call from the same machine shows whether the request gets through.
- Too many parallel steps. The agent starts ten sub-tasks, the key allows 8 at once, and the extra two receive 429 with the code
concurrency. Lower the worker count.
The response header X-Request-Id identifies a single call. Keep it in your agent's logs, and include it if you contact support about a specific failure, so the call can be found quickly.
Limits, retries and cost control
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60. Agents that fan out, running several sub-tasks at once, hit the concurrency cap first. Over the limit you get HTTP 429 with the code concurrency or rate_limited, and under temporary load the API sends 429 with Retry-After: 5. Streamed requests hold their slot until the stream ends.
import time
from openai import OpenAI, RateLimitError
client = OpenAI(base_url="https://api.uncensoredqwen.cc/v1", api_key="YOUR_API_KEY")
def ask(messages, tries=5):
for attempt in range(tries):
try:
return client.chat.completions.create(model="uncensored", messages=messages)
except RateLimitError:
time.sleep(5)
raise RuntimeError("still rate limited after retries")
Use a semaphore or a pool of 8 workers so you rarely reach the 429 at all. For cost, remember that agents resend growing context on every step. At $0.15 per million input tokens, a 40,000-token context sent 25 times is 1,000,000 input tokens, so $0.15 for the input side alone, plus output at $0.50 per million. That is cheap per task, but a loop that never stops is not, so add a step limit. Failed or refused requests are not charged, and the balance appears in X-Balance-USD. Full rates are on the pricing page, and the Qwen 3 API guide has a production checklist worth reading before you leave an agent unattended.
More guides
Questions and answers
Which environment variables does Qwen Code use?
It reads OPENAI_API_KEY, OPENAI_BASE_URL and OPENAI_MODEL for OpenAI-compatible providers. Set them to your key, the base URL ending in /v1, and the model ID uncensored.
Does the endpoint support tool calling for agents?
Yes. It accepts tools and tool_choice, streams tool_calls, and takes results as role tool messages.
How many parallel requests can an agent make?
A full key allows 8 concurrent requests and 300 per minute. A trial key allows 2 and 60.
Why do I get a 404 from my editor?
The base URL is usually missing /v1 or includes /chat/completions. Use the base URL exactly as given and test it with curl.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.