Using OpenCode AI Coding Agent with PayPerQ
Learn how to integrate OpenCode, the open source AI coding agent, with PayPerQ to access premium AI models including Claude Sonnet 4, GPT-5, and Gemini 2.5 Pro.
What is OpenCode?
OpenCode is an open source AI coding agent that helps you write code directly in your terminal, IDE, or desktop application. With OpenCode, you can leverage AI to assist with coding tasks, refactoring, debugging, and more—all through a simple command-line interface or desktop app.
Why Use PayPerQ with OpenCode?
By connecting OpenCode to PayPerQ's API, you gain access to cutting-edge AI models that are perfect for coding tasks:
- Claude Sonnet 4.5 & Opus 4.5 - Anthropic's most advanced reasoning models
- GPT-5.1 Codex - OpenAI's specialized coding models
- Gemini 2.5 Pro - Google's latest multimodal AI
- Qwen3 Coder - Specialized for programming tasks
- Grok Code Fast - X.AI's rapid coding model
- And many more premium models
All models recommended by OpenCode's Zen provider are available through PayPerQ with simple pay-per-use pricing—no subscriptions required.
Step by Step Set Up
1. Install OpenCode
First, install OpenCode using one of the following methods:
Using curl:
curl -fsSL https://opencode.ai/install | bash
Using npm:
npm install -g opencode
Using brew (macOS):
brew install opencode
For more installation options, visit the OpenCode GitHub repository.
2. Get Your PayPerQ API Key
Navigate to ppq.ai/api-docs and copy your API key. You'll need this to authenticate your requests.

3. Locate Your OpenCode Config Folder
OpenCode stores its configuration in a platform-specific location:
- Linux:
~/.config/opencode - macOS:
~/.config/opencode - Windows:
%APPDATA%\opencode
Navigate to this folder in your terminal or file explorer.
4. Create the Configuration File
Create a new file called opencode.json in your OpenCode config folder. You can download the complete configuration file here:
Or create it manually with the following content:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ppq": {
"npm": "@ai-sdk/openai-compatible",
"name": "ppq",
"options": {
"baseURL": "https://api.ppq.ai",
"apiKey": "sk-YOUR_API_KEY_HERE",
"includeUsage": true
},
"models": {
"z-ai/glm-4.6": {
"name": "z-ai/glm-4.6"
},
"x-ai/grok-code-fast-1": {
"name": "x-ai/grok-code-fast-1"
},
"moonshotai/kimi-k2-thinking": {
"name": "moonshotai/kimi-k2-thinking"
},
"moonshotai/kimi-k2": {
"name": "moonshotai/kimi-k2"
},
"qwen/qwen3-coder": {
"name": "qwen/qwen3-coder"
},
"anthropic/claude-sonnet-4": {
"name": "anthropic/claude-sonnet-4"
},
"claude-sonnet-4.5": {
"name": "claude-sonnet-4.5"
},
"claude-haiku-4.5": {
"name": "claude-haiku-4.5"
},
"anthropic/claude-3.5-haiku": {
"name": "anthropic/claude-3.5-haiku"
},
"claude-opus-4.5": {
"name": "claude-opus-4.5"
},
"anthropic/claude-opus-4.1": {
"name": "anthropic/claude-opus-4.1"
},
"gemini-2.5-pro": {
"name": "gemini-2.5-pro"
},
"gpt-5.1": {
"name": "gpt-5.1"
},
"gpt-5.1-codex": {
"name": "gpt-5.1-codex"
},
"openai/gpt-5.1-codex-max": {
"name": "openai/gpt-5.1-codex-max"
},
"openai/gpt-5": {
"name": "openai/gpt-5"
},
"openai/gpt-5-codex": {
"name": "openai/gpt-5-codex"
},
"gpt-5-nano": {
"name": "gpt-5-nano"
}
}
}
}
}
Important: Replace sk-YOUR_API_KEY_HERE with your actual PayPerQ API key from ppq.ai/api-docs.
5. Launch OpenCode and Select Your Model
Start OpenCode in your terminal or desktop app. To view all available PayPerQ models, use the /models command:
/models

You'll see all the PPQ models listed under the "ppq" provider. Select the model that best fits your coding task.
6. Verify Your Setup
Once you start using OpenCode with PayPerQ models, you can verify that requests are being processed by checking your usage history at ppq.ai/account-activity.
Available Models
The configuration includes all Zen-recommended models that are available through PayPerQ:
- Claude Models: Sonnet 4.5, Opus 4.5, Haiku 4.5, and more
- GPT Models: GPT-5.1, GPT-5.1 Codex, GPT-5 Codex Max
- Gemini: 2.5 Pro
- Specialized Coding Models: Qwen3 Coder, Grok Code Fast
- Thinking Models: Kimi K2 Thinking
- And more!
Each model has been tested and verified to work with OpenCode through PayPerQ's API.
Get the Most Recent Models
Want to create your own configuration with the latest models? You can fetch the most up-to-date list of available models directly from PayPerQ's API:
View all available models:
curl https://api.ppq.ai/v1/models
This endpoint returns a JSON list of all currently available models on PayPerQ. You can use this to:
- Check for new models - See what's been added since this guide was published
- Build custom configs - Create your own
opencode.jsonwith specific models you want - Stay updated - Always have access to the latest AI models as they're released
Let AI Update Your Configuration Automatically
The easiest way to keep your opencode.json file up-to-date is to ask an AI model on PPQ to do it for you! Here's how:
-
Visit the models API endpoint in your browser: https://api.ppq.ai/v1/models
-
Copy the entire JSON response from the browser page (Ctrl+A or Cmd+A to select all, then copy)
-
Go to ppq.ai and start a new chat with any AI model
-
Paste this prompt along with the models data:
I have this list of models from the PPQ API:
[PASTE THE JSON RESPONSE HERE]
Please create an OpenCode configuration file using this EXACT structure. For each model in the API response, extract ONLY the "id" field and add it to the models section:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ppq": {
"npm": "@ai-sdk/openai-compatible",
"name": "ppq",
"options": {
"baseURL": "https://api.ppq.ai",
"apiKey": "sk-YOUR_API_KEY_HERE",
"includeUsage": true
},
"models": {
"z-ai/glm-4.6": {
"name": "z-ai/glm-4.6"
},
"anthropic/claude-sonnet-4": {
"name": "anthropic/claude-sonnet-4"
},
"gpt-5.1-codex": {
"name": "gpt-5.1-codex"
}
}
}
}
}
CRITICAL: Each model entry must have the model ID as BOTH the object key AND the "name" property value. Do NOT include any other fields from the API response (like "object", "created", "owned_by", etc.). ONLY use the "id" field.
Process ALL models from the API response in this exact format.
- The AI will generate a complete configuration with all current models
- Copy the result and save it as
opencode.jsonin your OpenCode config folder - Replace
sk-YOUR_API_KEY_HEREwith your actual API key from ppq.ai/api-docs
This method ensures you always have access to the newest models without manually updating the configuration!
Or download the pre-configured file with all current models (as of December 18, 2025):
Download opencode.json with all current models
Note: This file includes all models available at the time of publication. For the most up-to-date model list, use the AI method above or check the API endpoint directly.
Tips for Best Results
- Choose the right model: Use specialized coding models like
qwen/qwen3-coderorgpt-5.1-codexfor programming tasks - Monitor your usage: Check your PayPerQ dashboard to track API usage and costs
- Experiment: Different models excel at different tasks—try a few to find your favorite
Problems?
Please contact us through the customer communication chatbot in the bottom right or in our telegram channel!