API_KEY. API clients remove both. An organization creates an API client for one node on the Stellarium Platform, exchanges it for a short-lived run token, and calls the node’s POST /v1/run with that token.
- On your own nodes, runs are free, just as with the node’s API key.
- On another organization’s listed node, runs are paid from your organization’s prepaid balance: the node’s price per script token, plus every paid function the script calls.
Listing a node
A listed node appears on the platform’s Explore page, and any organization can create API clients for it. On the Nodes page, an admin sets each node’s listing:
Listing needs the node’s URL. A node reports its
BASE_URL to the operator whenever it starts with OPERATOR_URL set. When you list it, the operator calls {BASE_URL}/v1/self and lists the node only if it answers with the node’s public key. If the node later reports a different URL, it is unlisted until you list it again.
You earn the token charges and your paid functions’ prices, less the 20% platform fee, like any paid call. A priced node’s organization must have finished payout setup before its runs are accepted.
Creating an API client
On the API clients page, or from a node’s Create API client button on Explore, an admin chooses:
The client’s ID (
cli_...) and secret (cs_...) are shown once: the operator keeps only a hash of the secret. Revoke a client on the same page, and it can’t get new tokens or start new runs.
Running a script
Exchange the client for a run token at the operator’s token endpoint. It is the OAuth 2.0 client credentials grant, so most OAuth libraries work too:Response
Script tokens
A node prices scripts by the tokens they execute. A token is one lexer token of RequestScript: an identifier, keyword, number, operator or punctuation mark, or a whole string literal however long. Only what runs is counted:- An
ifcounts each condition it evaluates, and then only the branch it takes. Untaken branches cost nothing. - The side of
&&or||that a short circuit skips is not counted. - The
requestdeclaration and the body’s outer braces are free.
ceil(tokens × price / 1,000,000) micro-USD. See the RequestScript docs for the exact rules.
How a billed run works
- The node checks the run token’s signature against the operator’s published keys, and that it is addressed to this node and unexpired.
- The node asks the operator to authorize the run. The operator computes the script’s most tokens, and holds up to the client’s maximum per run on your available balance. The hold is less when your balance or monthly cap leaves less, but it always covers the script’s tokens at the node’s price.
- The script runs. Each paid function it calls, on another node or on this one, is paid with a voucher that names the run. The operator moves the call’s amount from the run’s hold to the call, so a run can never cost more than its hold. Calls are charged at their manifest prices, exactly as in Payments.
- The node captures the run with the tokens the script executed. You’re charged for them at the node’s price, and the rest of the run’s hold is released. A script that fails partway is charged for what it executed. A run that the node itself fails to complete is released and costs nothing.
Your runs and what each was charged appear on the Usage page under Runs spent, and the paid calls they made under Spent. A listed node’s organization sees them under Runs earned and Earned.
Operator routes
A run token’s claims are
iss (stellarium), sub (the client ID), aud (the node’s public key), org (the paying organization), iat, exp and jti.
Limits
- Token counts come from the node. The operator caps them at the most the script can execute, which it computes itself, but within that cap it trusts the node, as it trusts usage reported by inference functions.
- Revoking takes effect at the next run. A revoked client’s existing token still verifies at the node until it expires, but billed runs are refused because the operator checks the client on every run.
- Price changes apply to new runs. A run is charged at the price the node had when the run was authorized.