Upload a file
Changed onUploads a file to be referenced in future API calls. The file is stored under the workspace of the authenticating API key. Maximum file size: 100 MB; empty files are rejected. The file type is determined from the file contents — not the filename or the declared content type — and must be a PDF, a PNG/JPEG/GIF/WebP image, a DOCX/XLSX/PPTX document, an MP3/WAV/FLAC/OGG audio file, or UTF-8 text. Text is reported by its structure as application/json, application/x-ndjson, text/csv, text/markdown, or text/plain.
Request
- Base URLhttps://openrouter.ai/api/v1
- AuthHTTP bearer
Query parameters
Workspace to scope the request to. Defaults to the caller’s default workspace.
Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage.
Request body multipart/form-data
Response
The uploaded file metadata.
A stored file. The shape is negotiated per request — see the endpoint description.
A stored file in the OpenRouter superset shape: Anthropic-shaped, plus OpenRouter-only fields.
A stored file in OpenAI's Files API shape.
A stored file in Anthropic's Files API shape.
Example response
{
"_shape": "openrouter",
"created_at": "2025-01-01T00:00:00Z",
"downloadable": false,
"filename": "document.pdf",
"id": "or_file_011CNha8iCJcU1wXNR6q4V8w",
"mime_type": "application/pdf",
"size_bytes": 1024000,
"type": "file"
}Changes
- info
added the non-success response with the status
- info
- breaking
added to the response body
oneOflist for the response status - breaking
the response's body type changed from
objectto no type for status
11 more changes in this revision
- breaking