The files endpoint stores a file once so you can reference it by id in any number of chat requests instead of re-encoding the bytes into every message. It follows the OpenAI files schema, so the openai SDK's files methods work without modification. Uploads and storage are free.
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://opendunes.com/api/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const file = await client.files.create({
file: fs.createReadStream("report.pdf"),
purpose: "user_data",
});
console.log(file.id);
Send a file content part carrying the file_id — the server inlines the bytes for you:
const completion = await client.chat.completions.create({
model: "google/gemini-2.5-flash",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Summarize this document." },
{ type: "file", file: { file_id: file.id } },
],
},
],
});
- Max 32 MB per file, 256 MB storage per account; files expire after 30 days.
- Supported types: images (png, jpeg, webp, gif), audio (mp3, wav, flac, m4a, ogg, aac), PDF, and plain text.
- The model must support the file's modality — vision for images, audio input for audio, file/PDF input for documents.
- List, retrieve, and delete are also available — see the Files guide for the full surface.
- Files guide — endpoints, limits, and reference semantics
- Files reference