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

# Use Modellix LLM with OpenCode

> Add Modellix as a custom OpenAI-compatible provider in OpenCode with @ai-sdk/openai-compatible, baseURL, and provider/name model IDs.

Configure [OpenCode](https://opencode.ai) to call the Modellix LLM gateway. The recommended approach is a [custom provider](https://opencode.ai/docs/providers/#custom-provider) using `@ai-sdk/openai-compatible` (Chat Completions at `/v1/chat/completions`).

<Note>
  Modellix model IDs are `provider/name` (for example `openai/gpt-5.5`). Put that full string in the custom provider `models` map so OpenCode sends it unchanged in the request body. See [Models & Pricing](/llm/overview#models-and-pricing).
</Note>

## 1. Store credentials

In OpenCode, run `/connect`, choose **Other**, and enter a provider ID such as `modellix`. Paste your Modellix API key from the [console](https://modellix.ai/console/api-key).

The provider ID from `/connect` must match the key under `provider` in `opencode.json`.

Alternatively, set the key in config with `options.apiKey` (for example `{env:MODELLIX_API_KEY}`).

## 2. Add a custom provider

Create or update `opencode.json` (project) or `~/.config/opencode/opencode.json`:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "model": "modellix/openai/gpt-5.5",
  "provider": {
    "modellix": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Modellix",
      "options": {
        "baseURL": "https://llm.modellix.ai/v1",
        "apiKey": "{env:MODELLIX_API_KEY}"
      },
      "models": {
        "openai/gpt-5.5": {
          "name": "GPT 5.5"
        },
        "openai/gpt-5.6-sol": {
          "name": "GPT 5.6 Sol"
        },
        "openai/gpt-5.6-terra": {
          "name": "GPT 5.6 Terra"
        },
        "openai/gpt-5.6-luna": {
          "name": "GPT 5.6 Luna"
        },
        "anthropic/claude-sonnet-5": {
          "name": "Claude Sonnet 5"
        },
        "google/gemini-3.6-flash": {
          "name": "Gemini 3.6 Flash"
        },
        "xai/grok-4.5": {
          "name": "Grok 4.5"
        }
      }
    }
  }
}
```

| Field             | Value                                                      |
| ----------------- | ---------------------------------------------------------- |
| Provider ID       | Any string (for example `modellix`); must match `/connect` |
| `npm`             | `@ai-sdk/openai-compatible` for Chat Completions           |
| `options.baseURL` | `https://llm.modellix.ai/v1`                               |
| `options.apiKey`  | Modellix API Key (or rely on `/connect` auth)              |
| `models` keys     | Exact Modellix Model IDs (`provider/name`)                 |
| Top-level `model` | `modellix/<model-id>` (provider ID + model key)            |

Add or remove entries under `models` as needed. Full catalog: [Models & Pricing](/llm/overview#models-and-pricing).

Then run `/models` and select a Modellix model.

<Tip>
  If you prefer Responses instead of Chat Completions, set `npm` to `@ai-sdk/openai` (see [OpenCode custom provider](https://opencode.ai/docs/providers/#custom-provider)). Most setups should keep `@ai-sdk/openai-compatible`.
</Tip>

## Anthropic and Google models

You do **not** need a separate Anthropic `baseURL` without `/v1` for OpenCode. Register `anthropic/...` and `google/...` IDs on the same Modellix custom provider above; traffic goes through OpenAI-compatible Chat Completions on `https://llm.modellix.ai/v1`.

Native Anthropic Messages (`ANTHROPIC_BASE_URL` without `/v1`) is for the [Anthropic SDK](/llm/anthropic-sdk) and [Claude Code](/llm/claude-code), not required here.

## Troubleshooting

| Check         | Detail                                                                  |
| ------------- | ----------------------------------------------------------------------- |
| Provider ID   | `/connect` ID matches `provider.modellix` (or your chosen ID) in config |
| `npm` package | Use `@ai-sdk/openai-compatible` for `/v1/chat/completions`              |
| `baseURL`     | Must be `https://llm.modellix.ai/v1`                                    |
| Model keys    | Must be full IDs like `openai/gpt-5.5`, not bare `gpt-5.5`              |
| Auth          | `opencode auth list`, or `options.apiKey`                               |

## Related

* [OpenCode custom provider](https://opencode.ai/docs/providers/#custom-provider) — official setup
* [Models & Pricing](/llm/overview#models-and-pricing) — Model IDs and rates
* [LLM API guide](/llm/api) — protocols and curl examples
* [OpenAI SDK](/llm/openai-sdk) — same `/v1` Chat Completions gateway
