Use Oh My Pi with Models Hub: models.yml Custom Provider
Edit Oh My Pi's ~/.omp/agent/models.yml to add Models Hub as a custom provider over the OpenAI-compatible protocol, with verification and error troubleshooting.
Oh My Pi (the omp command) is a terminal AI coding agent with built-in LSP, subagents, and browser tools, configured through ~/.omp/agent/models.yml for custom model providers. Add Models Hub there, and every chat and code edit inside omp uses your Models Hub balance for the model you choose. This page covers the connection only, not how to use Oh My Pi itself.
Three things you need
A Models Hub API key, the base URL https://modelsok.com/v1, and a model name. There's no one-click setup — Oh My Pi isn't one of the targets the Models Hub CLI supports.
Prerequisites
- Oh My Pi installed (the
ompcommand available). Usebun install -g @oh-my-pi/pi-coding-agent, or curl, Homebrew, Nix, or PowerShell — see omp.sh for options. - A Models Hub API key, created on the Tokens page. The token's group must have access to the models you plan to use.
Recommended models
| Use case | Model | Pricing | Live status |
|---|---|---|---|
| Everyday coding | claude-sonnet-4-6 | Price | Availability and latency |
| Harder reasoning and long tasks | gpt-5.6-luna | Price | Availability and latency |
| Cheap and fast for small edits | gpt-5.4-mini | Price | Availability and latency |
Model names are authoritative on the pricing page.
Setup
Step 1 — Set the environment variable
export MODELSOK_API_KEY="your-models-hub-api-key"Step 2 — Edit models.yml
Create or edit ~/.omp/agent/models.yml:
providers:
modelsok:
baseUrl: https://modelsok.com/v1
api: openai-completions
apiKey: MODELSOK_API_KEY
authHeader: true
models:
- id: claude-sonnet-4-6
name: Claude Sonnet 4.6
contextWindow: 200000
maxTokens: 128000
- id: gpt-5.4-mini
name: GPT-5.4 Mini
contextWindow: 128000
maxTokens: 16384Key fields
| Field | Description |
|---|---|
baseUrl | The base URL, ending in /v1 |
api | Protocol type; openai-completions for the OpenAI-compatible protocol — Oh My Pi also supports anthropic-messages and others |
apiKey | The name of an environment variable (no $ prefix); Oh My Pi looks for that env var first, and only falls back to treating the value as a literal key |
authHeader: true | Sends the resolved key as Authorization: Bearer <key> |
models[].id | Must exactly match the model name in the Models Hub console |
Reasoning models may need a compat override
If a reasoning model returns field names (like the reasoning-content field or the max_tokens parameter name) that differ from the standard OpenAI shape, add a compat block under that model entry to override them — see the official docs/models.md. Everyday usage usually doesn't need this; get the minimal config above working first, then adjust as needed.
Verify
Go to your project directory and launch with the model flag:
cd /path/to/your-project
omp --model modelsok/claude-sonnet-4-6Or start omp normally, then press Ctrl+P or type /model to switch to a model under modelsok. Send a test message; a normal reply means you're connected. Then open Usage logs in the Models Hub console; a request under your configured model name appears within seconds.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| Provider not found on startup | The path or YAML indentation in ~/.omp/agent/models.yml is wrong | Check the file path, and confirm indentation uses spaces, not tabs |
401 Unauthorized | MODELSOK_API_KEY isn't exported in the current shell, or apiKey has a typo | Check the environment variable, reopen the terminal, and retry |
| Model not found | models[].id doesn't match the Models Hub console | Check the name on the pricing page |
| Tool-call errors with a reasoning model | The reasoning-content field name doesn't match upstream | Override the relevant field in a compat block per the official docs |
omp models modelsok shows nothing | The config wasn't saved, or has a formatting error | Recheck the YAML syntax, then restart omp |
More in Troubleshooting.
FAQ
How is it billed? Per input and output token actually consumed, at the price on each model's pricing page; every request is itemized in usage logs.
How is this different from using the official APIs directly? Oh My Pi sends requests to the Models Hub gateway over the openai-completions protocol — you don't need a separate account with each vendor, and one key covers every model.
How do I switch models? Pass --model modelsok/<model-id> at launch, or press Ctrl+P to cycle, or type /model inside a session to open the picker.
Related
- CLI one-command setup: Claude Code, Codex, Gemini CLI and OpenClaw support one-click configuration
- Model pricing and model status
- Pi setup, OpenCode setup
Use Factory Droid CLI with Models Hub: BYOK Custom Models
Add a customModels entry pointed at Models Hub in Droid CLI's settings.json, with install commands, recommended models, and error fixes.
Use Pi with Models Hub: models.json Custom Provider
Edit Pi (pi-mono)'s ~/.pi/agent/models.json to add Models Hub as a custom OpenAI-compatible provider, with verification and error troubleshooting.