Introduction
OpenCode is an open-source AI coding agent that runs in your terminal. It provides an interactive interface for coding, planning, reviewing, and debugging. OpenCode works with SaladCloud in two ways:- Salad AI Gateway - no infrastructure or custom provider configuration to manage. OpenCode discovers Salad AI Gateway through models.dev and loads the SaladCloud AI SDK provider automatically.
- Self-hosted model - deploy your own SaladCloud container group for full control over the model, hardware, and configuration. Still very easy to set up and use.
Prerequisites
Before getting started, make sure you have:- A SaladCloud account
- A terminal environment (Linux, macOS, or WSL on Windows)
- For Salad AI Gateway, an organization-specific AI Gateway API key
Step-by-Step Setup
Step 1: Choose Your Backend
- Salad AI Gateway
- Self-Hosted on SaladCloud
Salad AI Gateway is the fastest way to get started - no container groups to deploy, no cold starts to wait for.
- Sign in to the SaladCloud portal.
- Create or copy your AI Gateway API key by following Pay-Per-Token Onboarding.
Step 2: Install OpenCode
Install OpenCode using the official install script:Step 3: Connect OpenCode to SaladCloud
Choose the instructions for your backend:- Salad AI Gateway
- Self-Hosted on SaladCloud
Log in once to save your AI Gateway API key in OpenCode:Refresh the models catalog and verify that the model is available:The command should print:No custom provider block is required. OpenCode gets the endpoint and model metadata from models.dev and installs
To make Salad AI Gateway the default, add the The
- Search for and select SaladCloud AI Gateway.
- Paste AI Gateway API key you created during onboarding.
- Press Enter to save it.
opencode providers login --provider salad-cloud instead.OpenCode saves the credential locally, so you do not need to export an environment variable each time you open a
terminal. Confirm that SaladCloud AI Gateway appears in the saved providers:Log in before running the models command. Without a saved credential or
SALAD_CLOUD_API_KEY in the environment,
OpenCode can report Provider not found: salad-cloud even when its models cache is current. If your version does
not recognize providers, run opencode upgrade or use the older alias opencode auth login.@saladtechnologies-oss/ai-sdk-provider automatically.As an alternative to saving credentials, export the key in the same terminal before running OpenCode:model setting to ~/.config/opencode/opencode.json. A minimal
configuration is shown below; preserve any settings already in your file:model setting is optional if you prefer to pass --model salad-cloud/qwen3.6-35b-a3b when launching
OpenCode.Step 4: Test the Connection
For Salad AI Gateway, make a test request directly from the command line:“Create a hello world Python script that prints ‘Hello from SaladCloud!’”If OpenCode successfully creates the file, your setup is complete.
Troubleshoot Provider Discovery
If OpenCode reportsProvider not found: salad-cloud:
-
Check whether SaladCloud appears in your saved providers:
-
If it is missing, run
opencode providers loginand select SaladCloud AI Gateway. If you use the environment variable instead, confirm thatSALAD_CLOUD_API_KEYis set in the terminal where you run OpenCode. -
Check your OpenCode version and upgrade if necessary:
-
Run
opencode models salad-cloud --refreshagain.
401 Unauthorized, log in again with the organization-specific AI Gateway
key. Listing models confirms provider discovery, not that your API key is valid.
Tips for Best Results
Use the Build Agent
OpenCode’s built-inbuild agent handles code generation and editing with all tools enabled. It uses whichever model is
set as the default in your config. You can also switch to the built-in plan agent (Tab key) for read-only analysis and
planning without the risk of unintended file modifications.
Context Window
The Qwen 3.6-35B-A3B recipe and AI Gateway support a 262,144 token context window. Thecontext value in the config
lets OpenCode track how much context is remaining and manage prompt sizes accordingly, so make sure it reflects your
actual deployment configuration.
Persist Your API Key
Choose how to keep your credentials available:- Salad AI Gateway
- Self-Hosted on SaladCloud
opencode providers login saves your key locally for future sessions. No shell-profile change or API key in
opencode.json is needed. Treat OpenCode’s credential file as a secret and do not commit or share it. See
OpenCode’s authentication documentation for storage details.