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

# OpenCode

> Use OpenCode with NagaAI by adding a custom provider to the OpenCode config file.

OpenCode is an AI coding agent that runs in your terminal. You can connect it to NagaAI by defining a custom provider in `~/.config/opencode/opencode.json` and then authenticating with your **NagaAI API key** inside OpenCode.

## Setup

<Steps>
  <Step title="Install OpenCode">
    Follow the official installation docs at [opencode.ai/docs](https://opencode.ai/docs).

    You can install it with the official install script:

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

    Or install it with npm:

    ```bash theme={null}
    npm install -g opencode-ai
    ```
  </Step>

  <Step title="Create a NagaAI API key">
    Create an API key in the [NagaAI Dashboard](https://naga.ac/dashboard).

    <Info>
      If you're new to NagaAI, follow the [Quickstart](/get-started/quickstart) first.
    </Info>
  </Step>

  <Step title="Add NagaAI as a custom provider">
    Open `~/.config/opencode/opencode.json` and configure a custom provider named `naga-ai`:

    ```json theme={null}
    {
      "$schema": "https://opencode.ai/config.json",
      "disabled_providers": [],
      "provider": {
        "naga-ai": {
          "name": "NagaAI",
          "npm": "@ai-sdk/openai",
          "models": {
            "gpt-5.4": {
              "name": "GPT 5.4",
              "limit": {
                "context": 1050000,
                "output": 128000
              },
              "modalities": {
                "input": ["text", "image"],
                "output": ["text"]
              }
            }
          },
          "options": {
            "baseURL": "https://api.naga.ac/v1"
          }
        }
      }
    }
    ```

    <Note>
      This example registers `gpt-5.4`, but you can add other NagaAI models too. For agentic coding, prefer models with tools support.
    </Note>
  </Step>

  <Step title="Connect your API key in OpenCode">
    Start OpenCode in your project directory:

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

    Then run:

    ```text theme={null}
    /connect
    ```

    In the provider list:

    1. Select **NagaAI**
    2. Paste your **NagaAI API key**
    3. Save the credential
  </Step>

  <Step title="Choose the model and start coding">
    After connecting, select the configured NagaAI model in OpenCode and start your session.

    <Info>
      The provider base URL should be `https://api.naga.ac/v1`.
    </Info>
  </Step>
</Steps>

## Notes

* Config file: `~/.config/opencode/opencode.json`
* Base URL: `https://api.naga.ac/v1`
* Provider name in config: `naga-ai`
* Display name in OpenCode: `NagaAI`
* Recommended starter model: `gpt-5.4`
* Tools-capable models: [browse the live catalog](https://naga.ac/models?parameters=tools)

## Try it

* "Summarize this repository: structure, build system, and entry points."
* "Find where feature X is implemented and list the relevant files."
* "Run tests and fix the first failing test."
* "Refactor module Y and update all call sites."
