Skip to main content

Overview

OpenCode is a collaborative web-based coding environment. Connecting OpenCode to ZnapAI unlocks premium code generation models directly within your web editor.

Prerequisites

  • An active OpenCode account.

Installation

Step 1: Install OpenCode

Download OpenCode from https://opencode.ai/download. Alternatively, the recommended installation method is via npm:
npm install -g opencode-ai

Step 2: Launch OpenCode

Start OpenCode by running:
opencode
This opens the OpenCode terminal interface.
OpenCode Terminal

Step 3: Understanding Provider Setup

Running the /connect command only configures built-in providers. To use ZnapAI, you must use the Custom AI Provider settings.

Configuration Steps

  1. Open your OpenCode settings.
  2. Navigate to the Custom AI Provider section.
  3. Input the Base URL: https://api.znapai.com/
  4. Provide your API Key to authenticate.
OpenCode Popular Providers

Base URL

https://api.znapai.com/

API Key Setup

Copy your key from the ZnapAI console and paste it into the secure API Key input in OpenCode.

Example Configuration

By default, the OpenCode configuration file contains:
config.json
{
  "$schema": "https://opencode.ai/config.json"
}
Replace it with the following configuration:
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "znap": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.znapai.com/",
        "apiKey": "YOUR_API_KEY"
      }
    }
  }
}
Save the file once you have replaced YOUR_API_KEY with your actual ZnapAI credentials.

Troubleshooting

  • If OpenCode fails to generate responses, check your balance on the ZnapAI dashboard.
  • Verify your network allows outbound requests to api.znapai.com.

Notes

  • OpenCode’s chat features are fully supported via the standard completions API format.