<!-- Markdown twin of https://pixelvault.dev/docs/guides/save-ai-outputs/ -->

# Save AI outputs before their links expire

**Goal:** keep what a model produced at a permanent URL, without downloading it first or knowing whether it is an image, a video or audio. One call to [`POST /v1/media`](/docs/api/media/#import_media) (or the `save_url` MCP tool) does it.

## Why the links break

Generation APIs hand back a temporary link or raw bytes, and their docs tell you to store the file yourself:

Provider

What you get

How long it lasts

Replicate

A `replicate.delivery` URL

Deleted after 1 hour (API predictions)

OpenAI Images

A `url`, or `b64_json`

URLs are valid for 60 minutes

Runway

An output URL

Expires within 24 to 48 hours

Gemini

Inline base64, or a Files API URI

Files are deleted after 48 hours

fal

A `fal.media` URL

Kept at least 7 days by default

ElevenLabs

Audio bytes in the response

No URL; keep the bytes yourself

Provider CDNs also tend to serve every file as `application/octet-stream`, so the link alone does not say what it is.

## 1\. Save a link

Send the link as `url` right after the result arrives. A secret API key is required. PixelVault reads the first bytes, decides the type, and stores the file through the same pipeline as `upload_image`, `upload_video` or `upload_audio`: same validation, plan limits, video posters and webhooks.

Save a link

curlNode.jsPython

```
curl -X POST https://api.pixelvault.dev/v1/media \
  -H "Authorization: Bearer $PIXELVAULT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: replicate-7f3a" \
  -d '{"url":"https://replicate.delivery/xezq/abc123/out-0.webp",
       "folder":"generations",
       "metadata":{"model":"flux-schnell","prediction":"7f3a"}}'
```

```
{ "data": {
  "id": "img_abc123",
  "kind": "image",
  "url": "https://img.pixelvault.dev/proj_xyz789/generations/img_abc123.webp",
  "optimized_url": "https://img.pixelvault.dev/proj_xyz789/generations/img_abc123.webp?fmt=auto&q=85",
  "mime_type": "image/webp",
  "size": 198694,
  "width": 1024,
  "height": 1024,
  "filename": "out-0.webp",
  "folder": "generations",
  "metadata": { "model": "flux-schnell", "prediction": "7f3a" },
  "source_host": "replicate.delivery",
  "created_at": "2026-11-29T12:00:00.000Z"
} }
```

The response is the asset's own object, so check `kind` (`image`, `document`, `video` or `audio`): videos come back with `poster_url`, audio with duration and codec. `source_host` records where the file came from; PixelVault keeps the host only, never the URL, because provider links carry credentials in their query strings.

**Retries:** pass an `Idempotency-Key` built from the provider's own id (a Replicate prediction id, a fal request id). A repeat returns the file the first call saved, with `replayed: true`, instead of storing a copy. See [Idempotency](/docs/idempotency/).

## 2\. Save inline bytes

Some providers return the file itself, not a link: Gemini's inline images, OpenAI's `b64_json`, ElevenLabs audio. Send it as `data`, plain base64 or a `data:` URL, up to 10 MB decoded. For bigger files, upload them with [`POST /v1/videos`](/docs/api/videos/#upload_video) or [`POST /v1/audio`](/docs/api/audio/#upload_audio) instead.

```
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});
const result = await ai.models.generateContent({
  model: "gemini-2.5-flash-image",
  contents: "a lighthouse at dusk, flat vector",
});
const part = result.candidates[0].content.parts.find((p) => p.inlineData);

// Inline bytes have no URL at all: send them as base64 (up to 10 MB decoded).
const res = await fetch("https://api.pixelvault.dev/v1/media", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.PIXELVAULT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ data: part.inlineData.data, filename: "lighthouse.png" }),
});
console.log((await res.json()).data.url);
```

## 3\. From an agent (MCP)

The hosted [MCP server](/docs/mcp/) exposes the same call as `save_url`. Its result adds a ready-to-paste `markdown` snippet: images embed, and videos show the poster linked to a player page, because GitHub and most Markdown renderers will not play a video hosted elsewhere.

```
save_url({ "url": "https://replicate.delivery/xezq/abc123/out-0.mp4",
           "idempotency_key": "replicate-7f3a" })

→ { "id": "vid_abc123", "kind": "video",
    "url": "https://img.pixelvault.dev/proj_xyz789/vid_abc123.mp4",
    "poster_url": "https://img.pixelvault.dev/proj_xyz789/vid_abc123.poster.jpg",
    "source_host": "replicate.delivery",
    "markdown": "[![out-0.mp4](<…poster.jpg>)](<https://pixelvault.dev/i/proj_xyz789/vid_abc123.mp4?…>)",
    … }
```

## Formats and limits

-   **Images and PDFs:** JPEG, PNG, GIF, WebP, AVIF, SVG and PDF, up to 5 MB on Free, 10 MB on Starter and 15 MB on Pro. Unverified accounts can store 5 files before verifying their email.
-   **Video:** MP4, up to 25 MB on Free, 100 MB on Starter and 250 MB on Pro. A verified email is required, and the source must send `Content-Length`.
-   **Audio:** MP3, WAV, M4A and OGG, up to 25 MB on Free, 100 MB on Starter and 250 MB on Pro. A verified email is required.

MOV and WebM links are converted to an MP4 on the way in (up to 60 seconds and 100 MB, using the monthly video-optimization allowance; see [normalize on ingest](/docs/guides/social-ready-video/#normalize)). Anything else returns `415 unsupported_media_type` with `detected_format` naming what it found: `heic` (convert to JPEG), `flac` or `aac` (convert to MP3), `avi` (convert to MP4). An expired link fails with `url_fetch_failed`; generate it again.

A URL is requested twice: a short probe that reads the first 4 KB, then the import itself. Both happen within the same call.

## Next steps

-   [Generate images with PixelVault](/docs/guides/generate-images/) and skip the expiring link altogether.
-   [Organize saved outputs](/docs/guides/organize-media/) with folders, metadata filters and collections.
-   [Webhooks](/docs/webhooks/): get a `media.created` event with `source: "url_import"` for every saved link.
