# Service Router > Pay-per-call access to APIs for AI agents. One account and one payment key pay any service listed here, with credits: a prepaid USD balance, with no on-chain fee per call. Agents without an account can pay each call with x402 or MPP instead. Sellers list an API and get paid per call. Every service is called at `https://pay-servicerouter.agents.bakingbad.dev/service//`. A call without payment answers `402 Payment Required`, listing every way to pay: credits, x402 (USDC on Base and Solana, USDM on Cardano), and MPP (stablecoins on Tempo). Credits are the default: sub-cent prices work, and nothing is signed per call. ## Start with credits Ask your user before each of these steps. 1. Sign up: `curl -X POST https://api-servicerouter.agents.bakingbad.dev/v1/accounts`. The answer has a `masterKey`. Save it at once in a file only your user can read (`chmod 600`), and never paste it into a chat, a log, or a URL. 2. Tell your user that a lost master key can't be recovered: there is no email recovery yet. Ask them to keep a copy somewhere safe. 3. Create a payment key with limits your user agrees to, and use only that key for calls. Keep the master key with your user: ```sh curl -X POST https://api-servicerouter.agents.bakingbad.dev/v1/keys \ -H "Authorization: Bearer $SERVICEROUTER_MASTER_KEY" \ -H "Content-Type: application/json" \ -d '{"label": "my-agent", "dailyBudget": "5", "maxPrice": "0.05"}' ``` The answer's `key` is shown once. Limits: `dailyBudget` (USD a day, $5 by default), `allowance` (USD in total), `maxPrice` (USD per call), and `expiresAt`. 4. Top up: `GET https://api-servicerouter.agents.bakingbad.dev/v1/account` gives a `topupUrl`. Give it to your user: it shows the deposit address (USDM on Cardano). Start calling once the deposit is credited. While `topupUrl` is null, deposits aren't open for the account yet: pay with x402 or MPP instead. ## Call a service ```sh curl https://pay-servicerouter.agents.bakingbad.dev/service// -H "Authorization: Bearer $SERVICEROUTER_PAYMENT_KEY" ``` - A paid answer carries `Servicerouter-Receipt: id="pay_…", amount="0.001", currency="USD"`. You pay only for `2xx` answers. - `GET https://pay-servicerouter.agents.bakingbad.dev/_/key` with the payment key shows its limits, what it spent, and what's left. - `https://api-servicerouter.agents.bakingbad.dev/v1/balance` and `https://api-servicerouter.agents.bakingbad.dev/v1/payments` take the master key. - Errors are `{"error": {"code", "message"}}`: `insufficient_balance`, `key_budget_exceeded`, `key_allowance_exceeded`, `key_price_limit` (`402`); `invalid_key`, `wrong_key_type` for a master key (`401`); `rate_limited` (`429`, with `Retry-After`); `upstream_unavailable` (`503`, not charged). ## Pay without an account - **x402:** the `402` has a `PAYMENT-REQUIRED` header (x402 v2). Sign one of its options with an x402 client and retry with `PAYMENT-SIGNATURE`. The answer carries `PAYMENT-RESPONSE`. - **MPP:** the `402` has a `WWW-Authenticate: Payment` Tempo charge. Sign it in pull mode with an MPP client, such as `mppx`, and retry with `Authorization: Payment …`. The answer carries `Payment-Receipt`. Send the retry at once: the signed transaction expires within about 25 seconds. Either way, the payment settles only after a `2xx` answer. A failed call costs nothing. ## Find services - [The catalog](https://servicerouter.agents.bakingbad.dev/discover.md): every service, with prices, payment methods, and stats. Filter with `?category=`, `q=`, `method=`, `maxPrice=`, and `sort=`. - Each service has its own instructions: `llms.txt`, an Agent Skill, and an OpenAPI document whose server is its pay URL. Its page links them: `https://servicerouter.agents.bakingbad.dev/discover/.md`. ## Skills - [Buyer skill](https://servicerouter.agents.bakingbad.dev/skills/servicerouter-buyer/SKILL.md): everything above, step by step. - [Seller skill](https://servicerouter.agents.bakingbad.dev/skills/servicerouter-seller/SKILL.md): list an API and get paid per call, with plain HTTP calls. ## Optional - [Everything in one file](https://servicerouter.agents.bakingbad.dev/llms-full.txt): this guide, both skills, and the catalog. - [For agents](https://servicerouter.agents.bakingbad.dev/agents.md): what agents can read here. --- --- name: servicerouter-buyer description: Pay for API calls through Service Router with credits, x402, or MPP. Use when the user wants an agent to call a paid API listed on Service Router, to sign up, to create a payment key with limits, or to check spending. --- # Service Router for buyers Service Router lets an agent call paid APIs, paying per call. Credits, a prepaid USD balance, are the default. Every listed service is at `https://pay-servicerouter.agents.bakingbad.dev/service//`. Ask the user before you sign up, create a key, or spend anything. ## 1. Sign up once ```sh curl -s -X POST https://api-servicerouter.agents.bakingbad.dev/v1/accounts > servicerouter-account.json chmod 600 servicerouter-account.json ``` The answer's `masterKey` controls the account. Keep it in that file, readable only by the user. Never print it, paste it into a chat, or put it in a URL. Tell the user: a lost master key can't be recovered, because there is no email recovery yet. Ask them to keep a copy safe. ## 2. Create a payment key for the agent Agents call with a payment key, never the master key. Agree on its limits with the user first. ```sh MASTER_KEY=$(jq -r .masterKey servicerouter-account.json) curl -s -X POST https://api-servicerouter.agents.bakingbad.dev/v1/keys \ -H "Authorization: Bearer $MASTER_KEY" \ -H "Content-Type: application/json" \ -d '{"label": "my-agent", "dailyBudget": "5", "allowance": "20", "maxPrice": "0.05"}' ``` The `key` in the answer is shown once: store it like the master key. `GET https://api-servicerouter.agents.bakingbad.dev/v1/keys` lists keys and what each spent. `PATCH https://api-servicerouter.agents.bakingbad.dev/v1/keys/` changes limits. `DELETE https://api-servicerouter.agents.bakingbad.dev/v1/keys/` revokes one. ## 3. Top up `GET https://api-servicerouter.agents.bakingbad.dev/v1/account` (master key) returns `topupUrl`. Give it to the user: it shows a deposit address for USDM on Cardano. Credits arrive once the deposit confirms. `GET https://api-servicerouter.agents.bakingbad.dev/v1/balance` shows the balance. While `topupUrl` is null, deposits aren't open yet: pay per call with x402 or MPP (step 5). ## 4. Find and call a service - The catalog: `https://servicerouter.agents.bakingbad.dev/discover.md`, filtered with `?q=`, `category=`, `method=`, `maxPrice=`, and `sort=popular|price|newest|success`. - A service: `https://servicerouter.agents.bakingbad.dev/discover/.md` lists its routes and prices, and links its `llms.txt`, Agent Skill, and OpenAPI document. ```sh curl https://pay-servicerouter.agents.bakingbad.dev/service// -H "Authorization: Bearer $SERVICEROUTER_PAYMENT_KEY" ``` - Only `2xx` answers are charged. Each carries `Servicerouter-Receipt` with the payment ID and amount. - `GET https://pay-servicerouter.agents.bakingbad.dev/_/key` (payment key) shows the key's limits and what's left. - `402` codes: `insufficient_balance` (top up), `key_budget_exceeded` (wait for midnight UTC, or ask the user to raise it), `key_allowance_exceeded`, `key_price_limit`. - `401 wrong_key_type`: a master key was sent. Use the payment key. - `429 rate_limited`: wait for `Retry-After` seconds. - `503 upstream_unavailable`: the service failed. You weren't charged. ## 5. Without an account: x402 or MPP A call without a credential answers `402` with every option: - `PAYMENT-REQUIRED`: x402 v2. Sign an option with an x402 client, and retry with `PAYMENT-SIGNATURE`. - `WWW-Authenticate: Payment`: an MPP Tempo charge. Sign it in pull mode, with `mppx` for example, and retry with `Authorization: Payment …` at once: the transaction expires within about 25 seconds. Payment settles only after a `2xx` answer. --- --- name: servicerouter-seller description: List an API on Service Router and get paid per call by agents. Use when the user wants to sell access to their API, write or submit a Service Router config, rotate upstream secrets, roll back a revision, or check earnings. --- # Service Router for sellers Service Router sells per-call access to an HTTP API. Agents call `https://pay-servicerouter.agents.bakingbad.dev/service//` and pay with credits, x402, or MPP. The platform forwards each paid call to the upstream with the seller's credentials, which agents never see, and pays the seller. Show the user the config before you submit it. Never print secret values. ## 1. Sign up once ```sh curl -s -X POST https://api-servicerouter.agents.bakingbad.dev/v1/accounts > servicerouter-account.json chmod 600 servicerouter-account.json ``` The `masterKey` controls the account and its earnings. Keep it in that file. A lost master key can't be recovered yet. ## 2. Write the config One YAML file describes the service, its upstream, its prices, and its payout: ```yaml servicerouter: version: "1" service: id: my-prices # [a-z0-9-], unique, in the URL forever title: My Prices summary: Live token prices by symbol description: | The latest price, 24-hour change, and volume for any token symbol. category: crypto/prices # One ID of the catalog's categories: `GET https://api-servicerouter.agents.bakingbad.dev/v1/catalog` lists them tags: [prices, tokens] discoverable: true # Listed in the x402 Bazaar. false keeps it out payouts: default: asset: cardano-usdm # Paid out in USDM on Cardano address: addr1... # Your Cardano address payments: default: amount: "0.001" # USD per call upstreams: - baseUrl: https://api.example.com openapi: https://api.example.com/openapi.json # Or an inline `paths` object auth: main-key credentials: main-key: type: http scheme: bearer # Authorization: Bearer secret: upstream-key # A name: the value is sent separately ``` - Each operation of the OpenAPI document becomes a route at the same path. `routes.` sets a route's own `payment`, a `target` path, or `enabled: false`. - An amount of `"0"` makes a route free. - `service.discoverable` (default `true`) lists each paid route in the x402 Bazaar, Coinbase's catalog of x402 APIs, once a payment for it settles through Coinbase's facilitator: its 402 carries the route's description, input and output schemas, and response example from your OpenAPI document. `discoverable: false` keeps the service out of it. Changing it makes a new revision, like any change. ## 3. Submit it with its secrets ```sh MASTER_KEY=$(jq -r .masterKey servicerouter-account.json) jq -n --rawfile config service.yaml --arg key "$UPSTREAM_KEY" \ '{config: $config, secrets: {"upstream-key": $key}}' | curl -s -X PUT https://api-servicerouter.agents.bakingbad.dev/v1/services/my-prices \ -H "Authorization: Bearer $MASTER_KEY" \ -H "Content-Type: application/json" \ --data-binary @- ``` - `201` creates the service, `200` updates it, and each change is a new revision. - `400 invalid_config` lists every problem with its path, line, and column. Fix them and submit again. - Secrets are sealed and bound to the host they go to. A config with no new secrets can be sent as YAML, with `Content-Type: application/yaml`. ## 4. Check and manage it - `GET https://api-servicerouter.agents.bakingbad.dev/v1/services`: your services. `GET https://api-servicerouter.agents.bakingbad.dev/v1/services/my-prices`: one service. - `GET …/revisions` lists revisions. `POST …/rollback` with `{"revision": 3}` makes an older one active. - `PUT …/secrets/` with `{"value": "…"}` rotates one secret. - `GET …/earnings`: calls, earnings by payment method, the fee, pending payout, and the next payout date. - Its public page: `https://servicerouter.agents.bakingbad.dev/discover/my-prices`. ## 5. Prove you own the upstream Before a service goes live, each upstream host serves `/.well-known/servicerouter.json` with the service's token. `GET https://api-servicerouter.agents.bakingbad.dev/v1/services//status` shows what's missing. A change of payout address waits until every host lists its confirmation token. This check is arriving: follow the status endpoint's answer. ## 6. Get paid Earnings are paid out monthly, on the 1st, in USDM on Cardano to the payout address, once they reach the minimum. Agents find the service in the catalog, in its generated `llms.txt`, Agent Skill, and OpenAPI document, and in the x402 Bazaar unless `discoverable` is `false`. --- # Discover services Every service listed on Service Router, called at `https://pay-servicerouter.agents.bakingbad.dev/service//` and paid per call. Filter with `?category=`, `q=`, `method=` (credits, x402, mpp), `maxPrice=` (USD), and `sort=` (popular, price, newest, success). > Sample data: shown until the Platform API serves it. These services and numbers aren't real. ## Categories - [AI](https://servicerouter.agents.bakingbad.dev/discover.md?category=ai) (`ai`): 3 - [Image generation](https://servicerouter.agents.bakingbad.dev/discover.md?category=ai/image-generation) (`ai/image-generation`): 1 - [Speech](https://servicerouter.agents.bakingbad.dev/discover.md?category=ai/speech) (`ai/speech`): 1 - [Translation](https://servicerouter.agents.bakingbad.dev/discover.md?category=ai/translation) (`ai/translation`): 1 - [Blockchain](https://servicerouter.agents.bakingbad.dev/discover.md?category=blockchain) (`blockchain`): 2 - [Node RPC](https://servicerouter.agents.bakingbad.dev/discover.md?category=blockchain/rpc) (`blockchain/rpc`): 1 - [Data](https://servicerouter.agents.bakingbad.dev/discover.md?category=data) (`data`): 2 - [Company data](https://servicerouter.agents.bakingbad.dev/discover.md?category=data/companies) (`data/companies`): 1 - [Geocoding](https://servicerouter.agents.bakingbad.dev/discover.md?category=data/geo) (`data/geo`): 1 - [Finance](https://servicerouter.agents.bakingbad.dev/discover.md?category=finance) (`finance`): 3 - [Currency exchange](https://servicerouter.agents.bakingbad.dev/discover.md?category=finance/fx) (`finance/fx`): 1 - [Market data](https://servicerouter.agents.bakingbad.dev/discover.md?category=finance/market-data) (`finance/market-data`): 2 - [Search](https://servicerouter.agents.bakingbad.dev/discover.md?category=search) (`search`): 2 - [Weather](https://servicerouter.agents.bakingbad.dev/discover.md?category=weather) (`weather`): 1 ## Services - [Chain RPC Gateway](https://servicerouter.agents.bakingbad.dev/discover/chain-rpc.md): JSON-RPC for Ethereum, Base, and Solana, paid per call. From $0.0005 a call; Credits; 1.19M calls in 30 days, 99.7% success. - [Crypto Prices](https://servicerouter.agents.bakingbad.dev/discover/crypto-prices.md): Spot prices for 5,000 tokens, aggregated across exchanges. From $0.0001 a call; Credits; 906.3K calls in 30 days, 99.5% success. - [Ticker Quotes](https://servicerouter.agents.bakingbad.dev/discover/ticker-quotes.md): Real-time stock quotes and daily price history. From $0.0005 a call; Credits, x402, MPP; 451.6K calls in 30 days, 99.9% success. - [Skycast Weather](https://servicerouter.agents.bakingbad.dev/discover/skycast-weather.md): Current conditions and 14-day forecasts for any city. From $0.001 a call; Credits, x402, MPP; 243.65K calls in 30 days, 99.8% success. - [Geo Lookup](https://servicerouter.agents.bakingbad.dev/discover/geo-lookup.md): Addresses to coordinates and back. From $0.0005 a call; Credits; 130.1K calls in 30 days, 99.2% success. - [Web Search Lite](https://servicerouter.agents.bakingbad.dev/discover/web-search-lite.md): Web search results with titles, links, and snippets. From $0.003 a call; Credits, x402, MPP; 129.5K calls in 30 days, 98.5% success. - [FX Rates](https://servicerouter.agents.bakingbad.dev/discover/fx-rates.md): Exchange rates for 170 currencies, and conversion. From $0.0002 a call; Credits; 126.9K calls in 30 days, 99.9% success. - [Block Explorer API](https://servicerouter.agents.bakingbad.dev/discover/block-explorer.md): Bitcoin addresses, transactions, and blocks. From $0.001 a call; Credits, x402; 80.1K calls in 30 days, 99.5% success. - [Lingua Translate](https://servicerouter.agents.bakingbad.dev/discover/lingua-translate.md): Machine translation between 90 languages. From $0.001 a call; Credits, x402; 67.8K calls in 30 days, 99.7% success. - [Pixel Forge](https://servicerouter.agents.bakingbad.dev/discover/pixel-forge.md): Text-to-image generation and 4x upscaling. From $0.02 a call; Credits, x402, MPP; 30.5K calls in 30 days, 98.2% success. - [News Digest](https://servicerouter.agents.bakingbad.dev/discover/news-digest.md): Headlines by topic, with one-paragraph summaries. From $0.002 a call; Credits, x402, MPP; 27.3K calls in 30 days, 99.0% success. - [Voice Scribe](https://servicerouter.agents.bakingbad.dev/discover/voice-scribe.md): Speech to text in 40 languages, and text to speech. From $0.005 a call; Credits, x402, MPP; 25K calls in 30 days, 99.1% success. - [Company Facts](https://servicerouter.agents.bakingbad.dev/discover/company-facts.md): Firmographics for any company domain. From $0.01 a call; Credits, x402, MPP; 12.1K calls in 30 days, 96.2% success.