ModelsLab supports three payment flows for agents, depending on the level of automation required:
Path
Flow
Best For
Headless
GET /billing/stripe-config -> tokenize card via Stripe API -> pass payment_method_id to POST /wallet/fund or POST /subscriptions
Fully automated agents with card details available
Setup Intent
POST /billing/setup-intent -> confirm via Stripe -> reuse payment_method_id for future charges
Agents that save payment methods for repeated use
Human-Assisted
POST /billing/payment-link -> forward URL to human -> human pays on Stripe Checkout -> agent polls POST /wallet/confirm-checkout or POST /subscriptions/confirm-checkout
Retrieve the Stripe publishable key dynamically instead of hardcoding it. This ensures your agent always uses the current key.
curl --request GET 'https://modelslab.com/api/agents/v1/billing/stripe-config' \ --header 'Authorization: Bearer <agent_access_token>'
Example response:
{ "publishable_key": "pk_live_51JfPKxSDo1BGXG2x...", "instructions": "Use this key to call the Stripe API directly to create PaymentMethods. Card data is sent to Stripe only — never to ModelsLab."}
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.
# Fund wallet — human pays $25 via Stripe Checkoutcurl --request POST 'https://modelslab.com/api/agents/v1/billing/payment-link' \ --header 'Authorization: Bearer <agent_access_token>' \ --header 'Content-Type: application/json' \ --data '{ "purpose": "fund", "amount": 25 }'# Subscribe to a plan — human completes subscription via Stripe Checkoutcurl --request POST 'https://modelslab.com/api/agents/v1/billing/payment-link' \ --header 'Authorization: Bearer <agent_access_token>' \ --header 'Content-Type: application/json' \ --data '{ "purpose": "subscribe", "plan_id": 10 }'
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:
{ "payment_url": "https://checkout.stripe.com/c/pay/cs_live_...", "session_id": "cs_live_...", "purpose": "fund", "amount": 25, "expires_at": "2026-02-20T12:30:00Z", "instructions": "Forward this URL to the user. They will complete payment on Stripe's hosted checkout page. After payment, they are redirected to ModelsLab's success page where the session_id is displayed for copy-to-clipboard. Use the session_id to confirm the payment via POST /wallet/confirm-checkout or POST /subscriptions/confirm-checkout."}
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.
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.
Headless Card Tokenization (Recommended for Agents)
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:
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.
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.