cURL
curl --fail-with-body https://api.pre.dev/v1/files \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-F "purpose=user_data" \
-F "file=@contract.pdf"import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
with open("contract.pdf", "rb") as handle:
uploaded = client.files.create(file=handle, purpose="user_data")
print(uploaded.id)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.pre.dev/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/v1/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pre.dev/v1/files"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pre.dev/v1/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": "file-8Kz3pQ",
"object": "file",
"bytes": 1024000,
"created_at": 1790500000,
"filename": "contract.pdf",
"purpose": "user_data"
}Files
Files
Upload, list, fetch, and delete files scoped to your workspace.
POST
/
v1
/
files
cURL
curl --fail-with-body https://api.pre.dev/v1/files \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-F "purpose=user_data" \
-F "file=@contract.pdf"import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
with open("contract.pdf", "rb") as handle:
uploaded = client.files.create(file=handle, purpose="user_data")
print(uploaded.id)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.pre.dev/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pre.dev/v1/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pre.dev/v1/files"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pre.dev/v1/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"id": "file-8Kz3pQ",
"object": "file",
"bytes": 1024000,
"created_at": 1790500000,
"filename": "contract.pdf",
"purpose": "user_data"
}The files endpoints store documents for reuse across chat requests. Files are scoped to the workspace that uploaded them; another workspace’s file id returns
The upload takes the bytes in a
The list has only files this workspace uploaded through the gateway, newest first (
404.
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/files | Upload, multipart/form-data |
| GET | /v1/files | List the workspace’s files |
| GET | /v1/files/{id} | File metadata |
| GET | /v1/files/{id}/content | Download the bytes |
| DELETE | /v1/files/{id} | Delete |
Upload
curl --fail-with-body https://api.pre.dev/v1/files \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-F "purpose=user_data" \
-F "file=@contract.pdf"
import fs from 'node:fs';
import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY! });
const file = await client.files.create({
file: fs.createReadStream('contract.pdf'),
purpose: 'user_data',
});
console.log(file.id);
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
with open("contract.pdf", "rb") as handle:
uploaded = client.files.create(file=handle, purpose="user_data")
print(uploaded.id)
file part and a purpose string (user_data for documents you will reference from chat messages) and returns the stored file object, including the id used in later requests.
List, fetch, download, delete
curl --fail-with-body "https://api.pre.dev/v1/files?limit=20" \
-H "Authorization: Bearer $PREDEV_API_KEY"
curl --fail-with-body "https://api.pre.dev/v1/files/$FILE_ID" \
-H "Authorization: Bearer $PREDEV_API_KEY"
curl --fail-with-body "https://api.pre.dev/v1/files/$FILE_ID/content" \
-H "Authorization: Bearer $PREDEV_API_KEY" -o file.bin
curl --fail-with-body -X DELETE "https://api.pre.dev/v1/files/$FILE_ID" \
-H "Authorization: Bearer $PREDEV_API_KEY"
order=asc for oldest first), 20 per page by default and at most 50 (limit). To page, pass last_id as after while has_more is true; after must be one of this workspace’s files, otherwise the call returns 404. purpose lists only files with that purpose. A page can hold fewer than limit files: a file whose read fails or takes more than 5 seconds is skipped, and a call that reaches 10 seconds leaves the rest for the next page. Skipped ids are in predev.skipped, which appears only when something was skipped; GET /v1/files/{id} fetches them.
Only files whose metadata says downloadable: true can be downloaded; a file you uploaded returns 400 from /content. In the SDKs these are client.files.list(), client.files.retrieve(id), client.files.content(id), and client.files.delete(id) (Node client.files.del(id) on older versions).
Use a file in a request
Reference the uploaded file from a chat message as afile content part, and add the file-parser plugin so models without native document input can read it. See multimodal.Authorizations
apiKeyAuthxApiKey
The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.
Body
multipart/form-data
Response
The stored file.
File metadata. id and filename are always present. The other fields follow one of two styles: object: "file", bytes, purpose and a Unix created_at, or type: "file", size_bytes, mime_type, downloadable and an ISO created_at.
Use it in a file content part as file_id.
Allowed value:
"file"Allowed value:
"file"Whether GET /v1/files/{id}/content can return the bytes.
Was this page helpful?

