How to Use OpenCode With Qwen3.8 27B as a Coding Agent

By the end of this guide, OpenCode, the open-source terminal coding agent, will read, edit and run code in your project using Qwen3.8-27B Uncensored on your own dedicated pod. The setup is one config file that adds a custom OpenAI-compatible provider, and it takes about ten minutes once the pod is running.
The steps follow the site's OpenCode integration guide and add the settings this model needs: its 256K context window, an output limit, and a first task that proves tool calls work.
Why pair OpenCode with this model
A coding agent needs three things from a model: it has to be good at code, it has to call tools reliably, and it has to hold a lot of your project in view at once.
- Code quality. For the base model, the maker reports 90.3 on LiveCodeBench v6, 61.7 on SWE-bench Pro and 73.0 on Terminal-Bench 2.1.
- Tool calls. They are switched on for this build and use the standard OpenAI
toolsformat, which is what OpenCode sends. - Context. The pod serves the full 256K window (262,144 tokens), so the agent can keep many files and long tool output in one session.
- Speed. On an OpenLLM Buddy pod the model generates 79 tokens per second on one RTX 5090, single stream.
- Fewer refusals. The build's refusals were removed, so it answers security questions about your own code directly: how a bug could be exploited, what a proof of concept looks like, how to harden it. It refuses far less often than the base model, not never, and you remain responsible for lawful use.
Your code also stays where you put it. Prompts and outputs stay on your pod, which nobody else shares, and you pay for pod time with no per-token billing. That matters for an agent, because agents re-send large amounts of context on every step. The Qwen3.8 27B Uncensored guide covers the model in full.
What you need
| Item | Where it comes from |
|---|---|
| A running Qwen3.8-27B Uncensored pod | Deploy Qwen3.8-27B Uncensored |
The base URL, ending in /v1 | Your console |
| The API key | Your console |
| The model id | Your console; copy it exactly |
| A terminal on macOS or Linux | For the install script below |
| A project folder, ideally a git repository | So you can review and undo the agent's edits |
Throughout this guide, https://YOUR-POD-ENDPOINT/v1, YOUR_API_KEY and YOUR_MODEL_ID are placeholders. Copy the model id from your console, along with the other two values.
Step 1: Check the endpoint with curl
Do this before you touch OpenCode. If this request fails, no OpenCode setting will fix it, and you will save yourself from debugging the wrong tool.
curl https://YOUR-POD-ENDPOINT/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "YOUR_MODEL_ID", "messages": [{"role": "user", "content": "Reply with OK"}]}'
You should get a JSON response containing an assistant message. If you see a 401 or a 404 instead, jump to the troubleshooting table, fix the base URL, key or model id, and run it again.
Step 2: Install OpenCode
Install OpenCode with the official script from opencode.ai. Run it in your terminal on macOS or Linux:
curl -fsSL https://opencode.ai/install | bash
For other systems and install methods, see opencode.ai. When it finishes, the opencode command is available in new terminal windows.
Step 3: Store your API key with /connect
OpenCode keeps keys apart from its config file. The /connect command stores the key, and the config file in the next step supplies the endpoint and the model list.
Start OpenCode inside your project folder:
opencode
Then, inside the OpenCode screen:
/connect
- Scroll to Other.
- Enter a provider ID. This guide uses
openllmbuddy. You will type the same ID into the config file, so keep it simple. - Paste your API key when prompted.
The key is now saved under that provider ID. Nothing works yet, because OpenCode does not know where the provider lives. Quit OpenCode before the next step.
Step 4: Add the provider and the 256K limits
Create a file named opencode.json in the root of your project. To make the provider available in every project instead, the integration guide uses the global file at ~/.config/opencode/config.json.
{
"provider": {
"openllmbuddy": {
"npm": "@ai-sdk/openai-compatible",
"name": "OpenLLM Buddy",
"options": {
"baseURL": "https://YOUR-POD-ENDPOINT/v1"
},
"models": {
"YOUR_MODEL_ID": {
"name": "Qwen3.8-27B Uncensored",
"limit": {
"context": 262144,
"output": 32768
}
}
}
}
},
"model": "openllmbuddy/YOUR_MODEL_ID"
}
What each part does:
| Key | Value | Why |
|---|---|---|
provider.openllmbuddy | The provider ID from Step 3 | It must match the ID you entered in /connect, or the saved key is not used |
npm | @ai-sdk/openai-compatible | The package for providers that expose /v1/chat/completions, which your pod does |
options.baseURL | Your pod URL, ending in /v1 | The /v1 root over HTTPS. Do not add /chat/completions |
models | One entry keyed by your model id | The key must be the exact model id from your console |
limit.context | 262144 | The 256K window your pod serves |
limit.output | 32768 | The room reserved for each reply |
model | openllmbuddy/YOUR_MODEL_ID | Optional: makes this the default model, as provider ID, slash, model id |
Two of those need a little more explanation.
The context limit. A custom provider's model is unknown to OpenCode, so it cannot look up the window size. Setting limit.context to 262144 tells it how much conversation it can send before it has to compact the session. Leave it out and OpenCode has to guess. Set it higher than the real window and requests will fail once the session grows past what the pod accepts.
The output limit. The 32,768 here is a sensible setting, not a limit of the model. It is the space kept aside for one reply inside the 256K window, and this model's thinking counts toward it. Raise it if long generations get cut off. Lower it if you would rather give more of the window to your files.
The integration guide also shows an optional shortcut that uses environment variables in place of a config file. This tutorial uses the file, because the file is where the context and output limits live.
If you are on the OpenCode v2 beta
The config above is OpenCode's stable format. The v2 beta renames some keys: provider becomes providers, npm becomes package, and options becomes settings. The v1 format shown here remains supported, so it is the safe one to start with. If you are on v2 and want the new key names, check OpenCode's migration notes before converting the file.
Step 5: Select the model
Start OpenCode again in your project folder and open the model picker:
/models
Your custom provider appears in the list with the model under it. Choose the Qwen3.8-27B Uncensored entry. If you added the model line to the config, it is already selected.
Send a plain message such as "Which model are you and what can you do in this folder?" A reply means the provider, key, base URL and model id all line up.
Test it: a first task to try
A chat reply only proves the connection. An agent is working when it reads files, writes files and runs commands by itself. This first task exercises all three and is safe to run in any repository:
Read this repository and write a one-page summary of its structure to NOTES.md:
the main folders, the entry points, and how the tests are run.
Then run the test suite and list any failing tests with the likely cause of each.
Do not change any source files.
What you should see:
- A series of file reads and directory listings. These are tool calls.
- A new
NOTES.mdin your project. That is a write tool call. - A shell command that runs your tests, which OpenCode may ask you to approve first, followed by a summary of the result.
If all three happen, the agent is fully working. Review the change with git diff or git status, as you would with any contributor.
A good second task shows what the uncensored build adds for your own code:
Audit this codebase for injection and path traversal bugs.
For each one, explain how it could be exploited, then write a failing test that proves it.
Do not fix anything yet.
Run that only on code you own or are authorised to test.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| 404 on every request | The /v1 is doubled, as in /v1/v1/chat/completions, or baseURL includes /chat/completions | Set baseURL to exactly https://YOUR-POD-ENDPOINT/v1 and nothing after it |
| 404 on every request | The /v1 is missing from baseURL | Add /v1 to the end of the base URL |
| 401 unauthorized | Wrong or mistyped API key, or the key was saved under a different provider ID | Run /connect again with the key from your console and the same provider ID as the config |
| "Model not found", or a 404 or 400 that names the model | The key under models does not match the model id on the pod | Copy the model id from your console into the models key and the model line |
The provider is missing from /models | The config file is not being read, or the JSON is invalid | Check the file name and location, validate the JSON, and restart OpenCode |
| The model describes edits but no files change | Tool calls are not firing | See the checks below |
| Requests fail once the session gets long | limit.context is set above 262144, or is missing | Set limit.context to 262144 and start a new session |
| Replies stop partway through | The output limit is too low for the answer plus its thinking | Raise limit.output |
| Everything worked, then every request fails | The pod's time pack has ended and the pod has stopped | Start a new pod, then check the base URL and key in your console against your config |
When tool calls are not firing
First find out which side the problem is on. Send the pod a request with a tools field, using curl:
curl https://YOUR-POD-ENDPOINT/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "List the files in the src folder."}],
"tools": [{
"type": "function",
"function": {
"name": "list_files",
"description": "List the files in a directory of the project.",
"parameters": {
"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"]
}
}
}]
}'
If the response contains a tool_calls entry, the pod is doing its part and the problem is in the OpenCode setup. Check these in order:
- The package name. It must be
@ai-sdk/openai-compatible. The similar@ai-sdk/openaipackage is for providers that use/v1/responses, which is a different endpoint. - The mode. OpenCode has a plan mode that proposes changes without applying them. If the agent only describes what it would do, make sure you are in build mode.
- The session. A session that began before you fixed the config can keep its old state, so start a new one.
If the response has no tool_calls entry and the model answers in plain text instead, check that the model id is the one from your console and send the request again with a prompt that clearly needs the tool.
Getting better results from the agent
- Keep the session lean. Generation slows as the context fills, because each new token attends to everything before it. Start a new session for a new task instead of carrying a long history forward.
- Ask for a plan first on large changes. A written plan you approve is cheaper to correct than a hundred edited lines.
- Use the coding temperature where you can set one. The maker recommends a temperature of 0.6 for precise coding, against 1.0 for general use with thinking on.
- Be specific about scope. Name the files or folders, say what must not change, and say how to verify the result. Smaller models reward clear instructions more than large ones do.
- Know the model's size. This is a 27B model. It handles focused tasks, refactors and bug hunts well, and it will struggle sooner than the largest models on sprawling multi-step work.
- Keep work in git. Commit before a big task so that one command undoes it.
For the requests OpenCode sends underneath, including streaming and image input, see the Qwen3.8 27B Uncensored API guide. For why the full window fits on one 32 GB card, see Qwen3.8 27B VRAM and GPU requirements. If OpenCode is not the tool for your team, the best AI agent frameworks for startups compares other ways to build on the same endpoint, and the integrations index lists the other guides.
FAQ
Can OpenCode use Qwen3.8 27B?
Yes. OpenCode connects to any OpenAI-compatible endpoint through a custom provider, and a Qwen3.8-27B Uncensored pod exposes one with tool calls switched on. You add the provider in the config file with your pod's base URL and model id.
How do I add a custom OpenAI-compatible provider to OpenCode?
Store the API key with the connect command under a provider ID of your choice, then add a provider block with the same ID to the OpenCode config file. The block names the openai-compatible package, sets the base URL to your endpoint's v1 root and lists your model id.
What context limit should I set for Qwen3.8 27B in OpenCode?
Set the context limit to 262144, which is the full 256K window the pod serves. The output limit is your choice; 32768 is a reasonable starting point and can be raised if long replies are cut off.
Why does OpenCode return a 404 with my custom provider?
The base URL is almost always the cause. Either the v1 segment is missing, or it appears twice because the base URL already included the full chat completions path. A wrong model id can also produce a 404 that names the model.
Is Qwen3.8 27B good enough for a coding agent?
For the base model the maker reports 90.3 on LiveCodeBench v6, 61.7 on SWE-bench Pro and 73.0 on Terminal-Bench 2.1, and tool calls work in the standard format. It is a 27B model, so it suits focused tasks better than very large multi-step projects.
Does my code leave my pod when I use OpenCode this way?
OpenCode sends your prompts and file contents to the endpoint you configure, which is your own dedicated pod. Prompts and outputs stay on that pod, and nobody else shares it.


