Keep an output as a file
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.
curl --request POST \
--url https://api.tryleap.ai/v1/generations/{id}/outputs/{index}/file \
--header 'x-api-key: <api-key>'const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.tryleap.ai/v1/generations/{id}/outputs/{index}/file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.tryleap.ai/v1/generations/{id}/outputs/{index}/file"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)Authorizations
Your workspace API key, leap_.... Create one at https://app.tryleap.ai/go/api, and keep it on your server.
Path Parameters
The generation's ID, gen_....
The output's position in output, from 0.
0 <= x <= 63Response
The file.
A photo, video or sound stored in your workspace, to pass as a model input.
The file's ID, file_.... Pass it in a model's input.
"file"The type, read from the file's bytes, such as image/jpeg or video/mp4.
The size in bytes.
0 <= x <= 9007199254740991Width in pixels; null for a sound.
0 < x <= 9007199254740991Height in pixels; null for a sound.
0 < x <= 9007199254740991A video's or a sound's length in seconds; null for an image.
x >= 0The name you gave, if any.
A signed link to the file, valid for 24 hours. Read the file again for a fresh one.
When it was stored.
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$curl --request POST \
--url https://api.tryleap.ai/v1/generations/{id}/outputs/{index}/file \
--header 'x-api-key: <api-key>'const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.tryleap.ai/v1/generations/{id}/outputs/{index}/file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.tryleap.ai/v1/generations/{id}/outputs/{index}/file"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)