import requests
file_id = "your_file_id_here"
url = f"https://api.ai21.com/studio/v1/library/files/{file_id}/download"
headers = {"Authorization": "Bearer your_api_key_here"}
response = requests.get(url)
if response.status_code == 200:
print("Download URL:", response.text)
else:
print("Error:", response.status_code, response.text)
const file_id = "your_file_id_here";
fetch(`https://api.ai21.com/studio/v1/library/files/${file_id}/download`, {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
},
})
.then(res => res.text())
.then(link => console.log("Download URL:", link))
.catch(err => console.error("Error:", err));
<?php
$file_id = "your_file_id_here";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/$file_id/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo "Download URL: " . $response;
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
fileID := "your_file_id_here"
url := fmt.Sprintf("https://api.ai21.com/studio/v1/library/files/%s/download", fileID)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
curl -X GET "https://api.ai21.com/studio/v1/library/files/{file_id}/download" \
-H "Authorization: Bearer YOUR_API_KEY"
File Library Management
Get file download link
Retrieve a signed URL you can use to download a file’s contents from your workspace library.
GET
/
studio
/
v1
/
library
/
files
/
{file_id}
/
download
import requests
file_id = "your_file_id_here"
url = f"https://api.ai21.com/studio/v1/library/files/{file_id}/download"
headers = {"Authorization": "Bearer your_api_key_here"}
response = requests.get(url)
if response.status_code == 200:
print("Download URL:", response.text)
else:
print("Error:", response.status_code, response.text)
const file_id = "your_file_id_here";
fetch(`https://api.ai21.com/studio/v1/library/files/${file_id}/download`, {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
},
})
.then(res => res.text())
.then(link => console.log("Download URL:", link))
.catch(err => console.error("Error:", err));
<?php
$file_id = "your_file_id_here";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/$file_id/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo "Download URL: " . $response;
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
fileID := "your_file_id_here"
url := fmt.Sprintf("https://api.ai21.com/studio/v1/library/files/%s/download", fileID)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
curl -X GET "https://api.ai21.com/studio/v1/library/files/{file_id}/download" \
-H "Authorization: Bearer YOUR_API_KEY"
Path parameters
The unique ID of the file to download.
Response 200
Returns a string containing the signed download URL for the requested file. Example response:"https://storage.ai21.com/files/file_123abc/download?token=xyz"
Response 422
No matching ID is found.import requests
file_id = "your_file_id_here"
url = f"https://api.ai21.com/studio/v1/library/files/{file_id}/download"
headers = {"Authorization": "Bearer your_api_key_here"}
response = requests.get(url)
if response.status_code == 200:
print("Download URL:", response.text)
else:
print("Error:", response.status_code, response.text)
const file_id = "your_file_id_here";
fetch(`https://api.ai21.com/studio/v1/library/files/${file_id}/download`, {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
},
})
.then(res => res.text())
.then(link => console.log("Download URL:", link))
.catch(err => console.error("Error:", err));
<?php
$file_id = "your_file_id_here";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/$file_id/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo "Download URL: " . $response;
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
fileID := "your_file_id_here"
url := fmt.Sprintf("https://api.ai21.com/studio/v1/library/files/%s/download", fileID)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
curl -X GET "https://api.ai21.com/studio/v1/library/files/{file_id}/download" \
-H "Authorization: Bearer YOUR_API_KEY"
Was this page helpful?
⌘I

