DevOps
OpenCode Custom Provider in Docker Sandbox
Rasmus Larsson Dev.to (EN Zone)
23 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
← Previous
A two-person rule for AI coding agents
Next →
One tab for every repo, container and AI session on my machine
Related
Upgrading a Locked-Down Linux Fleet with Nothing but kubectl
DevOps
53
Dev.to (EN Zone)
PasteSwitch: 108 crypto-theft ads on a hijacked HBO Max Reddit account
DevOps
39
DEV Community
Code Hosting vs CI/CD: GitHub Actions, GitLab CI, Jenkins, CircleCI, Argo Workflows and More — What Actually Fits Your Stack?
DevOps
40
Dev.to (EN Zone)
My build finished in 0 seconds and thirteen test suites passed. They had run yesterday's binary.
DevOps
37
DEV Community
Comments0
No comments yet — be the first