OpenCode Integration
Use NanoGPT with OpenCode, the open source AI coding agent for your terminal.One-Click Setup (Mac/Linux)
Run this command in your terminal:- Open your browser to authenticate with NanoGPT (or let you paste an API key)
- Configure OpenCode to use NanoGPT as your AI provider
- Set up popular models like Claude Sonnet 4.5, Claude 4.5 Opus, GPT 5.2, Gemini 3 Flash (Preview), Gemini 3 Pro, GLM 4.7
Manual Setup
If you prefer to configure manually:1. Create the auth file
Add your NanoGPT API key to~/.local/share/opencode/auth.json:
2. Create the config file
Create~/.config/opencode/.opencode.json:
Usage
After setup, start OpenCode:Switching Models
Use the/model command inside OpenCode to switch between models, or edit the model field in your .opencode.json:
Available Models
The setup script preconfigures these models:| Model ID | Description |
|---|---|
nanogpt/claude-sonnet-4-5-20250929 | Claude Sonnet 4.5 (default) |
nanogpt/claude-opus-4-5-20251101 | Claude 4.5 Opus |
nanogpt/openai/gpt-5.2 | GPT 5.2 |
nanogpt/google/gemini-3-flash-preview | Gemini 3 Flash (Preview) |
nanogpt/gemini-3-pro-preview | Gemini 3 Pro |
nanogpt/zai-org/glm-4.7 | GLM 4.7 |
Adding More Models
Add any of NanoGPT’s 250+ models to themodels section in your config:
Requirements
- OpenCode installed (
curl -fsSL https://opencode.ai/install | bash) - A NanoGPT account with API access
Troubleshooting
OpenCode not finding the config? OpenCode searches for config in this order:./.opencode.json(current directory)$XDG_CONFIG_HOME/opencode/.opencode.json$HOME/.opencode.json
~/.local/share/opencode/auth.json (as an object with type and key) and that the key name matches the provider ID (nanogpt).