← /docs/integrationsopenai-chat-completions
FlatCompute × OpenCode
OpenCode
Use OpenCode with FlatCompute for a flat-rate, unlimited-token coding agent backend.
FlatCompute speaks the OpenAI Chat Completions API, so any tool that can
point at https://api.openai.com/v1 can point at FlatCompute instead — and
swap per-token billing for a fixed monthly plan with unlimited tokens.
Configuration
Set these environment variables (or your agent's equivalent config file):
export FLATCOMPUTE_BASE_URL="https://gateway.flatcompute.com/v1"
export FLATCOMPUTE_API_KEY="<FLATCOMPUTE_API_KEY>"
export FLATCOMPUTE_MODEL_ID="qwen3.6:35b-a3b"
export FLATCOMPUTE_PLAN="starter"
Then point your OpenCode config at the gateway:
{
"provider": "flatcompute",
"baseURL": "https://gateway.flatcompute.com/v1",
"model": "qwen3.6:35b-a3b",
"apiKeyEnv": "FLATCOMPUTE_API_KEY"
}
Heads up:
FLATCOMPUTE_API_KEYmust be loaded from your environment only. It is never written into downloaded files or shared client-side.
Quick start
- Create an API key in the FlatCompute dashboard.
- Subscribe to a plan on the zones page.
- Export the environment variables above.
- Launch OpenCode — it will route every request through FlatCompute.
Verifying the connection
curl https://gateway.flatcompute.com/v1/chat/completions \
-H "Authorization: Bearer ${FLATCOMPUTE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.6:35b-a3b",
"messages": [{"role": "user", "content": "ping"}]
}'
A 200 OK with a completion body means you're live on FlatCompute.
Troubleshooting
| Symptom | Fix |
|---|---|
401 Unauthorized | Regenerate your API key; ensure FLATCOMPUTE_API_KEY is exported in the shell that launches the agent. |
429 Too Many Requests | You hit your plan's RPM limit. Upgrade your plan or reduce concurrency. |
| Timeouts | Pick a zone closer to you from the zones page, or raise your client timeout. |
| Wrong model | Confirm FLATCOMPUTE_MODEL_ID matches a model offered by your subscribed zone. |