sh.stellarium.inference.claude.Sonnet.
How to call a model
Calling a model looks like calling any other function. Every inference function takes amaxTokens argument, the most output tokens the call may produce:
AskClaude.req
/v1/run endpoint like any other request:
value or error; token counts stay between the nodes and the operator. A single request can mix model calls with any other resource on the network and use their results together.
What a call costs
A call’s charge, in micro-USD, is its token counts times the model’s advertised rates, rounded up:maxTokens output tokens. Afterwards you pay for the tokens actually used, never more than that ceiling. With Sonnet at $2.50 per million input tokens and $10.50 per million output tokens, a 1,000-token prompt with maxTokens: 400:
Raising your spending limit
Your node refuses any inference call whose ceiling is over itsinferenceCostLimitMicroUsd, which defaults to costLimitMicroUsd ($0.01). Larger models or longer outputs can go over it, so raise it if you need to:
.env
Finding models
Inference functions are listed byGET /v1/resources on every node, with kind: "inference" and their per-token payment manifest, so you can compare rates before calling anything.
How to set up a model
If you can run a model, or call one you have access to, you can offer it on Stellarium. You write two pieces of code: the function that runs the model, and an estimator that counts a call’s input tokens. Discovery, billing and payouts are handled by the network.1
Run a node
Follow the Quickstart to set up a node. Hosting a paid function also needs Your organization is paid for every call, so set up payouts on the platform first. Until then, calls to your paid functions are refused. See Getting paid.
OPERATOR_URL set, and the node enrolled in your organization with an enrollment token from the Stellarium Platform. See Configuration..env
2
Declare an inference function
An inference function is declared like any other function on a resource, with a few additions:
kind: "inference"marks it as an inference function.- A
maxTokens: int32parameter, which the caller uses to cap output tokens. The function can take any other parameters too. execreports usage by returning{ value, usage: { inputTokens, outputTokens } }.- A per-token
paymentManifest, if the function is paid, withinputCostMicroUsdPerMillionTokensandoutputCostMicroUsdPerMillionTokensinstead ofcostMicroUsd. Either rate can be0. - An
estimateInputTokens(args)estimator, if the function is paid. It runs only on your node, so it can call a token-counting API such as Anthropic’s.
sonnet.ts
3
Register it and start
Register the resource before The node checks inference functions when it starts, and
start, as with any other resource:server.ts
start throws if one is missing maxTokens, or is paid and lacks per-token rates or an estimator. An inference function without a paymentManifest is free: it still needs maxTokens, but no estimator.GET /v1/resources and route calls to it. Every paid call arrives with a voucher that covers it, so inference never runs unpaid. For how vouchers are verified and charged, see Inference functions.