# Connect OpenCode to Apertis

Use OpenCode with one Apertis key and the OpenAI-compatible endpoint. Keep the provider configuration explicit, select a current model from the live catalog, and verify both the response and its usage record before expanding the workflow.

Source: https://apertis.ai/integrations/opencode

## Before you configure OpenCode

No card is required to create an account. Choose a Coding Plan or add PAYG balance before your first API request.

## Configure OpenCode

In OpenCode, add an “Other” credential with /connect, then define the same provider ID in opencode.json with the OpenAI-compatible AI SDK package and the Apertis base URL.

Official docs: https://opencode.ai/docs/providers/#custom-provider

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "apertis": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Apertis",
      "options": {
        "baseURL": "https://api.apertis.ai/v1"
      },
      "models": {
        "YOUR_MODEL_ID": {
          "name": "YOUR_MODEL_ID"
        }
      }
    }
  }
}
```

## Select a current model

Model IDs, availability, capabilities, and pricing change faster than a static setup guide. Copy the exact ID from the [live model catalog](https://apertis.ai/models) and replace `YOUR_MODEL_ID` in your tool configuration.

## Verify the first successful API call

Send one small request through OpenCode. A completed setup is a model response followed by a matching request record in [Activity](https://apertis.ai/setting?tab=activity).

```bash
curl -sS https://api.apertis.ai/v1/chat/completions \
  -H "Authorization: Bearer $APERTIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"YOUR_MODEL_ID","messages":[{"role":"user","content":"Reply with OK"}]}'
```

## Common setup failures

| Error | Meaning | Next step |
| --- | --- | --- |
| 401 Unauthorized | The API key is missing, expired, or entered incorrectly. | Create or replace the key, then retry without exposing it in logs. |
| 404 Model Not Found | The selected model ID is unavailable for the current access path. | Copy a current model ID from the live Apertis model catalog. |
| 429 Too Many Requests | The request reached a rate or quota boundary. | Review the current plan, PAYG balance, and key quota before retrying. |
| Tool call failed | The selected model or endpoint may not support the tool pattern. | Choose a model with the required capability in the live catalog. |

## Start with one workload

Validate one model response and its usage record before moving more agents or repositories onto the same path.

No card is required to create an account. Choose a Coding Plan or add PAYG balance before your first API request.
