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

# OpenCode

> Configure AsterWise in OpenCode v1 or v2.

Before you start, install the tool and create an API key with prepaid balance in the [AsterWise app](https://app.asterwise.dev).

<Note>Based on the tool’s documented custom-provider setup. Live AsterWise compatibility has not yet been tested for this tool.</Note>

## Which API does this use?

This guide selects **Chat Completions** through the `openai-compatible` package. The base URL is `https://api.asterwise.dev/v1`. The client builds the full endpoint: `https://api.asterwise.dev/v1/chat/completions`.

The model name chooses AsterCode or AsterWork, not the protocol. Use the base URL in the configuration below, rather than the full endpoint.

## 1. Set your API key

```bash theme={"dark"}
export ASTER_API_KEY='your AsterWise API key'
```

## 2. Choose the configuration for your version

Check `opencode --version`. Create or edit `opencode.json` in your project, merging these fields with existing settings. The key stays in your environment.

<Tabs>
  <Tab title="OpenCode v1">
    ```json theme={"dark"}
    {
      "$schema": "https://opencode.ai/config.json",
      "model": "asterwise/aster-code",
      "provider": {
        "asterwise": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "AsterWise",
          "options": {
            "baseURL": "https://api.asterwise.dev/v1",
            "apiKey": "{env:ASTER_API_KEY}"
          },
          "models": {
            "aster-code": {
              "name": "AsterCode"
            },
            "aster-work": {
              "name": "AsterWork"
            }
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="OpenCode v2">
    ```json theme={"dark"}
    {
      "$schema": "https://opencode.ai/config.json",
      "model": "asterwise/aster-code",
      "providers": {
        "asterwise": {
          "name": "AsterWise",
          "env": [
            "ASTER_API_KEY"
          ],
          "package": "@opencode/ai/providers/openai-compatible",
          "settings": {
            "baseURL": "https://api.asterwise.dev/v1"
          },
          "models": {
            "aster-code": {
              "name": "AsterCode"
            },
            "aster-work": {
              "name": "AsterWork"
            }
          }
        }
      }
    }
    ```
  </Tab>
</Tabs>

Do not mix the v1 `provider` schema with v2 `providers`.

## 3. Start OpenCode

Run `opencode` from that project in the same terminal. Enter `/models` and select **AsterCode** under **AsterWise**.

Before your first request, configure model context and output limits from the app’s Setup page rather than assuming OpenCode’s defaults match the service.

## Check the connection

Ask “Reply with hello” first. Confirm a response appears and find the request in **Usage** in AsterWise. Then try a small coding task before a larger project.

For authentication errors, check the key and restart the tool from the terminal where you exported it. See [troubleshooting](/errors-fallback).

## Official reference

Configuration reviewed on September 16, 2026. [OpenCode v1 providers](https://opencode.ai/docs/providers) and [v2 providers](https://opencode.ai/v2/docs/providers).
