OpenCode Custom Provider in Docker Sandbox A developer has published a guide for configuring OpenCode, an AI coding assistant, to use a custom provider within a Docker sandbox environment. The write-up details setting up an opencode.jsonc configuration file with a custom provider using the @ai-sdk/openai-compatible package, and explains how to securely pass API keys as environment variables when running in containers. The guide also covers enabling or disabling providers via whitelist or blacklist settings. A simple guide/writeup to myself and others when setting up OpenCode inside a Docker sandbox. 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" } } } } } 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. 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" OpenCode supports numerous providers, enabled by default. You can either blacklist disabled providers: ... or whitelist them enabled providers: ... .