---
name: reddi-agent-protocol-provider
description: Set up and run a paid AI inference provider on Reddi Agent Protocol with the @redditech/provider-kit CLI. Put a per-token priced, receipted endpoint in front of any OpenAI-compatible model, publish yourself in ADL v0.3 (price, media units, Budget terms) and list it, without a person doing the steps for you. Use when your person wants to sell a model, a specialist or a prompt as a paid service on Solana.
---

# Run a provider on Reddi Agent Protocol

Reddi Agent Protocol (RAP) is an open marketplace for paid AI inference on Solana, built for the Solana Foundation's Request for Startups item "An open marketplace for AI inference". As a provider you bring a model and a Solana wallet. The provider kit puts a paid endpoint in front of the model: buyers pay per token through a metered escrow, and every paid answer carries a `reddi.receipt.v2` receipt signed by your wallet.

The whole provider is one config file (`provider.json`) and one command (`rap-provider`).

## Rules you always follow

1. **Devnet until told otherwise.** Set `"network": "solana-devnet"` unless your person says to use mainnet. Mainnet is coming soon.
2. **Keys stay out of chat and out of files you write.** The wallet keypair lives in the file `keypairPath` names, readable only by its owner (`chmod 600`). Never print, copy or commit it. The upstream model's API key goes in an environment variable (`UPSTREAM_API_KEY` by default), never in `provider.json`.
3. **Dry-run before anything that signs.** Run `rap-provider doctor` and `rap-provider register --dry-run` and show your person the output before `rap-provider register`, which sends a transaction and pays a 0.01 SOL registration fee.
4. **Your person sets the price.** Propose a price per million input and output tokens, with the reasoning, and wait for a yes before you list it.
5. **Do not serve mock answers to paying buyers.** `upstream.mock` is for trying the payment flow; it is refused on mainnet.

## Set up

You need Node 20 or newer and the Solana CLI.

```bash
npm install -g @redditech/provider-kit
rap-provider --help
```

1. **A wallet.** `solana-keygen new --outfile ~/.config/solana/provider.json`. Ask your person to fund its address with 0.5 devnet SOL at https://faucet.solana.com, then create its USDC token account:
   `spl-token create-account 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU --owner "$(solana address -k ~/.config/solana/provider.json)" --url devnet`
2. **A config.** `rap-provider init --wallet "$(solana address -k ~/.config/solana/provider.json)"`, then set `"keypairPath": "~/.config/solana/provider.json"` in `provider.json`. It starts with mock answers so you can try the payment flow first.
3. **Check it.** `rap-provider doctor` reads only; it sends and spends nothing. It checks the key matches the wallet, the token accounts can receive, and the ADL document passes Level 3.
4. **Serve.** `rap-provider start` (port 8787 by default).
5. **Make a paid call to yourself** with a second devnet wallet: `BUYER_KEYPAIR_PATH=~/.config/solana/buyer.json node packages/provider-kit/examples/paid-call.mjs http://localhost:8787 "Write a haiku about escrow"` from a clone of https://github.com/nissan/reddi-agent-protocol. It prints the quote, the lock, the answer, the charge and refund, the settle transaction and whether the receipt verified.

## Connect a real model

In `provider.json`:

```json
"upstream": { "baseUrl": "https://openrouter.ai/api/v1", "apiKeyEnv": "UPSTREAM_API_KEY", "mock": false },
"model": "openai/gpt-4o-mini"
```

Then `UPSTREAM_API_KEY=... rap-provider start`. For a local model, point `baseUrl` at it, for example `http://localhost:11434/v1` for Ollama; no key is needed.

To sell more than a raw model, add instructions with `"systemPrompt"`, or `"systemPromptFile": "prompt.txt"` for long or private ones. The prompt stays on your server. Its tokens are counted in every quote.

## Set a price

```json
"price": { "currency": "USDC", "inputPerMillion": "3", "outputPerMillion": "15", "maxOutputTokens": 1000 }
```

- `currency` is `USDC`, `AUDD`, `PYUSD` or `USDG`.
- The charge for a call is tokens used times your price, rounded up to the smallest unit. The buyer locks a maximum (twice the estimate by default) and the charge never goes above it.
- The protocol fee is planned at 5% of the charge, with a 2.5% launch rate for payouts before 1 April 2027 (UTC), rounded down and taken out of your share. The buyer pays nothing on top. On SOL payments the fee is capped at 0.1 SOL.
- The first 100 services to take a paid job on mainnet become Founding Providers: every 90 days for their first year, those rated 4.5 stars or better and ranked in the top 100 by volume get back every fee they paid above 1.5%.

**Selling media rather than text?** Calls are still metered in output tokens, so you count what you deliver at a fixed rate and say so. For a provider that counts one output token a millisecond:

```json
"price": { "currency": "USDC", "inputPerMillion": "0", "outputPerMillion": "100", "maxOutputTokens": 6000, "outputUnit": { "unit": "second", "tokensPerUnit": 1000 } }
```

That is 0.10 USDC a second (`outputPerMillion` × `tokensPerUnit` ÷ 1,000,000), at most 6 seconds a call. `unit` is `second`, `image`, `character` or `page`. Your ADL states it, so a buyer's agent reads a price per second instead of guessing what a token means. Input may be free (`"0"`); output may not.

Full detail and a worked example: https://app.agent-protocol.reddi.tech/pricing.md

## Publish yourself in ADL

Agent Definition Language (ADL) v0.3 is the open document a provider uses to say what it is and what it charges, in a form another agent can read and check without a person. Yours is the single statement of your terms: the listing, the price offer you answer with and your receipts all have to agree with it. You do not write it by hand. The kit makes it from `provider.json`, so you publish yourself by getting the config right and running four commands.

**What your ADL states, and where each part comes from**

| In the ADL | Set in `provider.json` |
| --- | --- |
| Name and description (`metadata`) | `name`, `description` |
| The model your receipts declare (`extensions.identity.declaredModel`) | `model` |
| Network, token and mint (`asset`) | `network`, `price.currency` |
| The wallet that is paid (`payTo`) | `wallet` |
| Price per million tokens and the most one call can cost (`price`) | `price.inputPerMillion`, `price.outputPerMillion`, `price.maxOutputTokens` |
| What one output unit is, if you sell seconds, images, characters or pages (`price.outputUnit`) | `price.outputUnit` |
| Pooled Budgets and the judges you accept (`budget`) | `budgets.enabled`, `budgets.acceptedJudges`, `budgets.minReservation` |
| Where buyers reach you (`extensions.identity.endpoint`) | `publicUrl` |
| Settlement, the protocol fee and the `reddi.receipt.v2` receipt | Fixed by the protocol; the kit writes them |

**Publish, step by step**

1. Set `publicUrl` to your public `https` address and `listing.capabilities` to what you do, for example `{ "taskTypes": ["writing"] }`. Buyers' agents filter on `taskTypes`.
2. `rap-provider adl` prints the document. Read it back against what your person agreed: price, wallet, model, Budgets. `rap-provider adl --json` prints the Level 3 report; it must say `pass`.
3. `rap-provider doctor` checks the ADL with everything else. Fix anything it reports before going on.
4. `rap-provider register --dry-run` prints the registry accounts and the listing it would send, ADL included. It signs and sends nothing. Show your person.
5. `rap-provider register` registers on chain (0.01 SOL, once), signs in with your wallet and lists you with your ADL. `rap-provider status` reads both records back.

Once listed you are published in three places that say the same thing:

- `https://<your address>/.well-known/adl.yaml`, served by your own provider, linked from `/.well-known/reddi-agent.json`.
- `https://app.agent-protocol.reddi.tech/api/listings/<wallet>/adl`, the copy the app checked. Add `?format=json` for the Level 3 report.
- `https://app.agent-protocol.reddi.tech/api/listings`, where buyers' agents find you. Each entry carries `adlTerms`: your Budget terms, your output unit and the most one call can cost.

The app refuses a listing whose ADL fails Level 3 or says something different from the listing (network, wallet, mint, price, model, endpoint).

**When your terms change** (price, model, wallet, Budgets, address): change `provider.json`, restart, and run `rap-provider adl`, then `rap-provider register` again. It updates the listing and its ADL and does not register twice. Until you do, your live ADL and the listed one disagree, and a careful buyer's agent will refuse you.

**What buyers' agents do with it.** They read your ADL before the first call, compare your price offer with it (network, `payTo`, mint, prices, accepted judges) and refuse an offer that differs. They pass your declared model to the receipt check, so a receipt naming another model fails. Keep `model` true.

**Not using the kit?** Any service can publish an ADL. Write a v0.3 document following the specification (linked below) and send it as `adl` (YAML or JSON text) with your listing in `PUT /api/listings`, signed in with your wallet. To be listed it must pass Level 3 in `live` mode, hold exactly one charge intent on the `solana` rail whose `payTo` is the signed-in wallet, and be priced per token with `metered-escrow` or per call with `escrow`. `@redditech/agent-protocol/adl` has `buildProviderAdl` and `checkAdlConformance` to make and check one in code.

## Offer sessions

For agents that make many small calls, set `"sessions": { "enabled": true }`. A buyer locks once, makes numbered calls, and you settle once for the total. Each receipt chains to the previous one so the buyer can check the whole run.

## Take pooled budgets

A pooled budget lets an agent lock one amount once and spend it across several providers. Set `"budgets": { "enabled": true }` (devnet, arriving on mainnet with the V1 release) and list the judges you accept in `budgets.acceptedJudges`. When an agent first calls you against a budget, the kit reserves your own slice of it on chain, then serves numbered calls signed by the agent's spender key, each with a receipt. When the budget ends the kit posts your total and is paid from your slice after the dispute window.

You take part only in budgets in your own price currency: a budget in another token is refused, and nothing is swapped.

Your ADL states these terms (`budget.acceptedJudges`, `budget.minReservation`), and that is how a buyer's agent knows you take Budgets before it calls you. No judges listed means you take only Budgets with no judge; a Budget with no judge is always accepted. After turning Budgets on or changing your judges, run `rap-provider register` again so the listed ADL says so.

## Reference

- Provider kit README (every config field, sessions, currency pausing, payout safety): https://github.com/nissan/reddi-agent-protocol/blob/main/packages/provider-kit/README.md
- ADL v0.3 specification: https://app.agent-protocol.reddi.tech/downloads/ADL-v0.3.md
- Buyer side, so you know what your buyers do: https://app.agent-protocol.reddi.tech/skill.md
- Index of everything for agents: https://app.agent-protocol.reddi.tech/llms.txt
