Capabilities
Spending controls
How Lyber holds and charges credit, and the limits you can put on a request, a key and an account.
How a request is charged
- Hold. Before the model starts, Lyber reserves the most the request could cost: the model's full context at the input rate, plus
max_tokensat the output rate. If your available credit can't cover it, the request gets402 insufficient_creditand nothing runs. - Charge. When the request finishes, Lyber charges the tokens the model reported (
prompt_tokens× input rate +completion_tokens× output rate, rounded up to the micro-dollar) and releases the rest of the hold.
A smaller max_tokens means a smaller hold. If you leave it out, the hold covers the model's maximum output.
Cap a single request
Send max_cost_micro_usdc, a whole number of micro-dollars (1,000,000 = $1), to refuse any request whose hold would be larger. A refused request gets 402 request_budget_exceeded before anything runs or is held.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://lyber-paid-acceptance-gateway-production.up.railway.app/v1",
api_key=os.environ["LYBER_API_KEY"],
)
response = client.chat.completions.create(
model="minimax-m3.1-flash-abliterated",
messages=[{"role": "user", "content": "Summarize this changelog."}],
max_tokens=2048,
extra_body={"max_cost_micro_usdc": 300_000}, # at most $0.30
)The Responses API applies a $1 ceiling to each request unless you send your own.
Preview a hold
POST /v1/credits/reservation-preview with a model and max_tokens returns the hold a request would need and whether your balance and limits cover it. It never runs the model or charges anything. See Credits.
Monthly limits
Set a monthly spending limit for the whole account and for each key under Limits in the dashboard. A request that would pass either one gets 402 account_spend_limit_exceeded or 402 key_spend_limit_exceeded. Keys can read their limits with GET /v1/credits/limits but can never raise them.