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 — all uploads and storage are free.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://opendunes.com/api/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)
uploaded = client.files.create(
file=open("report.pdf", "rb"),
purpose="user_data",
)
print(uploaded.id)
Send a file content part carrying the file_id — the server inlines the bytes for you:
completion = 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": uploaded.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.
client.files.list(), client.files.retrieve(id), and client.files.delete(id) manage stored files — see the Files guide for the full surface.
- Files guide — endpoints, limits, and reference semantics
- Files reference