Magpie
Add RunAPI to Magpie and select its models for Claude Code or Codex.
Install and prepare
Install the latest stable release from Magpie. Follow the official reference for platform-specific installation. Install Claude Code or Codex separately.
Create a dedicated standard API key in the Authentication Guide. Copy a model ID and its supported protocol from the Model Catalog. Back up your agent configuration before changing providers.
Add an OpenAI-compatible provider
Use this branch for models that support Chat Completions. Replace both placeholders before running the command. The url= base ends in /v1; Magpie appends /chat/completions.
magpie provider add runapi-chat url=https://runapi.ai/v1 key=YOUR_RUNAPI_API_KEY models=YOUR_RUNAPI_MODEL_ID
Add an Anthropic-compatible provider
Use this branch for models that support Anthropic Messages. The anthropic= base has no /v1; Magpie appends /v1/messages.
magpie provider add runapi-anthropic anthropic=https://runapi.ai key=YOUR_RUNAPI_API_KEY models=YOUR_RUNAPI_MODEL_ID
Choose one branch first. Magpie rejects a second provider with the same key. To keep both providers, create a different dedicated RunAPI key for each. Keep the RunAPI keys in Magpie, outside your repositories.
Assign a model to an agent
Start Magpie and keep its gateway running. In the Agents screen, select Claude Code or Codex and choose the model under your RunAPI provider. The CLI offers the same selection. Run one command with your chosen provider and model ID.
magpie serve
In another terminal, select the model.
magpie models
magpie claude runapi-chat/YOUR_RUNAPI_MODEL_ID
magpie codex runapi-chat/YOUR_RUNAPI_MODEL_ID
For the Anthropic branch, replace runapi-chat with runapi-anthropic. Magpie uses provider/model locally and forwards the original model ID to RunAPI. The agent connects to Magpie on 127.0.0.1:3425; it does not need the RunAPI key. Codex uses the local Responses interface, which does not imply that RunAPI receives a Responses request. These provider branches select Chat Completions or Messages on the RunAPI side.
Verify your setup
Check the provider and selected model with these commands, then start a new agent session and send a short prompt.
magpie version
magpie providers
magpie claude
magpie codex
Confirm the expected model and request in RunAPI usage records. A successful agent response alone does not establish which provider handled it. Magpie’s Test models, Detect APIs, and provider test can send inference requests.
The configuration and local routes were checked with Magpie 0.1.1307 and Claude Code 2.1.295 on Linux. Both provider branches returned a fixed local fixture response. Real RunAPI inference and Codex inference were not tested for this guide. Check the selected model’s protocol and tool support before using it for agent work.
Troubleshoot
If Magpie reports that a provider is already added with that key, reuse that provider or use a different dedicated key for the second branch. This error was reproduced locally.
A local fixture run reproduced no model list with connection refused when the configured server was stopped. Check the address and server availability, then use models= with the exact model ID. Keep Magpie running while agents use its local gateway.
Claude Code reported unrecognized_model for the fixture IDs but still returned the fixture response. Check the original model ID and Claude Code’s model configuration if you see this warning. The fixture did not validate context limits, tool calls, or model quality.
Restore your previous setup
Restore the agent before removing its provider. These commands return each agent to its previous configuration.
magpie claude default
magpie codex default
magpie provider rm runapi-chat
magpie provider rm runapi-anthropic
Remove only the providers you added. Revoke the dedicated RunAPI keys if you no longer need them. Restore your backup if you made additional manual configuration changes.
Next steps
See LLM API Quickstart for RunAPI’s public protocol examples and the Model Catalog for supported models. Magpie’s official reference also lists a Grok Build integration; Grok Build was not tested for this guide.