Inference Logoinference.sh

Billing

Manage team balance, credit top-ups, saved payment methods, and billing settings.

All endpoints require authentication. Use API key scopes billing:read (view balance and settings) and billing:write (checkout, charges, and settings updates).

Subscription — plan signup and Stripe subscription management


Money units

ContextUnitExample
GET /billing, GET /billing/balanceMicrocents (1 USD = 100,000,000)250000000 = $2.50
POST /billing/checkout, POST /billing/charge body amountCents (1 USD = 100)500 = $5.00 minimum top-up

Get billing account

GET /billing

Returns the team's billing account with cached balance.

Response

FieldTypeDescription
balanceint64Current balance in microcents
currencystringCurrency code (for example usd)
statusstringAccount status

Example:

bash
1curl https://api.inference.sh/billing \2  -H "Authorization: Bearer inf_your_key" \3  -H "X-API-Version: 2"

Get balance

GET /billing/balance

Recalculates balance from grants and usage, then returns the current value. Use this after checkout when status is processing, or when you need an authoritative balance.

Response

json
1{2  "balance": 2500000003}

balance is in microcents.


Service fee

GET /billing/service-fee

Returns the active service-fee configuration used for top-ups (default 5% + $0.30). Call before checkout or a saved-card charge to show users the full total including fee and tax.


Add credits

Two paths depending on whether a card is already on file.

MethodEndpointWhen to use
Stripe CheckoutPOST /billing/checkoutNo saved card, user picks a payment method, or delayed methods (ACH, SEPA)
Saved cardPOST /billing/chargeGET /billing/settings reports has_payment_method: true

Both paths apply the same service fee and tax rules, then credit balance on success.

Stripe Checkout

POST /billing/checkout — requires billing:write.

Body:

FieldTypeRequiredDescription
amountint64YesCredit to add, in cents (minimum 500 = $5)
success_urlstringYesRedirect URL after payment
cancel_urlstringYesRedirect URL if the user cancels

ResponsePaymentRecordDTO with status: "pending" and session_url for redirect. Line items include credit_amount, service_fee, and tax fields filled when checkout completes.

Complete checkout:

POST /billing/checkout/success — body: { "session_id": "<stripe_checkout_session_id>" }.

statusMeaning
completeBalance credited now; grant included
processingDelayed payment; balance credited when Stripe confirms (poll GET /billing/balance)

Credits apply exactly once — the success URL and Stripe webhooks share the same completion path.

Example:

bash
1curl -X POST https://api.inference.sh/billing/checkout \2  -H "Authorization: Bearer inf_your_key" \3  -H "Content-Type: application/json" \4  -H "X-API-Version: 2" \5  -d '{6    "amount": 2000,7    "success_url": "https://app.inference.sh/settings/billing?success=1",8    "cancel_url": "https://app.inference.sh/settings/billing"9  }'

Saved card charge

POST /billing/charge — requires billing:write.

Body:

FieldTypeRequiredDescription
amountint64YesCredit to add, in cents (minimum 500)

Success response:

json
1{2  "status": "complete",3  "grant": { }4}

Balance is credited immediately.

Errors (400, code charge_failed):

MessageCause
no saved payment methodUse checkout or save a card first
minimum top-up amount is $5amount < 500
payment failed: ...Stripe declined the charge

Billing settings

GET /billing/settings — requires billing:read.

Returns auto-recharge, alerts, invoice fields, and saved-card metadata.

FieldDescription
has_payment_methodWhether instant top-up (POST /billing/charge) is available
payment_method_labelDisplay label (for example Visa •••• 4242)
auto_recharge_enabledAuto top-up when balance drops below threshold
spending_limitTeam spending cap (microcents)
low_balance_thresholdAlert threshold (microcents)

POST /billing/settings — requires billing:write. Send only fields to update (BillingSettingsUpdateRequest).


Saved payment methods

EndpointMethodScopePurpose
/billing/payment-method/setupPOSTbilling:writeStripe Checkout to save a card
/billing/payment-method/successPOSTbilling:writeComplete setup (session_id in body)
/billing/payment-methodDELETEbilling:writeRemove saved card

Setup body: { "success_url": "...", "cancel_url": "..." }. Success body: { "session_id": "..." } — returns last4 and brand.

Users can also save a card during a balance checkout when Stripe shows “Save my info for future purchases.”


Payment history

GET /billing/payments — requires billing:read.

Lists payment records for the team (checkout sessions, charges, and status).


Insufficient balance

When a run would exceed available balance, the API may return 402 Payment Required with a message pointing to billing settings. This is separate from plan limit errors (limit_exceeded, feature_not_available) enforced by entitlements.

The belt and infsh CLIs surface billing URLs in error text for 402 responses.


we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.