Coding agents like OpenCode are great, until you realise every one of them wants its own API keys. One for OpenAI, one for Anthropic, one for Google, sitting in config files on every laptop you code from. If you already run AI Engine, all those keys are already set up in WordPress. So why not use them from there? 🙂
That is exactly what the new Models API module in AI Engine Pro does. One key, every model you configured, and your provider keys never leave WordPress.
What the Models API does
It turns your WordPress site into an endpoint that speaks the OpenAI API. Any app that can talk to OpenAI can talk to it instead, and behind it you get the models of all your AI Engine environments: OpenAI, Anthropic, Google, Mistral, OpenRouter, xAI, Perplexity, OVH, and your custom ones.
- One key for everything. Your apps get a single Models API key. The real provider keys stay in WordPress.
- Every call is logged. Requests show up in Insights like any other AI Engine query, so you see exactly what an agent spent.
- Your limits apply. The same limits that protect your chatbot protect this.
- Streaming and tool calls work. That is what coding agents need, and it is what we tested.
Model names are written as environment/model, for example openai/gpt-5.4-mini or claude/claude-haiku-4-5. That way the same model in two environments (OpenAI directly and through OpenRouter, say) never gets mixed up.
It is not MCP
People will confuse the two, so let’s be clear. MCP lets an AI act on your WordPress site: write posts, clean media, read your analytics. The Models API does the opposite job: it lets apps use the AI models configured on your site. The key cannot read or change posts, users, settings or anything else in WordPress. Only the models.
Before you turn it on
This is the part most guides would skip. Please don’t 🙂
- It can get expensive, fast. Coding agents are hungry. With every request, OpenCode sends its instructions and the list of its tools, often more than 10,000 tokens, before your own message is even read. A small task like fixing one bug usually takes several requests, and a long session can take hundreds. Set a site-wide limit in Insights → Limits before you start. The calls run as the site administrator, and user limits skip administrators by default, so the site-wide limit is the only one that actually protects you.
- The key is a password for your AI credits. Anyone who has it can use every model on your site, as far as your limits allow. Keep it in an environment variable, never in a file you commit to Git. If it leaks, click Generate again: the old key stops working right away.
- It needs a capable host. Each reply keeps one PHP process busy until it ends, and agents often wait on long replies. Shared hosting usually offers only a few PHP processes, so your site can slow down while an agent works, and the host can cut long requests off. A VPS, or a host that allows long requests, works best. Some proxies also hold streamed replies until they are complete: it still works, it just feels less live.
- It needs HTTPS as soon as you use it outside your local network.
Turn on the Models API
You need AI Engine Pro. In Meow Apps → AI Engine, open the Modules tab and find the MCP & Agents block. Enable Models API and click Generate to create your key. If you don’t see the module, update AI Engine Pro first.

Two buttons appear next to it. Before you use it repeats the warnings above (read them once, really). How to use gives you the exact setup for your own site, which is what the next steps are based on.
Use your models in OpenCode, in three steps
1. Keep the key in an environment variable. That way it never ends up in a config file. On macOS and Linux, add this line to your shell profile (for example ~/.zshrc), with your key in place of your-key:
export AI_ENGINE_API_KEY="your-key"
On Windows, run this once in PowerShell, then open a new terminal:
setx AI_ENGINE_API_KEY "your-key"
2. Add the models to OpenCode. In How to use, pick one of your environments. AI Engine generates a block with the right URL, the key reference and all the models of that environment. Copy it into opencode.json, either in your project folder or in ~/.config/opencode/opencode.json to use it everywhere. It looks like this:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ai-engine-openai": {
"npm": "@ai-sdk/openai",
"name": "AI Engine (OpenAI)",
"options": {
"baseURL": "https://example.com/wp-json/mwai-openai/v1",
"apiKey": "{env:AI_ENGINE_API_KEY}"
},
"models": {
"openai/gpt-5.4-mini": {
"name": "GPT-5.4 Mini (OpenAI)",
"tool_call": true
}
}
}
}
}
Copy it from AI Engine rather than typing it: the model list and their limits are filled in for you. Do the same for each environment you want, and remove the models you will never use, it keeps the picker tidy.
3. Start coding. Run opencode in your project, type /models and pick one of the AI Engine models. The first start after a config change can take up to a minute, so don’t panic if it looks stuck.
Does it really work?
Yes, and not just “hello world”. We gave OpenCode a real multi-step task (create a script, run it, edit it, run it again) and it went through to the end with GPT-5.4 Mini, Claude Haiku 4.5, Gemini 3.5 Flash, Mistral Medium and Qwen on OVH. Streaming and tool calls worked with all of them.
My honest advice: start with a small, cheap model like GPT-5.4 Mini or Claude Haiku 4.5. For most everyday coding they are more than enough, and with the amount of tokens agents burn, the difference on your bill is huge.
Other apps
OpenCode is what most people will use this for, but any app that works with the OpenAI API can use the same key. Give it your base URL and a model name from the list:
https://example.com/wp-json/mwai-openai/v1
The endpoints are /models, /chat/completions and /responses (the last one only for OpenAI models). To check that everything works, this lists your models:
curl https://example.com/wp-json/mwai-openai/v1/models \
-H "Authorization: Bearer $AI_ENGINE_API_KEY"
To sum up
If you already pay for AI providers through AI Engine, the Models API lets you reuse all of it from your terminal, with one key, full logs and your own limits. Set that site-wide limit first, keep the key out of your repos, and make sure your host can take long requests. Then have fun, agents are a lot of fun 😉