Documentation Index
Fetch the complete documentation index at: https://docs.modelslab.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Headless Agent Flow allows an AI agent or automation script to go from zero to generating content in 5 API calls, with no browser interaction required. Card data never touches ModelsLab servers — agents tokenize cards directly with Stripe.All responses include
X-RateLimit-Remaining and X-RateLimit-Reset headers for rate-limit awareness.Stripe Publishable Key
Agents fetch the Stripe publishable key via the API, then create PaymentMethods directly with Stripe. Card data never touches ModelsLab servers.{ "publishable_key": "pk_live_...", "instructions": "..." }. Always use this endpoint to get the current key — it handles key rotation automatically.
The 5-Step Flow
Verify Email (Headless)
Extract the Returns
verification_code from the verification email and verify without a browser.access_token and api_key directly.Create Payment Method via Stripe
Use the publishable key from Step 1 of the flow (fetched via Returns a
GET /billing/stripe-config) to tokenize card details. Card data never touches ModelsLab servers.payment_method_id (e.g., pm_1Xyz...). Use this ID with ModelsLab endpoints — never send raw card numbers to ModelsLab.Fund Wallet or Subscribe
Use the Option B — Subscribe to a plan:Use
payment_method_id from Step 3 to either fund the wallet or create a subscription.Option A — Fund wallet (pay-as-you-go):GET /subscriptions/plans first to discover available plan IDs.Generate Content with Existing APIs
Use the existing generation APIs (
/api/v6, /api/v7, /api/v8) with the api_key returned in Step 2. See the Image Generation, Video API, and Speech & Audio docs for endpoint details.Flow Diagram
Alternative: Human-Assisted Payment
If your agent does not have access to card details or the card requires 3D Secure, use the Human-Assisted flow instead. The agent creates a Stripe-hosted payment link and forwards it to a human:session_id, and relays it to the agent. The agent then confirms:
Handling Card Failures
When a card is declined, the API returns HTTP 402 with a structured error:Rate Limits
| Limiter | Limit | Applies to |
|---|---|---|
agent-auth | 20/min per IP+email | Signup, login, verify, forgot-password |
agent-billing | 15/min per IP+user | Wallet fund, subscriptions, payment methods |
agent-general | 120/min per IP+user | All other authenticated endpoints |
Idempotency
All billing mutations support anIdempotency-Key header. If you retry a request with the same key, the cached response is returned with idempotency_replay: true instead of charging again.

