Tuti APIBilling

Buy AI credits

Buy AI credits: a Stripe Checkout page to pay on. The credits are added once Stripe says it's paid. Off (503) where top-ups aren't set up.

Needs a read + write key.

POST/credits/top-up

Authorization Bearer token

Body

application/json · object · required

  • dollarsinteger · 5–1000required

    What to pay, in whole US dollars: 5 to 1000

Responses

  • 200The payment page

    application/json · object

    The payment page

    • urlstringrequired

      The Stripe Checkout page to pay on

    • dollarsintegerrequired

      What it costs, in US dollars

    • creditsnumberrequired

      How many credits the payment gives

  • 400The request isn't valid: a field is missing, has the wrong type or is out of range, or the body isn't a JSON object. The message names the field.

    application/json · Error

    • errorobjectrequired
      Show 2 properties
      • codestringrequired

        What went wrong, for code to check: stays the same

      • messagestringrequired

        What went wrong, for a person: may change

  • 401No API key was sent, or it isn't valid: it was revoked, or whoever created it left the team.

    application/json · Error

    • errorobjectrequired
      Show 2 properties
      • codestringrequired

        What went wrong, for code to check: stays the same

      • messagestringrequired

        What went wrong, for a person: may change

  • 403It isn't allowed: the key is read-only, its creator isn't a project owner or admin where only they may, only a person can do it in the app, a setting is off, or someone's address isn't confirmed. The code says which.

    application/json · Error

    • errorobjectrequired
      Show 2 properties
      • codestringrequired

        What went wrong, for code to check: stays the same

      • messagestringrequired

        What went wrong, for a person: may change

  • 429Too many requests: past 600 a minute per key, try again after the seconds in the Retry-After header. Some operations have limits of their own (their description gives them), whose 429 has no Retry-After.

    application/json · Error

    • errorobjectrequired
      Show 2 properties
      • codestringrequired

        What went wrong, for code to check: stays the same

      • messagestringrequired

        What went wrong, for a person: may change

  • 500Something went wrong on Tuti's side. Try again in a moment.

    application/json · Error

    • errorobjectrequired
      Show 2 properties
      • codestringrequired

        What went wrong, for code to check: stays the same

      • messagestringrequired

        What went wrong, for a person: may change

  • 502A service Tuti uses failed (the AI model, Stripe, DNS or email). Try again in a moment.

    application/json · Error

    • errorobjectrequired
      Show 2 properties
      • codestringrequired

        What went wrong, for code to check: stays the same

      • messagestringrequired

        What went wrong, for a person: may change

  • 503This feature isn't set up on this server (for example AI or billing), or Tuti couldn't start the work just now: try again in a moment.

    application/json · Error

    • errorobjectrequired
      Show 2 properties
      • codestringrequired

        What went wrong, for code to check: stays the same

      • messagestringrequired

        What went wrong, for a person: may change

curl 'https://tuti.so/api/v1/credits/top-up' \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "dollars": 25
}'
const response = await fetch("https://tuti.so/api/v1/credits/top-up", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "dollars": 25
  }),
});
const text = await response.text();
import requests

response = requests.post(
    "https://tuti.so/api/v1/credits/top-up",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    data="{\n  \"dollars\": 25\n}",
)
print(response.text)
{
  "url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3",
  "dollars": 25,
  "credits": 2500
}
{
  "error": {
    "code": "invalid_input",
    "message": "title: Title is too short"
  }
}
{
  "error": {
    "code": "unauthorized",
    "message": "This API key isn't valid or was revoked"
  }
}
{
  "error": {
    "code": "forbidden",
    "message": "This key can only read. Create a read + write key to change things."
  }
}
{
  "error": {
    "code": "rate_limited",
    "message": "Up to 600 requests a minute per key"
  }
}
{
  "error": {
    "code": "internal_error",
    "message": "Something went wrong"
  }
}
{
  "error": {
    "code": "ai_failed",
    "message": "The AI couldn't write a draft. Try again in a moment."
  }
}
{
  "error": {
    "code": "ai_unavailable",
    "message": "AI isn't set up on this server"
  }
}