Skip to main content
This page explains how to run models from Modular Cloud on OpenCode.

Before you begin

Make sure you have:

Connect to the Modular provider

To get started with Modular Cloud on OpenCode, you can connect a model from any of our shared endpoints:
  1. Start OpenCode:
  2. Run the /connect command and search for Modular. Select Modular and enter your API key.
  3. Run the /models command and select a Modular Cloud model.
To make a Modular Cloud model your default, set model in your opencode.json config file:
opencode.json
The OpenCode model list only includes models on Modular Cloud shared endpoints. The next section describes how to connect a model from a dedicated deployment.

Connect a dedicated deployment

Each dedicated deployment runs on your organization’s own endpoint, so you need to add it to OpenCode as a separate provider:
  1. Open your deployment and copy its Dedicated Endpoint and Model ID.
  2. Export your API key as an environment variable:
  3. Open the opencode.json config file in your project directory and add a provider for your deployment:
    opencode.json
    In baseURL, paste the dedicated endpoint you copied in step 1 with /v1 at the end. Then replace the model ID with your deployment’s model ID. Modular Cloud supports the OpenAI chat completions API, so set npm to @ai-sdk/openai-compatible. Avoid naming the provider modular because it might conflict with the built-in provider ID for Modular.
  4. Restart OpenCode, run the /models command, and select your deployment’s model.
To see the complete list of configuration options for providers, see the OpenCode documentation on custom providers.