> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salad.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> For autonomous tasks, use live SaladCloud API responses for current state, availability, quotas, models, and other dynamic values. Use current OpenAPI specifications where provided for paths, schemas, required fields, and enums. Never invent endpoints, fields, prices, availability, quotas, models, or state. Prefer API workflows over Portal steps. Read before changing and never expose credentials, signed media URLs, prompts, or sensitive outputs. Retry only safe or idempotent operations with bounded backoff, honoring Retry-After. Verify every write with a read. Stop rather than repeat an uncertain non-idempotent or billable request. AI Gateway uses an organization-specific Bearer key and live /v1/models discovery. Do not delete, cancel, stop, or reduce capacity without explicit user intent. Bind shared operation IDs to the selected product path. Treat Container Engine instances as interruptible and local state as ephemeral. Install the SaladCloud skills (npx skills add https://docs.salad.com), start from the salad skill and /agents/overview; docs MCP: https://docs.salad.com/mcp.

# Use OpenCode with SaladCloud

> Use the OpenCode terminal coding agent with Salad AI Gateway or a self-hosted model on SaladCloud.

*Last Updated: October 12, 2026*

## Introduction

[OpenCode](https://opencode.ai) 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](https://docs.salad.com/ai-gateway/explanation/overview.md)** - no infrastructure or custom provider configuration to
  manage. OpenCode discovers Salad AI Gateway through [models.dev](https://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](https://portal.salad.com)
* A terminal environment (Linux, macOS, or WSL on Windows)
* For Salad AI Gateway, an [organization-specific AI Gateway API key](https://docs.salad.com/ai-gateway/tutorials/pay-per-token-onboarding.md)

## Step-by-Step Setup

### Step 1: Choose Your Backend

> [tab] Salad AI Gateway
>
> Salad AI Gateway is the fastest way to get started - no container groups to deploy, no cold starts to wait for.
>
> 1. Sign in to the [SaladCloud portal](https://portal.salad.com).
> 2. Create or copy your **AI Gateway API key** by following
>    [Pay-Per-Token Onboarding](https://docs.salad.com/ai-gateway/tutorials/pay-per-token-onboarding.md).
>
> Available models:
>
> | Model | Description |
> | :- | :- |
> | `qwen3.6-35b-a3b` | Qwen3.6 35B-A3B - suited to agentic tasks, coding, and complex reasoning |

> [tab] Self-Hosted on SaladCloud
>
> First, deploy an OpenAI-compatible LLM server on SaladCloud.
>
> * Go to the [SaladCloud portal](https://portal.salad.com) and create an account if you do not already have one.
> * Create an organization or choose an existing one, then click "Deploy a container group".
> * Select an LLM recipe. The best fit for agentic coding is the Qwen3.6-35B-A3B (llama.cpp) recipe. On the recipe
>   page, provide a name and deploy - the rest is preconfigured with recommended settings.
> * Once deployed, your endpoint will be live and serving an OpenAI-compatible API.
>
> Available recipes:
>
> Ready-to-deploy recipes (best for less technical users):
>
> * [qwen3.6-35B-A3B](https://docs.salad.com/container-engine/reference/recipes/qwen3.6-35b-a3b-llama-cpp.md) — A powerful Mixture of Experts
>   model optimized for instruction-following tasks, ideal for agentic use cases.
>
> Recipes for custom deployments (best for advanced users):
>
> * [llama.cpp](https://docs.salad.com/container-engine/reference/recipes/llama-cpp.md) — Supports GGUF models
> * [sglang](https://docs.salad.com/container-engine/reference/recipes/sglang.md) — High-performance inference
> * [vllm](https://docs.salad.com/container-engine/reference/recipes/vllm.md) — Popular LLM serving framework
> * [ollama](https://docs.salad.com/container-engine/reference/recipes/ollama.md) — Simple model management
> * [tgi](https://docs.salad.com/container-engine/reference/recipes/tgi.md) — Hugging Face Text Generation Inference server
>
> After deployment, note your:
>
> * **API endpoint URL** (e.g., `https://your-endpoint.salad.cloud`)

### Step 2: Install OpenCode

Install OpenCode using the official install script:

```bash theme={null}
curl -fsSL https://opencode.ai/install | bash
```

Or install via npm:

```bash theme={null}
npm install -g opencode-ai
```

Verify the installation:

```bash theme={null}
opencode --version
```

### Step 3: Connect OpenCode to SaladCloud

Choose the instructions for your backend:

> [tab] Salad AI Gateway
>
> Log in once to save your AI Gateway API key in OpenCode:
>
> ```bash theme={null}
> opencode providers login
> ```
>
> 1. Search for and select **SaladCloud AI Gateway**.
> 2. Paste **AI Gateway API key** you created during onboarding.
> 3. Press Enter to save it.
>
> To skip provider selection, use `opencode providers login --provider salad-cloud` instead.
>
> > [!WARNING]
> >
> > Use the key listed under **AI Gateway Keys** for your organization, not the regular SaladCloud **Current API
> > Key**. Do not add a `Salad-Api-Key` header for AI Gateway.
>
> 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:
>
> ```bash theme={null}
> opencode providers list
> ```
>
> Refresh the models catalog and verify that the model is available:
>
> ```bash theme={null}
> opencode models salad-cloud --refresh
> ```
>
> The command should print:
>
> ```text theme={null}
> salad-cloud/qwen3.6-35b-a3b
> ```
>
> > [!NOTE]
> >
> > 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`.
>
> No custom provider block is required. OpenCode gets the endpoint and model metadata from models.dev and installs
> `@saladtechnologies-oss/ai-sdk-provider` automatically.
>
> As an alternative to saving credentials, export the key in the same terminal before running OpenCode:
>
> ```bash theme={null}
> export SALAD_CLOUD_API_KEY="your-ai-gateway-api-key"
> ```
>
> To make Salad AI Gateway the default, add the `model` setting to `~/.config/opencode/opencode.json`. A minimal
> configuration is shown below; preserve any settings already in your file:
>
> ```json theme={null}
> {
>   "$schema": "https://opencode.ai/config.json",
>   "model": "salad-cloud/qwen3.6-35b-a3b"
> }
> ```
>
> The `model` setting is optional if you prefer to pass `--model salad-cloud/qwen3.6-35b-a3b` when launching
> OpenCode.

> [tab] Self-Hosted on SaladCloud
>
> Create or edit the OpenCode configuration file at `~/.config/opencode/opencode.json`:
>
> ```json theme={null}
> {
>   "$schema": "https://opencode.ai/config.json",
>   "model": "saladcloud/qwen3.6-35b-a3b",
>   "provider": {
>     "saladcloud": {
>       "npm": "@ai-sdk/openai-compatible",
>       "name": "SaladCloud",
>       "options": {
>         "baseURL": "https://your-endpoint.salad.cloud/v1",
>         "apiKey": "dummy",
>         "headers": {
>           "Salad-Api-Key": "{env:SALAD_API_KEY}"
>         }
>       },
>       "models": {
>         "qwen3.6-35b-a3b": {
>           "name": "Qwen 3.6-35B-A3B",
>           "limit": {
>             "context": 262144,
>             "output": 32768
>           }
>         }
>       }
>     }
>   }
> }
> ```
>
> Replace `https://your-endpoint.salad.cloud/v1` with your actual SaladCloud endpoint URL.
>
> If your SaladCloud deployment requires authentication, set your API key as an environment variable or hardcode it in
> the config (not recommended for security reasons):
>
> ```bash theme={null}
> export SALAD_API_KEY=your-salad-api-key
> ```
>
> OpenCode will inject this as the `Salad-Api-Key` request header on every API call. The `apiKey` field in the config
> must be set to a non-empty string but is otherwise unused - authentication is handled entirely by the header.

### Step 4: Test the Connection

For Salad AI Gateway, make a test request directly from the command line:

```bash theme={null}
opencode run \
  --model salad-cloud/qwen3.6-35b-a3b \
  "Explain distributed inference in five sentences."
```

For an interactive session, navigate to your project and start OpenCode:

```bash theme={null}
cd /path/to/your/project
opencode
```

OpenCode will open a TUI in your terminal. Test with a simple task:

> "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 reports `Provider not found: salad-cloud`:

1. Check whether SaladCloud appears in your saved providers:

   ```bash theme={null}
   opencode providers list
   ```

2. If it is missing, run `opencode providers login` and select **SaladCloud AI Gateway**. If you use the environment
   variable instead, confirm that `SALAD_CLOUD_API_KEY` is set in the terminal where you run OpenCode.

3. Check your OpenCode version and upgrade if necessary:

   ```bash theme={null}
   opencode --version
   opencode upgrade
   ```

4. Run `opencode models salad-cloud --refresh` again.

If the provider is listed but requests return `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-in `build` 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 supports a 262,144 token context window. AI Gateway context windows vary by model; see the
[AI Gateway models page](https://docs.salad.com/ai-gateway/reference/models.md). The `context` 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:

> [tab] Salad AI Gateway
>
> `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](https://opencode.ai/docs/cli/#auth) for storage details.

> [tab] Self-Hosted on SaladCloud
>
> ```bash theme={null}
> echo 'export SALAD_API_KEY="your-salad-api-key"' >> ~/.bashrc
> source ~/.bashrc
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.