Before you begin
Make sure you have:- A Modular Cloud account.
- OpenCode installed.
Add authentication
First, connect Modular Cloud to OpenCode.- Create a Modular Cloud API key and copy its value.
-
Start OpenCode:
-
Run the
/connectcommand in OpenCode. - At the end of the provider list, select Other.
-
Set the Provider id to
modularand submit your API key.
Update the OpenCode config
Next, configure Modular Cloud as a provider in the OpenCode config.-
Open the
opencode.jsonconfig file in your project directory. - Choose the model that you want from our list of shared endpoints or use a dedicated endpoint if applicable.
-
Add Modular Cloud as a provider:
opencode.json
npm value depends on the API you’re using:
- For the chat completions API, use
@ai-sdk/openai-compatible. - For the responses API, use
@ai-sdk/openai.
opencode.json
/models command.
The example above demonstrates a basic provider configuration. To see the
complete list of configuration options, see the OpenCode documentation on
custom providers.