thelastapi
Get started free

Where to keep AI-generated images, with permanent links

Store AI-generated images with permanent links by generating them under a project on thelastapi, where files save automatically to Files.

On this page 8 sections

To store AI-generated images with permanent links, generate them under a project on thelastapi, where every output is automatically saved to the project's Files drive with an unexpiring public URL. You do not need to download base64 blobs, manage separate object storage buckets, or write upload pipelines. When you call the image generation API with a project key, the response returns a permanent link alongside the file ID, prompt, and cost.

This guide explains how automated storage works for AI assets, how to retrieve and query your saved images, and how to control link visibility.

Why temporary image URLs break in production

Most AI model providers return image generation results in one of two ways: a short-lived URL or a massive base64-encoded string. Both introduce maintenance headaches when building web applications:

  • Expiring URLs break user interfaces. Typical raw generation URLs expire after an hour or 24 hours. If you save that URL directly into your database, customer avatars, hero graphics, and product cards stop rendering the next day.
  • Base64 strings bloat payloads. Returning megabytes of encoded strings inside API payloads slows down client connections, consumes unnecessary server memory, and complicates edge caching.
  • Separate storage pipelines multiply complexity. The traditional workaround requires writing glue code: receiving the image stream, connecting to external file storage, uploading the buffer, setting public access permissions, and generating a permanent URL before writing to the database.

Using AI with thelastapi eliminates that glue code. When an image model runs inside a project, the generated media is captured, stored, and indexed in Files immediately.

How automatic media storage works

When you generate an image using the unified /v1/ai gateway, the backend routes your prompt to the specified lab model. Once generated, the project inspects the environment and saves the asset directly into the project's Files store.

Public file URLs use the format:

Text
https://thelastapi.dev/f/<key>/<name>

The <key> consists of 32 random characters. Because this key cannot be guessed or enumerated, your images remain secure while staying publicly resolvable for browser <img> tags, email campaigns, or social feed previews. The <name> at the end is slugified from the creation date and your prompt (for example, 2026-10-28-cold-email-cover.png). If you generate multiple images with the same prompt, subsequent files append -2, -3, and so forth.

Every file record retains full AI metadata:

  • The model identifier used (such as vibiz/image-pro)
  • The complete text prompt
  • Exact generation cost in USD
  • Asset dimensions (width and height)
  • File format and byte size

Calls made with a development key (vz_ai_... in .env.development.local) store assets in your project's development Files. Calls made with production keys store assets in production Files. If a request is executed using an account-level key without a project header (X-Vibiz-Project), the asset has no project drive to attach to; in that case, the resulting URL expires after 24 hours.

You can call image models using the OpenAI SDK by pointing the client to VIBIZ_AI_BASE_URL with your project's AI key. Setting response_format: "url" returns the permanent storage link in the standard response array:

TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: process.env.VIBIZ_AI_BASE_URL,
  apiKey: process.env.VIBIZ_AI_API_KEY,
});

const response = await openai.images.generate({
  model: 'vibiz/image-pro',
  prompt: 'A minimalist ceramic coffee cup on an oak desk, natural morning lighting',
  response_format: 'url',
  n: 1,
  size: '1024x1024',
});

// The link is permanent and ready to save to your database
const imageUrl = response.data[0].url;
console.log('Permanent asset URL:', imageUrl);

You can also make plain HTTP calls with curl:

Terminal
curl https://thelastapi.dev/v1/ai/images/generations \
  -H "Authorization: Bearer $VIBIZ_AI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "vibiz/image",
    "prompt": "Studio portrait of a golden retriever wearing spectacles",
    "response_format": "url"
  }'

The JSON response maintains standard structure while including persistent file properties:

JSON
{
  "created": 1730112000,
  "data": [
    {
      "url": "https://thelastapi.dev/f/Qm9xN8w2Lp4vRt6yU1s3Kj5hG7fD9aZb/2026-10-28-studio-portrait-golden-retriever.png",
      "file_id": "file_01k...",
      "file_url": "https://thelastapi.dev/f/Qm9xN8w2Lp4vRt6yU1s3Kj5hG7fD9aZb/2026-10-28-studio-portrait-golden-retriever.png"
    }
  ]
}

If you use the @vibiz/app SDK in your application code, accessing recently generated assets or uploading reference materials takes just a couple of lines, as detailed in file uploads for your app, with permanent links.

Managing and searching stored images

Because generated media lives in your project's Files drive, you do not need to retain external registries to look up old creations. You can query files from the terminal using the CLI:

Terminal
# Get the direct link to the newest generated image
vibiz files latest --type image --source ai

# Search images by words used in the prompt
vibiz files search "golden retriever"

# Inspect a file's metadata and prompt details
vibiz files get file_01k...

To fetch assets programmatically in backend services, query the Files API endpoint:

Terminal
curl https://thelastapi.dev/v1/projects/prj_123/files?type=image&source=ai \
  -H "Authorization: Bearer $VIBIZ_API_KEY"

This returns an array of file objects sorted newest first, including file size, dimensions, generation timestamp, prompt, and the url.

Comparing image models and pricing

thelastapi provides stable model aliases mapped to underlying lab models. When you request a specific model tier, that exact model runs without silent fallbacks.

Model aliasUnderlying lab modelBest forPricing
vibiz/imageNano Banana 2 (Google)Fast generation, editing, consistent characters~$0.067 / image
vibiz/image-proNano Banana 2.1 (Google)High detail, newest generation features~$0.034 / image
vibiz/image-textGPT-5.4 Image 2 (OpenAI)Rendering clear text within graphics~$0.04 / image

Beyond text-to-image prompts, you can provide reference images for edits and variations. Passing image_url or up to 8 URLs in image_urls lets you modify backgrounds or combine assets directly via the API. To learn how to structure editing prompts, read an AI photo editing API that starts from your photo. If you are building automated product catalogues, check out generate product photos for an online store with an API. For multi-modal apps using speech or video models, explore one API for image, video and voice AI models.

Handling private assets and download rules

By default, files generated through the AI endpoints have private: false, generating permanent public links. For sensitive workflows where images must remain confidential:

  1. You can update a file's visibility via the API with PATCH /v1/projects/:id/files/:fileId passing {"private": true}.
  2. A private file's url turns into a time-limited signed link that expires in one hour (url_expires_at).
  3. Unauthenticated requests to a private file URL without its signature return 404.
  4. Your application server can stream the raw bytes of private assets anytime using GET /v1/projects/:id/files/:fileId/content.

Every image file is served with X-Content-Type-Options: nosniff, ETag, and Content-Disposition: inline. Single file sizes are supported up to 50 MB, covering standard outputs from 256 px up to 2,048 px per side.

Next steps

Initialize a project with AI resources to get your development keys:

Terminal
vibiz init "My Project" --resources ai
vibiz dev

Run vibiz image "a brass compass on an old map" -o compass.png to test generation from your terminal, or review the complete parameter set on the AI docs page.

Frequently asked questions

Do images generated via thelastapi expire after 24 hours?

Images generated under a project have permanent public URLs that never expire. Only calls made using an account key without a project attached revert to 24-hour expiring temporary links.

How do I access the prompt used to create a saved image?

You can view the original prompt by inspecting the file metadata via `vibiz files get <id>`, listing files via `GET /v1/projects/:id/files`, or checking the project's Files page in the console.

Can I prevent generated images from being publicly accessible on the web?

Yes, you can mark any file private by sending `PATCH /v1/projects/:id/files/:fileId` with `{"private": true}`, which restricts direct access and provides signed URLs valid for one hour.

Where are files stored during local development?

Calls made with your development AI key automatically isolate generated media in your project's development Files environment, preventing test runs from cluttering production assets.