Connect OpenCode to OpenLLM Buddy
This guide shows how to use OpenCode with your OpenAI-compatible OpenLLM Buddy endpoint and model qwen3.6:27b.
Integration guide
What is OpenCode?
OpenCode is an open-source AI coding agent for your terminal, IDE, or desktop. It supports many providers — including any OpenAI-compatible API — so you can point it at your own hosted models.
Why connect OpenLLM Buddy?
OpenLLM Buddy serves /v1/chat/completions on dedicated GPU instances. OpenCode can use @ai-sdk/openai-compatible with a custom base URL — perfect for our proxy endpoint.
How this guide is structured
- Install — official installer from opencode.ai
- /connect — add provider openllmbuddy + API key
- config.json — set baseURL and models
- Optional — environment variables
- /models — pick your model in the TUI
- curl test — verify the endpoint before debugging OpenCode
Tip: run the curl test in Step 6 before OpenCode if anything fails — OpenCode cannot fix a broken endpoint. Get your API key from the console.
Install OpenCode
Install OpenCode using the official script from opencode.ai. Run this in your terminal (macOS or Linux).
curl -fsSL https://opencode.ai/install | bash
After install, launch the TUI with opencode to connect your provider.
Connect your custom provider
The easiest way to add OpenLLM Buddy is the /connect command inside OpenCode.
opencode
# Inside the OpenCode TUI: /connect # Scroll to "Other" → enter your provider ID → paste your API key
- Run opencode in your project directory.
- Type /connect.
- Scroll to Other.
- Enter a unique provider ID (example: openllmbuddy).
- Paste your OpenLLM Buddy API key when prompted.
After connecting, set the base URL in config.json (next step) — /connect stores the key; the config file wires the endpoint and model list.
Configure base URL in config.json
Edit your OpenCode config at ~/.config/opencode/config.json (or opencode.json in your project). Use the same provider ID you chose in /connect (example: openllmbuddy).
{
"provider": {
"openllmbuddy": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://openllmbuddy-proxy.botbuddytech.workers.dev/v1"
},
"models": {
"qwen3.6:27b": {}
}
}
}
}Use @ai-sdk/openai-compatible for providers that expose /v1/chat/completions (like OpenLLM Buddy). If your provider uses /v1/responses instead, use @ai-sdk/openai.
Set baseURL to your /v1 root (HTTPS). Add each model id you want under models as an empty object ({}).
Use environment variables (optional)
For a quick setup without editing JSON, export these two variables before running OpenCode:
export OPENAI_API_KEY=YOUR_API_KEY export OPENAI_BASE_URL=https://openllmbuddy-proxy.botbuddytech.workers.dev/v1
Replace the placeholder with your real API key from the console. You may still need config.json for custom provider IDs and multiple models — env vars are the fastest path for a single OpenAI-compatible endpoint.
Select your model
Inside the OpenCode TUI, run /models to pick which model to use for this session.
/models
Your custom provider and configured models should appear in the list. For this guide, choose qwen3.6:27b (or the matching entry under your provider id).
Examples: Gemma 4 26B → gemma4:26b, Qwen 3.6 27B → qwen3.6:27b
Test with curl (recommended)
Recommended: verify your endpoint with curl before relying on OpenCode. If this request fails, OpenCode will not fix it for you.
curl https://openllmbuddy-proxy.botbuddytech.workers.dev/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen3.6:27b", "messages": [{"role": "user", "content": "Reply with OK"}]}'You should get a JSON response with an assistant message (e.g. "OK"). Use your API key from the console. If you see 401/404, fix base URL, key, or model id before continuing with OpenCode.