Skip to main content

Billing Endpoints

Three Payment Paths

ModelsLab supports three payment flows for agents, depending on the level of automation required:

Get Stripe publishable key

Retrieve the Stripe publishable key dynamically instead of hardcoding it. This ensures your agent always uses the current key.
Example response:
Always use this endpoint to fetch the publishable key — it handles key rotation automatically so your agent never needs redeploying.
Create a Stripe-hosted payment URL that the agent can forward to a human user. The human completes payment on Stripe Checkout, then is redirected to ModelsLab’s success page where they can copy the session_id. The agent then confirms the payment using POST /wallet/confirm-checkout or POST /subscriptions/confirm-checkout.
Parameters:
  • purpose (required, string): "fund" for wallet funding or "subscribe" for plan subscription
  • amount (required if purpose is "fund", number): Amount in USD to fund the wallet
  • plan_id (required if purpose is "subscribe", integer): The plan ID from /subscriptions/plans
Example response:
The success_url and cancel_url are controlled by ModelsLab — agents do not pass them. After payment, the user is redirected to ModelsLab’s payment success page where the session_id is shown with a copy-to-clipboard button.

Card Data Policy

Raw card PAN/CVV is never accepted on ModelsLab API endpoints. Agents must tokenize cards directly with the Stripe API using the ModelsLab publishable key, then pass the resulting payment_method_id to ModelsLab endpoints.
Create a Stripe PaymentMethod directly using the ModelsLab publishable key. Card data goes to Stripe only — ModelsLab never sees raw card numbers. Step 1 — Fetch the Stripe publishable key:
Step 2 — Create PaymentMethod via Stripe API:
Response includes a payment_method_id (e.g., pm_1Xyz...). Step 3 — Use payment_method_id with ModelsLab endpoints:
The publishable key is safe to embed in agent code — it can only create tokens, never charge directly.

Attach payment method example

Wallet Endpoints

Wallet transactions example

Query the wallet ledger with optional filters for transaction type, limit, and offset.
Query parameters:
  • type (optional): credit or debit
  • limit (optional, integer, max 200, default 50)
  • offset (optional, integer, default 0)
Example response:

Wallet balance example

Quick check of wallet balance without the full transaction ledger:
Example response:

Wallet fund example

Fund wallet with a payment_method_id obtained from the Stripe API (see Headless Card Tokenization above).

Confirm wallet checkout (Human-Assisted flow)

After a human completes payment via a Stripe Checkout URL (created with POST /billing/payment-link), the agent confirms the session to credit the wallet. The human is redirected to ModelsLab’s success page after payment, where the session_id is displayed for them to copy and relay back to the agent.
Parameters:
  • session_id (required, string): The Stripe Checkout session ID from POST /billing/payment-link response or copied by the human from the success page
If the payment hasn’t completed yet (human hasn’t finished checkout), poll this endpoint with a short delay. Once the session is confirmed, the wallet balance is updated immediately.

Coupon validate example

Validate a coupon before redeeming (note: this is a GET request):

Payment status example

Check the status of a Stripe PaymentIntent (useful after wallet funding):
Example response:
Possible status values: succeeded, pending, failed.