{"openapi":"3.0.0","info":{"title":"Ludo.ai API","version":"0.9.10","description":"Buy extra credits for a Ludo.ai account over the Machine Payments Protocol (HTTP 402, Stripe). The full Ludo.ai API is documented at https://api.ludo.ai/api-documentation.","x-guidance":"Ludo.ai generates game assets (sprites and animations, images, 3D models, video, sound, music) for a Ludo account. This document covers buying extra credits for that account over the Machine Payments Protocol. Every call needs the account's API key in `Authorization: ApiKey <key>` (keys are made in the web app at https://app.ludo.ai, or by `ludo signup` in the Ludo CLI, which creates the account from the terminal). GET /api/assets/topup/quote?credits=<n> gives the price of n credits on the account's plan, for free. POST /api/assets/topup/pay with {\"credits\": <n>} (a whole number from 250 to 17000) and no credential answers 402 with a stripe charge challenge for that price. Send the credential in the header the challenge names, Payment-Authorization, and keep the API key in Authorization; the credits are added when it pays. `link-cli mpp pay https://api.ludo.ai/api/assets/topup/pay -X POST -d '{\"credits\": 1000}' -H \"Authorization: ApiKey $LUDO_API_KEY\"` does both steps after the account holder approves the amount in Link. The whole API (generation, jobs, account) is at https://api.ludo.ai/api-documentation/openapi.json.","contact":{"name":"Ludo.ai support","email":"support@ludo.ai","url":"https://ludo.ai"}},"paths":{"/api/assets/topup/quote":{"get":{"description":"The price of a credit top-up (extra credits that stay while the plan is active) on your plan, and the one-time Link (`link-cli`) spend request to pay it without a browser. `credits` goes in steps between min_credits and max_credits. Free, read-only. Buying: createTopupLink (a payment page for the user to pay), or payTopup with a Link token. Never buy credits the user did not ask for. Requires an API key (user scope).","tags":["Account"],"operationId":"getTopupQuote","security":[{"ApiKey":[]}],"parameters":[{"name":"credits","in":"query","required":true,"example":1000,"schema":{"type":"integer","minimum":250,"maximum":17000,"example":1000}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TopupQuote"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/assets/topup/pay":{"post":{"description":"Buy extra credits with a one-time Link Shared Payment Token (spt_...) the user approved in Link for exactly the amount getTopupQuote gives; when it answers \"completed\" the credits are in the account (\"paid\": they are on their way). For agents that run Link's CLI; otherwise use createTopupLink. A token buys one top-up. Only when the user asked for the credits and approved the payment. Without a payment_token it answers 402 with a Machine Payments Protocol challenge for the credits (WWW-Authenticate: Payment, method stripe), which `link-cli mpp pay` pays: the credential goes in the Payment-Authorization header, the API key stays in Authorization. Requires an API key (user scope).","tags":["Account"],"operationId":"payTopup","security":[{"ApiKey":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TopupPayPayload"}}},"required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TopupPaid"}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"No payment_token: a Machine Payments Protocol challenge (WWW-Authenticate: Payment, application/problem+json). Otherwise the token or credential was declined, or is not for the quoted amount.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"A top-up is in progress, or the token was used","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"x-payment-info":{"price":{"mode":"dynamic","currency":"USD","min":"7.50","max":"680.00"},"protocols":[{"mpp":{"method":"stripe","intent":"charge","currency":"usd"}}]}}}},"components":{"schemas":{"TopupQuote":{"type":"object","properties":{"credits":{"type":"integer"},"amount":{"type":"number","format":"float","description":"The price, in the currency's main unit, on the account's plan."},"amount_minor":{"type":"integer","description":"The price in minor units, as Link's --amount takes it."},"currency":{"type":"string"},"tier":{"type":"string"},"min_credits":{"type":"integer"},"max_credits":{"type":"integer"},"step_credits":{"type":"integer"},"network_id":{"type":"string"},"test_mode":{"type":"boolean"},"link_cli_command":{"type":"string","description":"The one-time spend request to create with Link's CLI."}}},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"metadata":{"type":"string"},"error_payload":{"type":"string"},"intent":{"type":"object","description":"Stripe intent details sent with 3D Secure (406) errors","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["payment","setup"],"example":"payment"},"client_secret":{"type":"string"}}}}},"TopupPayPayload":{"type":"object","required":["credits"],"properties":{"credits":{"type":"integer","example":1000,"minimum":250,"maximum":17000},"payment_token":{"type":"string","maxLength":256,"description":"A one-time Link Shared Payment Token (spt_...) for exactly the quoted amount. Leave it out to pay over MPP instead (a 402 challenge, then the credential in Payment-Authorization)."}}},"TopupPaid":{"type":"object","properties":{"status":{"type":"string","description":"completed: the credits are in. paid: the money is taken and the credits are on their way.","enum":["completed","paid"],"example":"completed"},"credits":{"type":"integer"},"amount":{"type":"number","format":"float"},"currency":{"type":"string"},"invoice_id":{"type":"string"},"payment_intent_id":{"type":"string","description":"The Stripe payment that charged the token (none when the account's Stripe balance covered it)."},"extra_credits":{"type":"number","format":"float","description":"The account's extra (top-up) credits after this one."}}}},"securitySchemes":{"ApiKey":{"type":"apiKey","name":"Authorization","in":"header","description":"For accessing the API a valid API Key token must be passed in all the queries in\nthe 'Authorization' header.\nThe following syntax must be used in the 'Authorization' header: ApiKey xxxxxx.yyyyyyy.zzzzzz\n"}}}}