cURL
curl https://api.portkey.ai/v1/files/file-abc123 \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY"from portkey_ai import Portkey
client = Portkey(
api_key = "PORTKEY_API_KEY",
virtual_key = "PROVIDER_VIRTUAL_KEY"
)
client.files.retrieve("file-abc123")import Portkey from 'portkey-ai';
const client = new Portkey({
apiKey: 'PORTKEY_API_KEY',
virtualKey: 'PROVIDER_VIRTUAL_KEY'
});
async function main() {
const file = await client.files.retrieve("file-abc123");
console.log(file);
}
main();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.portkey.ai/v1/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",
CURLOPT_HTTPHEADER => [
"x-portkey-api-key: <api-key>",
"x-portkey-virtual-key: <api-key>"
],
]);
$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"
)
func main() {
url := "https://api.portkey.ai/v1/files/{file_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-portkey-api-key", "<api-key>")
req.Header.Add("x-portkey-virtual-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.portkey.ai/v1/files/{file_id}")
.header("x-portkey-api-key", "<api-key>")
.header("x-portkey-virtual-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.portkey.ai/v1/files/{file_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-portkey-api-key"] = '<api-key>'
request["x-portkey-virtual-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"bytes": 123,
"created_at": 123,
"filename": "<string>",
"object": "file",
"status_details": "<string>"
}Retrieve File
GET
/
files
/
{file_id}
cURL
curl https://api.portkey.ai/v1/files/file-abc123 \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY"from portkey_ai import Portkey
client = Portkey(
api_key = "PORTKEY_API_KEY",
virtual_key = "PROVIDER_VIRTUAL_KEY"
)
client.files.retrieve("file-abc123")import Portkey from 'portkey-ai';
const client = new Portkey({
apiKey: 'PORTKEY_API_KEY',
virtualKey: 'PROVIDER_VIRTUAL_KEY'
});
async function main() {
const file = await client.files.retrieve("file-abc123");
console.log(file);
}
main();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.portkey.ai/v1/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",
CURLOPT_HTTPHEADER => [
"x-portkey-api-key: <api-key>",
"x-portkey-virtual-key: <api-key>"
],
]);
$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"
)
func main() {
url := "https://api.portkey.ai/v1/files/{file_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-portkey-api-key", "<api-key>")
req.Header.Add("x-portkey-virtual-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.portkey.ai/v1/files/{file_id}")
.header("x-portkey-api-key", "<api-key>")
.header("x-portkey-virtual-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.portkey.ai/v1/files/{file_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-portkey-api-key"] = '<api-key>'
request["x-portkey-virtual-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"bytes": 123,
"created_at": 123,
"filename": "<string>",
"object": "file",
"status_details": "<string>"
}Authorizations
Portkey-Key & Virtual-KeyPortkey-Key & Provider-Auth & Provider-NamePortkey-Key & ConfigPortkey-Key & Provider-Auth & Provider-Name & Custom-Host
Path Parameters
The ID of the file to use for this request.
Response
200 - application/json
OK
The File object represents a document that has been uploaded to OpenAI.
The file identifier, which can be referenced in the API endpoints.
The size of the file, in bytes.
The Unix timestamp (in seconds) for when the file was created.
The name of the file.
The object type, which is always file.
Available options:
file The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results and vision.
Available options:
assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision Deprecated. The current status of the file, which can be either uploaded, processed, or error.
Available options:
uploaded, processed, error Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job.
Last modified on October 8, 2024
Was this page helpful?
⌘I

