# Credits

Credits are counted, and signed callers now spend them. Nothing here is
money: credits cannot be bought or sold, and the only move is merging a
wallet into another of your own. This page says what is
counted and where it is going.

## What the hub counts now

- **Every front-door key** has a plan. `internal` keys (MeshKore's own
  agents and projects) are free and have no cap. `metered` keys have a
  daily token quota (prompt plus answer); past it the door answers 429
  `insufficient_quota` until 00:00 UTC. `demo` is the open demo link.
- **Every lending machine** earns from what its cluster's head reports:
  each token the cluster processes, prompt or answer, is shared among its
  members in proportion to the part of the model each one holds. So what a
  request costs is what the machines that served it earn. A machine kept out
  of every copy earns nothing.
- `GET https://llm.meshkore.com/pool/v1/credits` with your key
  (`Authorization: Bearer ...`) shows your usage, plan and today's quota.
  A node signs the same request with its identity key to see what it
  earned.

## Signed callers pay in credits

A caller that signs with its own key (`MeshKore-Sig`, see
[the agent](agent.md)) has an account named by that key:

- 1 credit = 1 token: a request costs its prompt tokens plus its answer
  tokens;
- a welcome package of 50,000 credits, once per person (about thirty to
  forty requests like the ones our own agents send);
- plus what the node with the same key earned by lending, added by itself.
  Lending is the only way to get more: nothing is for sale;
- with none left the answer is `402 insufficient_credits`.

Its balance is `GET /pool/v1/credits`, signed the same way. Issued keys
(above) keep their plans. A lender's own machine uses the model on its
loopback endpoint without spending.

## Wallets

A wallet is a key pair; its public key, written `mkw_` and 64 hex
characters, is its name. There is nothing to register.

- A machine earns into the wallet named in its settings (`wallet` in
  `pool.toml`, `--wallet`, or `HYVERK_WALLET`). With none, it earns into its
  own key. Several machines can name the same wallet.
- A machine only ever holds the wallet's public id. The secret stays with
  the person, off every machine that lends.
- A request signed by a wallet's key spends from it.
- One welcome package per wallet and per person, however many machines
  name it.
- To change wallet, the old one signs a merge into the new one
  (`POST /pool/v1/credits/merge`, `{"to": "mkw_..."}`): everything it
  earned moves and its machines earn into the new one from then on.
  Welcome credits stay where they were given. There is no other way to
  move credits.
- A machine may name a different wallet once a day.
- A lost wallet secret cannot be recovered and what it holds cannot be
  spent. Point the machines at a new wallet and they keep earning.

## The idea

- Lending earns credits in proportion to the tokens a machine helps
  produce: its share of the split times the tokens served while it was a
  member. A machine at 90% earns more than the same machine at 25%.
- Using the pool spends credits per token.
- The node identity key is the account. Nothing else to sign up for.

## What has to be solved first

- **Proof of work done.** The hub sees which machines were members and how
  many tokens the head served, but a member could claim memory it does not
  give, or return wrong results. Counting needs checks a cheater cannot
  fake.
- **Many identities.** Free keys make it cheap to look like many machines.
- **Where the ledger lives.** A hub-kept ledger is simple but needs trust in
  the hub. A shared ledger (a blockchain, or signed receipts any party can
  check) is an option being looked at, not a decision.

## Not promised

No credit has a cash value. Running a node
today is a contribution to a test.
