OpenCode
Use an OpenAI-compatible custom provider in OpenCode
This is OpenCode from opencode.ai, distinct from the OpenCodex proxy. Prepare a key and model using the shared guide.
1. Install and launch
npm install -g opencode-ai
opencodeAlternatively, use the desktop app from the official installation guide.
2. Save the API key
Run /connect inside OpenCode, choose Other, enter provider ID vnaipro, and paste your gateway API key.
The ID must match the provider key in the configuration below.
3. Configure the endpoint and model
Create or merge into opencode.json in the project directory:
{ "$schema": "https://opencode.ai/config.json", "provider": { "vnaipro": { "npm": "@ai-sdk/openai-compatible", "name": "VNAI Pro", "options": { "baseURL": "https://api.vnaipro.app/v1" }, "models": { "YOUR_MODEL_ID": { "name": "VNAI Pro model" } } } }, "model": "vnaipro/YOUR_MODEL_ID"}Replace both occurrences of YOUR_MODEL_ID.
The key is already saved through /connect; it does not belong in the project file.
| Model/channel protocol | npm |
|---|---|
| Chat Completions | @ai-sdk/openai-compatible |
| Responses | @ai-sdk/openai |
Both adapters use https://api.vnaipro.app/v1.
For a Responses-only model, change npm before testing; “OpenAI-compatible” does not mean every model accepts Chat Completions.
4. Select and test
Reopen OpenCode, run /models, and choose VNAI Pro model under your new provider.
Send a short prompt, test a file read, and check gateway usage history.
Missing model: the provider IDs in /connect and the config must match.
404 or tool errors: check the adapter, model ID, and shared requirements.
Sources: Custom provider, Configuration.