cd /news/developer-tools/opencode-custom-provider-in-docker-s… · home topics developer-tools article
[ARTICLE · art-120392] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=· neutral

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.

read1 min views1 publishedSep 3, 2026

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

).

── more in #developer-tools 4 stories · sorted by recency
── more on @opencode 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/opencode-custom-prov…] indexed:0 read:1min 2026-09-03 ·