{
  "id": 5352473,
  "title": "OpenCode Custom Provider in Docker Sandbox",
  "url": "https://urgent.news/2026/09/03/opencode-custom-provider-in-docker-sandbox",
  "topic": "ai",
  "section": "AI",
  "published": "2026-09-03T15:12:41.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/stoft/opencode-custom-provider-in-docker-sandbox-166b"
  },
  "original_language": "en",
  "account": "A comprehensive guide to setting up OpenCode within a Docker sandbox is available to help users get started. To begin, obtain the OpenCode provider key and then create the opencode.jsonc configuration file.\n\nThe configuration file should include the following elements:\n\n1. The $schema attribute should reference the OpenCode configuration file: https://opencode.ai/config.json\n2. The lsp (language server protocol) option should be set to true. This allows OpenCode to function as a language server.\n3. The enabled_providers array should contain the custom_provider entry.\n\nNext, add the custom provider settings within the provider object:\n\n1. The custom_provider object should be defined, specifying the npm package, custom_provider.\n2. The name of the custom provider should be set to \"My Custom Provider\".\n3. The options object should include the baseURL, pointing to custom_provider.example.com/v1 (note that this URL should be modified to match your specific provider).\n4. The apiKey should be set as an environment variable, using the env:CUSTOM_PROVIDER_API_KEY notation. This allows for secure management of the API key within the Docker sandbox environment.\n5. The models object should list the specific models that the custom provider should support, including their names and API keys.\n\nSome additional notes to keep in mind:\n\n* OpenCode will use the first encountered config file in the directory tree, which can be helpful when running within a sandbox that only has access to a subset of the disk's directory structure.\n* When running OpenCode in a container, such as a Docker sandbox, you'll need to pass in the API key as an environment variable to ensure that agents cannot access the entire machine. Here's an example command for setting up OpenCode in a Docker sandbox:\nexport CUSTOM_PROVIDER_API_KEY = \"****************\" && \\\nsbx secret set-custom --host custom_provider.example.com --env CUSTOM_PROVIDER_API_KEY --value $CUSTOM_PROVIDER_API_KEY\n\nOpenCode is capable of supporting a variety of providers, which can be enabled or disabled based on your specific needs. Enable or disable providers using the disabled_providers or enabled_providers arrays.",
  "summary": "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…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}