DEV Community

Cover image for Earn and spend USDC on inference
Christopher Poulsen
Christopher Poulsen

Posted on

Earn and spend USDC on inference

If your app or harness talks to three model providers, you have three accounts, three API keys, three billing dashboards, and three sets of rate limits to babysit. If you want to offer a model, you need your own signup flow, key issuance and billing before anyone can pay you.

We've been building Stellarium, a decentralized network where anyone can host an API and get paid for every call. This post is about the newest piece: running AI inference on it. Models become ordinary resources on the network, callers pay per token in USDC, and nobody needs to set up an account.

A model is just a resource

On Stellarium, every API is a resource hosted by a node. A resource has a name, like com.example.Weather, and a list of functions programs can call. Nodes advertise their resources to peers, and any node can route a call to whoever hosts the resource.

An AI model fits the same shape. A provider wraps the model in a resource with a function that takes a prompt and returns text. For example, sh.stellarium.inference.claude.Sonnet exposes Claude Sonnet through a message function.

That means AI gets everything the network already does: discovery by name, routing between peers, results that carry either a value or an error, and payment with no signup or keys.

Calling a model

Requests on Stellarium are written in RequestScript. Calling a model looks like calling a function. The only difference is maxTokens is a required parameter. This allows the caller and provider to work out a fair price.

request AskClaude {
  const sonnet: sh.stellarium.inference.claude.Sonnet

  const reply = sonnet.message(prompt: "Write a haiku about Oslo", maxTokens: 200)
  if (reply.error != null) {
    return reply.error.message
  }

  return reply.value
}
Enter fullscreen mode Exit fullscreen mode

The node does the rest: it finds the node hosting the model, gets a price estimate, checks it against your spending limit, and pays for the call. If the model fails, your script gets an error it can handle rather than a dead request.
Since a model is just another resource, one request can mix a model call with anything else on the network (a weather lookup, a Regex validation) and combine the results.

The hard part: paying per token, fairly

Most paid functions on Stellarium charge a flat fee per call. That doesn't work for inference, because cost depends on input and output tokens. There's a trust problem in both directions:

  • The caller can't know the output length ahead of time, and doesn't want to sign a blank check.
  • The provider doesn't want to burn GPU time (or its own API credits) on a call that won't be paid.
  • Nobody should have to trust the provider to report whatever token count it likes. AI-based functions need a new function type: inference functions. Inference functions are priced at a rate per million input tokens and a rate per million output tokens.

Every paid call goes through six steps:

  1. Estimate. The caller's node asks the provider for an estimate. The provider counts the input tokens and returns maxAmount: the cost of those input tokens plus maxTokens of output.
  2. Check. The caller recomputes maxAmount from the advertised rates and refuses the call if it's over its configured limit.
  3. Sign. The caller signs an inference voucher carrying maxAmount, both rates and maxTokens, and sends it with the call.
  4. Verify. The provider checks that the voucher's rates and maxTokens match, re-runs its estimate, and answers 402 if the voucher doesn't cover it. Inference never runs unpaid.
  5. Report. After the call, the provider sends the voucher and actual token counts to the operator. Output is capped at maxTokens.
  6. Settle. The operator verifies the signature and charges actual usage at the signed rates, never more than maxAmount, settling on Solana through an escrow.

The caller agrees to a ceiling up front and pays only for what was used. The provider knows the call is covered before spending anything.

Why this matters for agents

Agents have a great use-case for Stellarium. An agent that wants a second model, a cheaper model for a subtask, or a specialized model someone else fine-tuned shouldn't need a human to sign up, paste an API key and attach a card. On Stellarium it calls the resource by name, its node enforces a hard spending ceiling per call, and the payment is settled automatically. All through USDC on Solana.

Try it

Payments on Stellarium go live this Thursday, October 22nd, 2026. Stellarium is open source and early. Questions, comments and pull requests are all welcome.

https://stellarium.sh

Top comments (0)