> ## Documentation Index > Fetch the complete documentation index at: https://openrouter.ai/docs/llms.txt > Use this file to discover all available pages before exploring further. # Files > Files endpoints ## Overview Files endpoints ### Available Operations * [list](#list) - List files * [upload](#upload) - Upload a file * [delete](#delete) - Delete a file * [retrieve](#retrieve) - Get file metadata * [download](#download) - Download file content ## list Lists files belonging to the workspace of the authenticating API key. ### Example Usage ```python theme={null} from openrouter import OpenRouter import os with OpenRouter( http_referer="", x_open_router_title="", x_open_router_categories="", api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.files.list(provider="openai") while res is not None: # Handle items res = res.next() ``` ### Parameters | Parameter | Type | Required | Description | Example | | -------------------------- | ------------------------------------------------------------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | | `http_referer` | *Optional\[str]* | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional\[str]* | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional\[str]* | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | | `limit` | *Optional\[int]* | :heavy\_minus\_sign: | Maximum number of files to return (1–1000). | 100 | | `cursor` | *Optional\[str]* | :heavy\_minus\_sign: | Opaque pagination cursor from a previous response. | eyJjdXJzb3IiOiJvcl9maWxlXzAxMUNOaGE4aUNKY1Uxd1hOUjZxNFY4dyJ9 | | `workspace_id` | *Optional\[str]* | :heavy\_minus\_sign: | Workspace to scope the request to. Defaults to the caller’s default workspace. | a103d8b6-42f0-4e50-9a3c-bf41e2c3c1a7 | | `provider` | [Optional\[components.FileProvider\]](../../components/fileprovider.mdx) | :heavy\_minus\_sign: | Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage. | openai | | `after` | *Optional\[str]* | :heavy\_minus\_sign: | OpenAI-style forward cursor: the id to list after. | or\_file\_011CNha8iCJcU1wXNR6q4V8w | | `after_id` | *Optional\[str]* | :heavy\_minus\_sign: | Anthropic-style forward cursor: the id to list after. | or\_file\_011CNha8iCJcU1wXNR6q4V8w | | `before_id` | *Optional\[str]* | :heavy\_minus\_sign: | Anthropic-style reverse cursor. Not supported by OpenRouter storage. | or\_file\_011CNha8iCJcU1wXNR6q4V8w | | `order` | [Optional\[operations.Order\]](../../operations/order.mdx) | :heavy\_minus\_sign: | Sort direction. Only `asc` is supported by OpenRouter storage. | asc | | `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client. | | ### Response **[operations.ListFilesResponse](../../operations/listfilesresponse.mdx)** ### Errors | Error Type | Status Code | Content Type | | -------------------------------------- | ----------- | ---------------- | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.TooManyRequestsResponseError | 429 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.BadGatewayResponseError | 502 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## upload 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`. ### Example Usage ```python theme={null} from openrouter import OpenRouter import os with OpenRouter( http_referer="", x_open_router_title="", x_open_router_categories="", api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.files.upload(file={ "file_name": "example.file", "content": open("example.file", "rb"), }, provider="openai") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | Example | | -------------------------- | ------------------------------------------------------------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | `file` | [operations.UploadFileFile](../../operations/uploadfilefile.mdx) | :heavy\_check\_mark: | N/A | | | `http_referer` | *Optional\[str]* | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional\[str]* | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional\[str]* | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | | `workspace_id` | *Optional\[str]* | :heavy\_minus\_sign: | Workspace to scope the request to. Defaults to the caller’s default workspace. | a103d8b6-42f0-4e50-9a3c-bf41e2c3c1a7 | | `provider` | [Optional\[components.FileProvider\]](../../components/fileprovider.mdx) | :heavy\_minus\_sign: | Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage. | openai | | `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client. | | ### Response **[components.FileResponse](../../components/fileresponse.mdx)** ### Errors | Error Type | Status Code | Content Type | | -------------------------------------- | ----------- | ---------------- | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.PayloadTooLargeResponseError | 413 | application/json | | errors.TooManyRequestsResponseError | 429 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.BadGatewayResponseError | 502 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## delete Deletes a file owned by the requesting workspace. Deletion is irreversible. ### Example Usage ```python theme={null} from openrouter import OpenRouter import os with OpenRouter( http_referer="", x_open_router_title="", x_open_router_categories="", api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.files.delete(file_id="file_011CNha8iCJcU1wXNR6q4V8w", provider="openai") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | Example | | -------------------------- | ------------------------------------------------------------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | `file_id` | *str* | :heavy\_check\_mark: | N/A | or\_file\_011CNha8iCJcU1wXNR6q4V8w | | `http_referer` | *Optional\[str]* | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional\[str]* | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional\[str]* | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | | `workspace_id` | *Optional\[str]* | :heavy\_minus\_sign: | Workspace to scope the request to. Defaults to the caller’s default workspace. | a103d8b6-42f0-4e50-9a3c-bf41e2c3c1a7 | | `provider` | [Optional\[components.FileProvider\]](../../components/fileprovider.mdx) | :heavy\_minus\_sign: | Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage. | openai | | `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client. | | ### Response **[components.FileDeleteResponse](../../components/filedeleteresponse.mdx)** ### Errors | Error Type | Status Code | Content Type | | -------------------------------------- | ----------- | ---------------- | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.TooManyRequestsResponseError | 429 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.BadGatewayResponseError | 502 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## retrieve Retrieves metadata for a single file owned by the requesting workspace. ### Example Usage ```python theme={null} from openrouter import OpenRouter import os with OpenRouter( http_referer="", x_open_router_title="", x_open_router_categories="", api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.files.retrieve(file_id="file_011CNha8iCJcU1wXNR6q4V8w", provider="openai") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | Example | | -------------------------- | ------------------------------------------------------------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | `file_id` | *str* | :heavy\_check\_mark: | N/A | or\_file\_011CNha8iCJcU1wXNR6q4V8w | | `http_referer` | *Optional\[str]* | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional\[str]* | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional\[str]* | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | | `workspace_id` | *Optional\[str]* | :heavy\_minus\_sign: | Workspace to scope the request to. Defaults to the caller’s default workspace. | a103d8b6-42f0-4e50-9a3c-bf41e2c3c1a7 | | `provider` | [Optional\[components.FileProvider\]](../../components/fileprovider.mdx) | :heavy\_minus\_sign: | Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage. | openai | | `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client. | | ### Response **[components.FileResponse](../../components/fileresponse.mdx)** ### Errors | Error Type | Status Code | Content Type | | -------------------------------------- | ----------- | ---------------- | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.TooManyRequestsResponseError | 429 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.BadGatewayResponseError | 502 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | ## download Downloads the raw bytes of a file. Only files created server-side are downloadable; uploaded files return 400. ### Example Usage ```python theme={null} from openrouter import OpenRouter import os with OpenRouter( http_referer="", x_open_router_title="", x_open_router_categories="", api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.files.download(file_id="file_011CNha8iCJcU1wXNR6q4V8w", provider="openai") # Handle response print(res) ``` ### Parameters | Parameter | Type | Required | Description | Example | | -------------------------- | ------------------------------------------------------------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | `file_id` | *str* | :heavy\_check\_mark: | N/A | or\_file\_011CNha8iCJcU1wXNR6q4V8w | | `http_referer` | *Optional\[str]* | :heavy\_minus\_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | | `x_open_router_title` | *Optional\[str]* | :heavy\_minus\_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | | `x_open_router_categories` | *Optional\[str]* | :heavy\_minus\_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | | `workspace_id` | *Optional\[str]* | :heavy\_minus\_sign: | Workspace to scope the request to. Defaults to the caller’s default workspace. | a103d8b6-42f0-4e50-9a3c-bf41e2c3c1a7 | | `provider` | [Optional\[components.FileProvider\]](../../components/fileprovider.mdx) | :heavy\_minus\_sign: | Store or read this file on the named provider using your own API key for it. Omit to use OpenRouter storage. | openai | | `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | :heavy\_minus\_sign: | Configuration to override the default retry behavior of the client. | | ### Response **[httpx.Response](../../models/.mdx)** ### Errors | Error Type | Status Code | Content Type | | -------------------------------------- | ----------- | ---------------- | | errors.BadRequestResponseError | 400 | application/json | | errors.UnauthorizedResponseError | 401 | application/json | | errors.ForbiddenResponseError | 403 | application/json | | errors.NotFoundResponseError | 404 | application/json | | errors.TooManyRequestsResponseError | 429 | application/json | | errors.InternalServerResponseError | 500 | application/json | | errors.BadGatewayResponseError | 502 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |