---
title: "Upload a file"
method: POST
path: "/files"
tags: ["Files"]
---

# Upload a file

`POST /files`

Uploads 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`.

## Query parameters

- `workspace_id` string, uuid — Workspace to scope the request to. Defaults to the caller’s default workspace.
- `provider` 'openai' | 'anthropic' — Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage.

## Response `200`

The uploaded file metadata.

- union — A stored file. The shape is negotiated per request — see the endpoint description.
  - OpenRouterFile — A stored file in the OpenRouter superset shape: Anthropic-shaped, plus OpenRouter-only fields.
    - `_shape` 'openrouter', required
    - `created_at` string, required
    - `downloadable` boolean, required
    - `filename` string, required
    - `id` string, required
    - `mime_type` string, required
    - `size_bytes` integer, required
    - `type` 'file', required
  - OpenAIFile — A stored file in OpenAI's Files API shape.
    - `_shape` 'openai', required
    - `bytes` integer, required
    - `created_at` integer, required
    - `filename` string, required
    - `id` string, required
    - `object` 'file', required
    - `purpose` 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals' | 'assistants_output' | 'batch_output' | 'fine-tune-results', required
    - `status` 'processed', required
  - AnthropicFile — A stored file in Anthropic's Files API shape.
    - `_shape` 'anthropic', required
    - `created_at` string, required
    - `downloadable` boolean, required
    - `filename` string, required
    - `id` string, required
    - `mime_type` string, required
    - `size_bytes` integer, required
    - `type` 'file', required

## Other responses

- `400` — Bad Request - Invalid request parameters or malformed input
- `401` — Unauthorized - Authentication required or invalid credentials
- `403` — Forbidden - Authentication successful but insufficient permissions
- `413` — Payload Too Large - Request payload exceeds size limits
- `429` — Too Many Requests - Rate limit exceeded
- `500` — Internal Server Error - Unexpected server error
- `502` — Bad Gateway - Provider/upstream API failure
- `503` — Service Unavailable - Service temporarily unavailable

---

[API](https://skmtc.net/openrouterteam/apis/openrouter-api.md) · [All operations](https://skmtc.net/openrouterteam/apis/openrouter-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openrouterteam/openrouter-api/versions/fe902fcd8b57/schema)
