Retention of API-generated files

Decide how long files generated by your external app stay in your account storage

How it works

1

🔑Per-key default: in API Console → API Keys → Key settings choose the retention (Persistent, 1 hour, 24 hours, 7 days, 30 days). It applies to every file generated with that key.

2

⚡Per-request override: add storage_ttl_hours (integer 1–720 hours) to the JSON body. It applies only to that call and wins over the key default.

3

🧹Automatic deletion: an hourly sweeper removes expired files and immediately returns the space to your storage quota. Downloads keep working while the file exists.

Allowed values

💾

Persistent (-1)

Files stay until you delete them

storage_ttl_hours: -1
⏱️

1 hour

Automatic deletion at expiry

storage_ttl_hours: 1
⏳

24 hours

Automatic deletion at expiry

storage_ttl_hours: 24
📅

7 days

Automatic deletion at expiry

storage_ttl_hours: 168
🗓️

30 days

Automatic deletion at expiry

storage_ttl_hours: 720

Set it once per key: apps with different needs can use different keys. Backward compatible: existing keys stay persistent until you change the setting.

Per-request override

The same endpoint accepts storage_ttl_hours in the JSON body (integer 1–720): ideal when the same app wants, for example, to keep user-downloaded PDFs but make other files ephemeral.

Example: PDF expiring after 24 hours

// PDF che scade automaticamente dopo 24 ore
fetch("https://app.neuralaiweb.com/functions/neuralaiPublicApi", {
  method: "POST",
  body: JSON.stringify({
    api_key: "nai_...",
    generate_pdf: true,
    prompt: "# Il mio documento\nContenuto markdown...",
    storage_ttl_hours: 24   // override per questa richiesta
  })
})

// Upload con scadenza a 7 giorni (multipart/form-data)
const form = new FormData();
form.append("file", myFile);
form.append("storage_ttl_hours", "168");
await fetch("https://app.neuralaiweb.com/functions/apiUploadFile?api_key=nai_...", {
  method: "POST",
  body: form
});

Which files it applies to

  • PDF export (generate_pdf: true) and 16:9 PDF presentations
  • Videos generated with the unified API (async delivery with video_url)
  • Files uploaded with the API key (apiUploadFile / apiUploadAndAnalyze): attachments already have the 30-day lifecycle; a shorter TTL deletes them earlier
  • Images, music and videos returned as base64 data URLs do NOT use storage: no TTL needed

Recommended use cases

AI chat without history: TTL 1–24 hours. Generated media only serves the current session: it expires on its own, leaving no orphans in storage.

History in local storage (browser): short TTL (1–24 hours). Save locally what you want to keep: storage files expire, your local history stays yours.

App with stable history (your server or database): Persistent. History stays browsable and files must remain reachable as long as the references exist.

Security and quota

Retention is configurable only by the key owner and applies only to their account's files: no external app can act on other users' retention or files. Files with TTL still occupy space and count against the quota (1 GB free, then 50 tokens/GB per month) while they exist; automatic deletion instantly frees the quota. Revoking the key does not delete already generated files: use manageMediaStorage list_files/delete_files for manual cleanup.

Key attribution and the Storage dashboard

Every file generated or uploaded with an API key (PDFs, presentations, videos, uploads) is attributed to the key that produced it — including persistent files with no TTL.

The API Hub Storage dashboard groups files by key (name and visible prefix) and also shows files created by the app without a key: Neuralai Seek, Deep Research, chat, presentations and the Free, Premium and Premium Plus services.

From here you can delete individual files or all files of a key in one go. Files still linked to saved conversations, documents or sites are never deleted, and freed space returns to your quota immediately.

Unsure which retention to pick for your app? Ask the API Copilot (icon in the bottom right): it knows all the use cases.

Cookies & Privacy

We use technical cookies necessary for the site to function and, only with your consent, Google and Meta measurement and marketing cookies. You may accept or reject.