Concepts

Credits

Credits are the unit for everything the platform does for you. What a call cost comes back with the call — measured, not estimated in your process.

usage on every resultprices from the server
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

What a call cost

const result = await assistant.generate({ inputs });
result.usage;
// { credits: 4, inputTokens: 38, outputTokens: 96 }

const turn = await api.models.turn({ model, messages });
turn.usage;
// { credits: 3, inputTokens: 1840, outputTokens: 77, thinkingTokens: 54 }

await agent.run({ message });
agent.usage;
// { credits, turns, toolCalls } — the whole run, tools included
result = assistant.generate(inputs=inputs)
result["usage"]
# {"credits": 4, "inputTokens": 38, "outputTokens": 96}

turn = api.models.turn(model=model, messages=messages)
turn["usage"]
# {"credits": 3, "inputTokens": 1840, "outputTokens": 77, "thinkingTokens": 54}

agent.run(message=message)
agent.usage
# {"credits", "turns", "toolCalls"} — the whole run, tools included
Do not add these up yourself

An agent run already counts the tools it paid for. Adding a tool's credits on top of the run total counts them twice.

Reading prices

Prices come from the server. Copying them into your code is how a displayed cost drifts from the charged one.

const prices = await api.catalogue();
// [{ model, service, provider, unit, credits,
//    creditsInput, creditsOutput,          // when billed per token
//    contextWindow, maxOutput,             // text models
//    cachedInputRate,                      // what a cached input token costs
//    resolution, audio,                    // media variants
//    deprecatedAfter }]

const row = prices.find((p) => p.model === "gemini-3.5-flash" && p.service === "text-to-text");
prices = api.catalogue()
# [{"model", "service", "provider", "unit", "credits",
#   "creditsInput", "creditsOutput",          # when billed per token
#   "contextWindow", "maxOutput",             # text models
#   "cachedInputRate",                        # what a cached input token costs
#   "resolution", "audio",                    # media variants
#   "deprecatedAfter"}]

row = next(p for p in prices if p["model"] == "gemini-3.5-flash" and p["service"] == "text-to-text")

unit tells you how to read credits

unitBilled by
1M tokenstokens, in and out separately — read creditsInput and creditsOutput
secondduration — video
1K charactersinput length — speech
imageone per image, varying by resolution
anything elsea flat amount per call

The balance

const { credits, pack } = await api.getUser();
user = api.get_user()
credits, pack = user["credits"], user["pack"]

The agent can read this itself with its account tool, which is free and costs no turn of thinking — worth allowing, so it checks instead of guessing.

Running out

A call that the balance will not cover is refused before the work starts, and nothing is charged.

try {
  await assistant.generate({ inputs });
} catch (err) {
  if (err instanceof NotEnoughCredits) {
    console.log(`needs ${err.required}, has ${err.available}`);
  }
}
try:
    assistant.generate(inputs=inputs)
except NotEnoughCredits as error:
    print(f"needs {error.required}, has {error.available}")

Bounding what a run can spend

An agent decides how many steps it takes, so the only real bound is a budget. It is checked before a tool runs, not after.

const agent = api.agents.create({
  runtime: "local",
  machine: pc,
  model: "gemini-3.5-flash",
  budget: 200,        // credits for this run
  maxSteps: 40,       // and a ceiling on turns
});
agent = api.agents.create(
    runtime="local",
    machine=pc,
    model="gemini-3.5-flash",
    budget=200,        # credits for this run
    max_steps=40,      # and a ceiling on turns
)