provider configuration in opencode.json. This tutorial covers two methods: the interactive /connect command and direct opencode.json editing.
Prerequisites
- Node.js and the OpenCode CLI installed
- A Qhaigc API key — get one from the API Tokens page
- Access to create or edit an
opencode.jsonfile
Method 1: Using the /connect Command
Run /connect
Inside the OpenCode session, type
/connect and follow the interactive prompts to add a new provider. Select an OpenAI-compatible option when prompted for the provider type.Enter your Qhaigc details
When prompted, enter:
- Base URL:
https://api.qhaigc.net/v1 - API Key: your Qhaigc API key (starts with
sk-)
Method 2: Editing opencode.json Directly
Create or open opencode.json
Create or open
opencode.json in your project root (for project-level config) or your home directory (for user-level config).Add a Qhaigc provider entry
Add the following configuration, using the Replace
@ai-sdk/openai-compatible provider:sk-your-api-key-here with your actual Qhaigc API key.Save and restart OpenCode
Save
opencode.json, then restart your OpenCode session or refresh it so the new configuration takes effect.Verifying the Connection
Your setup is working when:- The
/connectflow completes without errors, oropencode.jsonis read without warnings - You can start a coding session and OpenCode sends requests to Qhaigc
- The model returns a response instead of an authentication or connection error
Frequently Asked Questions
Why not just use environment variables like OPENAI_API_KEY? OpenCode’s recommended approach is theprovider configuration in opencode.json. Environment variable overrides may work in some versions, but the opencode.json method is the official main path and more predictable.
OpenCode can’t fetch models from the endpoint — what do I do?
Confirm that baseURL and apiKey are correct. Then check OpenCode’s UI or config documentation for how to manually specify a model name, since not all OpenAI-compatible endpoints support the models list endpoint.