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: [...]).