---
title: "Keep an output as a file"
method: POST
path: "/v1/generations/{id}/outputs/{index}/file"
tags: ["Generations"]
---

# Keep an output as a file

`POST /v1/generations/{id}/outputs/{index}/file`

## Request

- Base URL: `https://api.tryleap.ai`
- URL: `https://api.tryleap.ai/v1/generations/{id}/outputs/{index}/file`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer

Turns an image output of a succeeded generation into a file of your workspace, so you can pass its ID to the next run without downloading and uploading it. Calling it again returns the same file. Other outputs answer `400`.

Needs an API key with the `generations:write` scope.

## Path parameters

- `id` string, required: The generation's ID, `gen_...`.
- `index` integer, required: The output's position in `output`, from 0.

## Response `201`

The file.

- File: A photo, video or sound stored in your workspace, to pass as a model input.
  - `id` string, required: The file's ID, `file_...`. Pass it in a model's input.
  - `object` 'file', required
  - `content_type` string, required: The type, read from the file's bytes, such as `image/jpeg` or `video/mp4`.
  - `bytes` integer, required: The size in bytes.
  - `width` integer, nullable, required: Width in pixels; null for a sound.
  - `height` integer, nullable, required: Height in pixels; null for a sound.
  - `duration` number, nullable, required: A video's or a sound's length in seconds; null for an image.
  - `filename` string, nullable, required: The name you gave, if any.
  - `url` string, uri, required: A signed link to the file, valid for 24 hours. Read the file again for a fresh one.
  - `created_at` string, date-time, required: When it was stored.

## Other responses

- `400`: `invalid_parameter`, `conflicting_credentials`
- `401`: `authentication_required`
- `403`: `permission_denied`
- `404`: `resource_not_found`
- `429`: `rate_limit_exceeded`

---

[API](https://skmtc.dev/tryleap/apis/leap-api.md) · [All operations](https://skmtc.dev/tryleap/apis/leap-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tryleap/apis/leap-api/revisions/c01f98d3e835?raw)
