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:

Step 2: Launch OpenCode

Start OpenCode by running:
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

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
Replace it with the following configuration:
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.