# Run Codex through AnyRouter

> anyr codex signs you in, stores one sk-ar- key, and launches Codex against AnyRouter's OpenAI-compatible endpoint.

One command signs you in and launches Codex

**Slug**: `codex`  
**URL**: https://anyrouter.dev/use-cases/codex  
**Markdown**: https://anyrouter.dev/use-cases/codex.md  
**Short link**: https://anyrouter.dev/u/codex  

## Why use this

Codex expects an OpenAI key and base URL. Using other models or one balance across tools means editing its environment by hand.

## Set it up

1. Install the anyr CLI.
2. Run anyr codex. First run signs you in or pastes an sk-ar- key.
3. Pin a model or effort with --model and --effort. Anything after -- goes to Codex.

## Code

### anyr CLI

```bash
curl -fsSL https://anyr.dev/cli.sh | bash
anyr codex
```

### Env wrapper

```bash
export OPENAI_BASE_URL="https://anyrouter.dev/api/v1"
export OPENAI_API_KEY="$ANYROUTER_API_KEY"
```

## Related

- [claude-code](https://anyrouter.dev/use-cases/claude-code)
- [coding-agents](https://anyrouter.dev/use-cases/coding-agents)
- [opencode](https://anyrouter.dev/use-cases/opencode)
