from ai21 import AI21Client
client = AI21Client()
# Replace with your actual file_id
file_id = "file_123abc"
# Retrieve file metadata
file_metadata = client.library.files.get(file_id=file_id)
print(file_metadata)
const options = {method: 'GET'};
fetch('https://api.ai21.com/studio/v1/library/files/{file_id}', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.ai21.com/studio/v1/library/files/{file_id}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
curl --request GET \
--url https://api.ai21.com/studio/v1/library/files/{file_id}
HttpResponse<String> response = Unirest.get("https://api.ai21.com/studio/v1/library/files/{file_id}")
.asString();
{
"id": "file_123abc",
"name": "customer_data.pdf",
"size": 204800,
"created_at": "2025-10-20T14:23:11Z",
"labels": ["invoices", "Q3"]
}
File Library Management
Get workspace file
Retrieve metadata about a specific file.
GET
/
studio
/
v1
/
library
/
files
/
{file_id}
from ai21 import AI21Client
client = AI21Client()
# Replace with your actual file_id
file_id = "file_123abc"
# Retrieve file metadata
file_metadata = client.library.files.get(file_id=file_id)
print(file_metadata)
const options = {method: 'GET'};
fetch('https://api.ai21.com/studio/v1/library/files/{file_id}', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.ai21.com/studio/v1/library/files/{file_id}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
curl --request GET \
--url https://api.ai21.com/studio/v1/library/files/{file_id}
HttpResponse<String> response = Unirest.get("https://api.ai21.com/studio/v1/library/files/{file_id}")
.asString();
{
"id": "file_123abc",
"name": "customer_data.pdf",
"size": 204800,
"created_at": "2025-10-20T14:23:11Z",
"labels": ["invoices", "Q3"]
}
The
file_id is generated by AI21 when you upload the file.
Path Parameters
The unique ID of the file to retrieve.
Responses
Response 200
A successful response returns metadata about the requested file.The file ID.
The file name.
File size in bytes.
File creation timestamp.
Labels assigned to the file
Error code, if any.
Error message, if any.
Response 422
No matching ID is found.from ai21 import AI21Client
client = AI21Client()
# Replace with your actual file_id
file_id = "file_123abc"
# Retrieve file metadata
file_metadata = client.library.files.get(file_id=file_id)
print(file_metadata)
const options = {method: 'GET'};
fetch('https://api.ai21.com/studio/v1/library/files/{file_id}', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.ai21.com/studio/v1/library/files/{file_id}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
curl --request GET \
--url https://api.ai21.com/studio/v1/library/files/{file_id}
HttpResponse<String> response = Unirest.get("https://api.ai21.com/studio/v1/library/files/{file_id}")
.asString();
{
"id": "file_123abc",
"name": "customer_data.pdf",
"size": 204800,
"created_at": "2025-10-20T14:23:11Z",
"labels": ["invoices", "Q3"]
}
Was this page helpful?
⌘I

