General
OpenCode Custom Provider in Docker Sandbox
0 views

A simple guide/writeup to myself and others when setting up OpenCode inside a Docker sandbox.
Get Started
Install OpenCode
Get your provider key
Create your opencode.jsonc config:
{
"$schema": "https://opencode.ai/config.json",
"lsp": true,
// see note below
"enabled_providers": [
"custom_provider"
],
"provider": {
"custom_provider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My Custom Provider",
"options": {
"baseURL": "https://custom_provider.example.com/v1",
// see note below
"apiKey": "{env:CUSTOM_PROVIDER_API_KEY}"
},
"models": {
"mistral.devstral-2-123b": {
"name": "mistral.devstral-2-123b"
},
"openai.gpt-oss-120b-1:0": {
"name": "openai.gpt-oss-120b-1:0"
},
"openai.gpt-oss-20b-1:0": {
"name": "openai.gpt-oss-20b-1:0"
}
}
}
}
}
Notes
Config
There’s a default config in your user (check the docs for OpenCode) but OpenCode will also consume the closest one in your directory tree. This is very handy when running in a sandbox that only has access to a sub-directory tree on your disk.
API Key
If you run OpenCode in a container such as Docker Sandboxes, which is good because then the agents can’t access your whole machine, but requires more setup, you have to pass in your API key as an environment variable when setting up. Here’s an example for docker sbx:
export CUSTOM_PROVIDER_API_KEY=**************** && \
sbx secret set-custom \
--host custom_provider.example.com \
--env CUSTOM_PROVIDER_API_KEY \
--value "$CUSTOM_PROVIDER_API_KEY"
Providers
OpenCode supports numerous providers, enabled by default. You can either blacklist (disabled_providers: [...]) or whitelist them (enabled_providers: [...]).
Read original: https://dev.to/stoft/opencode-custom-provider-in-docker-sandbox-166b
PreviousOpenClaw went viral. Meet the maintainers building and securing it.NextOpenCompany เปิดซอร์ส 22 บริษัทให้ agent รัน แต่สมองยังอยู่ที่อื่น
Related posts
More people should build browsers
0Hacker News New
Byesky: Wipe your Bluesky account clean
0Hacker News New
Electric trucks hit 50% of China's heavy truck sales, diesel demand falls
0Hacker News New
Poles and polars in projective space with homogeneous coordinates
0Hacker News New
Making Peace with the Projective Plane
0Hacker News New
Show HN: Hacker News Aggregators, Aggregated
0Hacker News Show