@phantomcodes/cli1.1.1
AI inference for your coding agents. Route models, control spending, and fund your workspace.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
Your agents have expensive taste.
Connect your agents to Phantom AI. Route models, control spending and pay from your terminal.
Phantom CLI (phantom) by Phantom AI · Docs · npm
Use Phantom AI's router to send requests to cheaper models when your rules allow it, or choose a model yourself. Connect the coding agents you already use, fund their inference and control spending—all from your terminal.
Install the agent skill
The phantom-ai skill ships in the package. phantom setup installs it for
each agent it finds:
npm i -g @phantomcodes/cli
phantom setup --agent claude
The skill covers workspace setup, funding, spending controls and model routing. Skill docs
Let your agent set it up
Copy this into Claude Code, Codex, Cursor or another agent with terminal access:
Help me set up phantom for AI inference through Phantom AI.
Check that I have Node 24 or newer, then install @phantomcodes/cli if needed.
Run phantom setup --agent <my agent> to install the phantom-ai skill, and read it.
Check for an existing workspace and saved keys before changing anything.
If I need to connect, start phantom login and let me complete the device approval.
Check the workspace balance. Ask which coding agent I use and what budget I want,
then create a named workspace key with that cap.
Ask whether I want to connect my existing agent for future runs or use a temporary
connection for one run. For saved setup, preview the changes with phantom setup --dry-run
and show them to me before applying the setup I approve. Make sure any spending cap
is on the key my agent will actually use. Ask before adding funds or starting paid
inference. Keep keys and recovery credentials out of chat. Finish with the command
to launch my agent, and explain how to undo any saved setup.
Connect your existing agents
Keep using your coding agent, with Phantom AI handling its inference and model routing. Connect it using your saved key:
npm i -g @phantomcodes/cli
phantom login
phantom setup
Used pai, this CLI's old name? Run phantom setup once after you install. Until
then, Claude Code and the shell block pai set up still call pai, and phantom
prints a reminder.
The Phantom CLI detects supported agents, previews the configuration changes, then asks before applying them. It connects their model calls to Phantom AI and wires up the saved key. Restart your agent, or open a new terminal, to use the connection.
Codex, Claude Code, opencode, Continue, Goose, Aider, GitHub Copilot CLI and Cline support saved setup. Cursor gets instructions for its settings screen; pi gets the agent skill. Agent-specific setup.
Preview without changing files with phantom setup --dry-run. The Phantom CLI keeps backups;
undo the changes with phantom setup --restore.
Connect for one run
npm i -g @phantomcodes/cli
phantom login
phantom workspace fund --amount 10 --card
phantom workspace status
phantom codex
Both setup options require Node 24+ and your coding agent installed. Connect, fund your
workspace, then launch Codex (phantom codex), Claude Code (phantom claude),
pi (phantom pi), or any other compatible agent.
Set up other agents.
Login opens a device approval page and saves a key privately. Funding opens checkout; check your workspace balance after payment. Agent runs use temporary configuration and print spending afterward. Your existing agent configuration stays in place.
Already have a Phantom key? Use phantom login --paste to save it locally.
Fund your workspace
Add credit first, then let your agents spend from the shared balance:
phantom fund --amount 10 --card
phantom fund --amount 10 --coin usdc
Credit is available after the payment is verified. Check balance anytime with phantom balance.
Give each agent a budget
Create a key with its own cap, sharing your workspace balance:
phantom keys create --save coding --limit 5
phantom claude --key coding
phantom keys list
phantom keys set --id <key-id> --limit 10
Workspace key controls include total limits, periodic budgets and spending
rates. Use the full key ID from phantom keys list when changing or revoking a key.
Revoking a workspace key preserves workspace funds.
Choose what answers
Let the router choose a model for auto requests. Your policy can prefer cheaper
models and change the choice for tool use, reasoning or spending limits:
PHANTOM_KEY_NAME=coding phantom route set --models <model-a>,<model-b>
PHANTOM_KEY_NAME=coding phantom route test --table
Prefer a specific model? Select it in your agent. Policies that apply only to
auto leave explicit model choices alone.
Routing covers conditions, fallback and conversation affinity.
phantom-1 picks a tier for each request: economy, standard or frontier. Your key's
lineup picks the model in each tier, and a fallback model to try when it fails:
phantom lineup --table
phantom lineup set --frontier <model> --economy-fallback <model>
phantom lineup reset
lineup shows the choices for each tier. default in place of a model puts that tier
back to its default.
See what a key spent, and what phantom-1 saved against always running its frontier
model:
phantom spend --table
phantom spend --from 2026-09-01 --to 2026-09-30
phantom spend --workspace --table
The dates are UTC days and the default is this month. --workspace lists every key in
your workspace by name; without it you see the key you run as. The saving is an
estimate: the same tokens at the frontier model's price today.
A Pro ($20 a month) or Max ($100 a month) plan pays for phantom-1 calls up to an amount
of model cost in any 7 days, then your credit pays:
phantom plan --table
phantom plan pro
phantom plan manage
plan shows the key's plan and how much of the last 7 days it has paid for. plan pro
and plan max print a Stripe Checkout link that puts the plan on this key and open it.
plan manage opens Stripe's billing page, where the card changes, the plan switches and
it cancels. A named model, not phantom-1, still spends credit.
Commands
| Task | Commands |
|---|---|
| Connect | phantom login, phantom logout |
| Connect existing agents | phantom setup, phantom setup --dry-run, phantom setup --restore |
| Run inference | phantom claude, phantom codex, phantom pi |
| Fund and check spending | phantom workspace fund, phantom workspace status, phantom balance, phantom spend |
| Manage workspace keys | phantom keys create, phantom keys set, phantom keys rotate, phantom keys revoke |
| Manage local copies | phantom keys saved, phantom keys save, phantom keys rm |
| Route models | phantom route |
| Pick phantom-1's models | phantom lineup, phantom lineup set, phantom lineup reset |
Put phantom flags before agent arguments; use -- to separate them:
phantom codex --key coding -- exec "explain this repository"
Commands print JSON; --table renders supported results for people. Agent
commands inherit the terminal and print a spending summary on stderr.
Exit codes: 0 success, 1 error, 2 rejected key; agent runs return the agent's exit code.
Advanced tools, integrations and legacy commands
phantom --help shows the main workflows. phantom --help --all and the
interface reference cover every command.
- Signed receipts: check which model answered with
phantom verify. - Funding credit:
phantom fundand checking payments. - Saved secrets: macOS Keychain or private files; guest recovery uses
phantom workspace exportandphantom workspace import. - Key selection and API address: environment overrides and shell integration.
The older phantom key commands still work.
phantom keys list reads the workspace; phantom keys saved lists local copies.
phantom keys show prints a secret for shell integration; keep it out of chat and logs.
Development and contributing
npm ci
npm run typecheck
npm run build
npm run coverage
npm run docs
node scripts/gen-docs.mjs --check
See CONTRIBUTING.md and SECURITY.md.
phantom is proprietary, under the Phantom Proprietary License. It lets you install and run phantom to use Phantom AI, the hosted API it calls.