> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Portkey CLI

> Wire Claude Code, Codex, or Cursor to Portkey — gateway routing, MCP servers, and team skills in one command.

The Portkey CLI sets up AI coding agent integrations from your terminal.

```bash theme={"system"}
npx portkey
```

Or install globally:

```bash theme={"system"}
npm install -g portkey
portkey
```

**Requirements:** Node.js 18+ · [Portkey account](https://app.portkey.ai) with at least one provider in [Model Catalog](https://docs.portkey.ai/docs/product/model-catalog.md)

> [card] [Source & full changelog](https://github.com/Portkey-AI/cli)
>
> github.com/Portkey-AI/cli

***

## What gets configured

Running `npx portkey` (or `npx portkey setup`) opens an interactive wizard. Choose which agent to configure:

* **Claude Code** — sets `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, and `ANTHROPIC_CUSTOM_HEADERS` in `~/.claude/settings.json`
* **Codex** — writes `base_url`, `PORTKEY_API_KEY`, and `wire_api` into `.codex/config.toml`
* **Cursor (skills only)** — syncs team skills to `.cursor/skills/`

### Gateway routing

```json Claude Code (~/.claude/settings.json) theme={"system"}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.portkey.ai",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_PORTKEY_API_KEY",
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-provider: @your-provider"
  }
}
```

```toml Codex (~/.codex/config.toml) theme={"system"}
model_provider = "portkey"
model = "@your-provider/gpt-4o"

[model_providers.portkey]
name = "Portkey"
base_url = "https://api.portkey.ai/v1"
env_key = "PORTKEY_API_KEY"
```

Every request appears in [Portkey Logs](https://app.portkey.ai) with cost, latency, and full trace detail.

![Claude Code and Codex requests logged in Portkey with cost and latency](https://mintcdn.com/portkey-docs/28zFZsk9XnqGMtZ6/images/cost.png?fit=max\&auto=format\&n=28zFZsk9XnqGMtZ6\&q=85\&s=03cb0b4f80f27963dcc2d8d0c9bc2dd8)

### MCP servers

Fetches your workspace's MCP integrations and writes them to each agent's config — your Portkey API key included in headers automatically.

* **Claude Code** — written to `~/.claude.json` / `.mcp.json`
* **Codex** — written as `[mcp_servers.*]` blocks in `.codex/config.toml`

> [!NOTE]
>
> MCP integrations requiring upstream OAuth (e.g. Linear, Slack) are flagged during setup. For Claude Code, run `/mcp` to complete the OAuth flow. For Codex, run `codex mcp login <server-name>`.

### Team skills

Syncs [Prompt Partials](https://docs.portkey.ai/docs/product/prompt-engineering-studio/prompt-partial.md) from Portkey as `SKILL.md` files to the agent's skills directory. Every developer runs one command and gets the same instructions.

| Agent | Skills directory |
| - | - |
| Claude Code | `.claude/skills/` |
| Codex | `.agents/skills/` |
| Cursor | `.cursor/skills/` |

![Team skills stored as versioned prompt partials in Portkey](https://mintcdn.com/portkey-docs/nDVSDSKLH6tq-r5C/images/product/prompts/prompt-library.png?fit=max\&auto=format\&n=nDVSDSKLH6tq-r5C\&q=85\&s=f941673dd2a66d159b8f01858c5e135f)

***

## Commands

| Command | What it does |
| - | - |
| `npx portkey` | Interactive menu (Setup Claude Code, Setup Codex, or Cursor skills-only) |
| `npx portkey setup` | Full setup wizard — gateway, MCP, skills |
| `npx portkey status` | Show current config, routing hints, and MCP counts |
| `npx portkey skills sync` | Pull Prompt Partials from Portkey → local `SKILL.md` trees |
| `npx portkey skills list` | List skills available in the workspace |
| `npx portkey mcp add` | Add MCP servers from the Portkey registry |

```bash theme={"system"}
npx portkey setup
npx portkey status
npx portkey skills sync
npx portkey mcp add
```

***

## Non-interactive setup (CI / scripts)

Pass `--yes` to skip all prompts and use flags directly:

```bash theme={"system"}
npx portkey setup \
  --yes \
  --portkey-key YOUR_PORTKEY_API_KEY \
  --provider @anthropic-prod \
  --skip-mcp \
  --skip-skills
```

Available flags:

| Flag | Description |
| - | - |
| `--yes` | Skip all prompts, accept defaults |
| `--portkey-key` | Portkey API key |
| `--provider` | Provider or Config slug (e.g. `@anthropic-prod`) |
| `--skip-mcp` | Skip MCP server configuration |
| `--skip-skills` | Skip skills sync |
| `--codex-wire-api` | Codex only: `chat` (default) or `responses` |

### Refresh skills in CI

```bash theme={"system"}
npx portkey skills sync --yes --agent claude
npx portkey skills sync --yes --agent codex
```

***

## Next steps

> [card] [Model Catalog](https://docs.portkey.ai/docs/product/model-catalog.md)
>
> Configure providers and model access in Portkey

> [card] [Portkey Configs](https://docs.portkey.ai/docs/product/ai-gateway/configs.md)
>
> Fallbacks, load balancing, and routing strategies

> [card] [Agent Skills](https://docs.portkey.ai/docs/guides/coding-agents/skills.md)
>
> Create and sync team skills to every developer's machine

> [card] [MCP Gateway](https://docs.portkey.ai/docs/product/mcp-gateway.md)
>
> Centralized auth and observability for MCP tool access

***

> [card] [Portkey is now PRISMA AIRS AI Gateway. See it in action.](https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey\&utm_medium=referral\&utm_campaign=prisma_airs\&utm_content=docs_nav#contact)
>
> Contact Us


## Related topics

- [Claude Code](https://docs.portkey.ai/docs/integrations/libraries/claude-code.md)
- [OpenAI Codex](https://docs.portkey.ai/docs/integrations/libraries/codex.md)
- [Skills Registry](https://docs.portkey.ai/docs/guides/coding-agents/skills.md)
- [Llama 3 on Portkey + Together AI](https://docs.portkey.ai/docs/guides/integrations/llama-3-on-portkey-+-together-ai.md)
- [Portkey with OpenAI Computer Use](https://docs.portkey.ai/docs/guides/use-cases/openai-computer-use.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.