---
title: Magpie | RunAPI
description: Add RunAPI to Magpie and select its models for Claude Code or Codex.
url: https://runapi.ai/docs/resources/tool-integrations/magpie.md
canonical: https://runapi.ai/docs/resources/tool-integrations/magpie
locale: en
---

> HTML version: https://runapi.ai/docs/resources/tool-integrations/magpie
> Site index for agents: https://runapi.ai/llms.txt

# Magpie

## Install and prepare

Install the latest stable release from [Magpie][1]. Follow the [official
reference][2] for platform-specific installation. Install Claude Code or
Codex separately.



[1]: https://usemagpie.ai
[2]: https://github.com/yetone/magpie/blob/main/docs/reference.md

Create a dedicated standard API key in the [Authentication
Guide](https://runapi.ai/docs/guides/authentication.md). Copy a model ID and its supported
protocol from the [Model Catalog](https://runapi.ai/models). 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`.

```shell
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`.

```shell
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.

```shell
magpie serve
```

In another terminal, select the model.

```shell
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.

```shell
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.

```shell
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](https://runapi.ai/docs/guides/llm-api/quickstart.md) for RunAPI's
public protocol examples and the [Model Catalog](https://runapi.ai/models) for supported
models. Magpie's official reference also lists a Grok Build integration;
Grok Build was not tested for this guide.

---

## More from RunAPI

- [Home](https://runapi.ai/.md)
- [Model Catalog](https://runapi.ai/models.md)
- [Pricing](https://runapi.ai/pricing.md)
- [Providers](https://runapi.ai/models)
- [Documentation](https://runapi.ai/docs/guides)
- [SDKs](https://runapi.ai/sdk.md)
- [CLI](https://runapi.ai/cli.md)
- [MCP Server](https://runapi.ai/mcp.md)
- [x402](https://runapi.ai/x402.md)
- [Claude Code vs Cursor](https://runapi.ai/claude-code-vs-cursor.md)
- [Cursor API Setup](https://runapi.ai/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/contact.md)
- [Contact](https://runapi.ai/contact.md)
- [Terms](https://runapi.ai/terms.md)
- [Privacy](https://runapi.ai/privacy.md)
- [Site index for agents](https://runapi.ai/llms.txt)

Contact: contact@runapi.ai

## Structured data

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "en",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "en",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/icon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "en",
    "@type": "TechArticle",
    "headline": "Magpie",
    "description": "Add RunAPI to Magpie and select its models for Claude Code or Codex.",
    "url": "https://runapi.ai/docs/resources/tool-integrations/magpie",
    "mainEntityOfPage": "https://runapi.ai/docs/resources/tool-integrations/magpie"
  }
]
```
