Call LLMs and media models through Phase Router (router.phase.xyz), an OpenAI-compatible router with about 400 models, the price of each call in the answer and a signed receipt. Use when the user want
OpenAI-compatible API for about 400 models. One key, one base URL; every answer says which model ran and what it cost.
https://router.phase.xyz/v1PHASE_API_KEY (starts with phk_), sent as Authorization: Bearer $PHASE_API_KEY. If the user has none, sendthem to https://router.phase.xyz/dashboard; never invent or print a key.
/v1/messages (same key as x-api-key or Bearer).https://mcp.ai.phase.xyz/mcp (tools list_models, quote, chat, embed,receipt, key, session).
GET https://router.phase.xyz/v1/models (no key needed). Each item has id and a phase object:input_per_m / output_per_m (micro-USD per 1M tokens: divide by 1,000,000 for USD), per_call (micro-USD fixed
fee per call), kind (chat, embeddings, image, image_edit, video, tts, asr, rerank, music),context_window, max_output, capabilities (tools, json_mode, vision, streaming, ...).
auto (the router picks the cheapest model that can do the task well), eco (cheapest),premium (strongest) or agentic (tool use, long multi-step work).
capabilities include them.curl -s https://router.phase.xyz/v1/chat/completions \
-H "Authorization: Bearer $PHASE_API_KEY" -H "content-type: application/json" \
-d '{"model": "auto", "messages": [{"role": "user", "content": "Summarize this in one line: ..."}]}'
import os
from openai import OpenAI
client = OpenAI(base_url="https://router.phase.xyz/v1", api_key=os.environ["PHASE_API_KEY"])
r = client.chat.completions.create(model="auto", messages=[{"role": "user", "content": "Hello"}])
print(r.choices[0].message.content)
Other endpoints with the same key: /v1/embeddings, /v1/images/generations, /v1/images/edits, /v1/audio/speech,/v1/audio/transcriptions, /v1/rerank, /v1/videos.
usage.cost: what the call cost, in USD.phase.routed_model: the model a class (auto, eco, ...) sent the request to; phase.provider: the host thatserved it; phase.price_micro_usd: the charge; phase.task_id: the receipt id.
https://router.phase.xyz/receipts/<task_id>.GET https://router.phase.xyz/v1/key with the key.| Status | Meaning | Do |
|---|---|---|
| 401 invalid_api_key | key wrong or disabled | ask the user for a valid key |
| 402 insufficient_balance | key out of balance | tell the user to add balance in the dashboard |
| 402 with accepts and no key | x402 quote: the request can be paid per call in USDT | pay only if the user set up a wallet and agreed to the price (see below) |
| 429 daily_cap_reached | key's daily cap reached (resets 00:00 UTC) | wait or raise the cap |
| 503 overloaded | retry later | back off and retry |
A request without Authorization gets 402 with accepts[0]: scheme (upto), network (eip155:1015, Phase
L1), amount (price ceiling in micro-USDT), asset, payTo, extra.taskId, extra.quote. The client signs an
EIP-712 authorization (ReceiveWithAuthorizationUpTo, nonce = extra.taskId) and repeats the same request with thePAYMENT-SIGNATURE header; the charge is the actual cost, never above amount. Never sign without the user's
consent and a spending limit. Working example: https://github.com/devcells/phase-router-skills/tree/main/examples/x402
input_per_m / output_per_m before long jobs).Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.