> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Files

> Upload and manage files with Anthropic through Prisma AIRS AI Gateway

The AI Gateway supports Anthropic's [Files API](https://docs.anthropic.com/en/docs/build-with-claude/files) (beta), enabling you to upload, list, retrieve, and delete files through the gateway. Uploaded files can be referenced in chat completions using `file_id` instead of re-uploading content each request.

> [!NOTE]
>
> The Files API is in beta and requires the `files-api-2025-04-14` beta header. The AI Gateway sets this automatically for file endpoints when using the SDK. For cURL requests, include the `anthropic-beta: files-api-2025-04-14` header.

## Upload a file

> [tab] REST
>
> ```sh theme={"system"}
> curl -X POST https://aigw.portkey.ai/v1/files \
>   -H "Authorization: Bearer $PORTKEY_API_KEY" \
>   -H "x-portkey-provider: @anthropic" \
>   -H "anthropic-beta: files-api-2025-04-14" \
>   -F 'file=@"document.pdf"'
> ```

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url="https://aigw.portkey.ai/v1",
>     default_headers={"x-portkey-provider": "@anthropic"}
> )
>
> file = client.files.create(
>     purpose="assistants",
>     file=open("document.pdf", "rb")
> )
>
> print(file.id)
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai';
> import fs from 'fs';
>
> const client = new OpenAI({
>     apiKey: "PORTKEY_API_KEY",
>     baseURL: "https://aigw.portkey.ai/v1",
>     defaultHeaders: { "x-portkey-provider": "@anthropic" }
> });
>
> const file = await client.files.create({
>     purpose: "assistants",
>     file: fs.createReadStream("document.pdf")
> });
>
> console.log(file.id);
> ```

## Use uploaded files in chat completions

Once a file is uploaded, reference it by `file_id` in your chat completions requests:

> [tab] REST
>
> ```sh theme={"system"}
> curl -X POST https://aigw.portkey.ai/v1/chat/completions \
>   -H "Authorization: Bearer $PORTKEY_API_KEY" \
>   -H "anthropic-beta: files-api-2025-04-14" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "model": "@anthropic/claude-sonnet-4-5-20250929",
>     "max_tokens": 1024,
>     "messages": [
>       {
>         "role": "user",
>         "content": [
>           {
>             "type": "text",
>             "text": "Please summarize this document."
>           },
>           {
>             "type": "file",
>             "file": {
>               "file_id": "<file_id>",
>               "mime_type": "application/pdf"
>             }
>           }
>         ]
>       }
>     ]
>   }'
> ```

> [!NOTE]
>
> When using the SDK, the `anthropic-beta` header is set automatically for file endpoints. For chat completions with file references via cURL, include `anthropic-beta: files-api-2025-04-14` in your request headers.

## List files

> [tab] REST
>
> ```sh theme={"system"}
> curl https://aigw.portkey.ai/v1/files \
>   -H "Authorization: Bearer $PORTKEY_API_KEY" \
>   -H "x-portkey-provider: @anthropic" \
>   -H "anthropic-beta: files-api-2025-04-14"
> ```

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url="https://aigw.portkey.ai/v1",
>     default_headers={"x-portkey-provider": "@anthropic"}
> )
>
> files = client.files.list()
>
> print(files)
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai';
>
> const client = new OpenAI({
>     apiKey: "PORTKEY_API_KEY",
>     baseURL: "https://aigw.portkey.ai/v1",
>     defaultHeaders: { "x-portkey-provider": "@anthropic" }
> });
>
> const files = await client.files.list();
>
> console.log(files);
> ```

## Get file

> [tab] REST
>
> ```sh theme={"system"}
> curl https://aigw.portkey.ai/v1/files/<file_id> \
>   -H "Authorization: Bearer $PORTKEY_API_KEY" \
>   -H "x-portkey-provider: @anthropic" \
>   -H "anthropic-beta: files-api-2025-04-14"
> ```

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url="https://aigw.portkey.ai/v1",
>     default_headers={"x-portkey-provider": "@anthropic"}
> )
>
> file = client.files.retrieve("<file_id>")
>
> print(file)
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai';
>
> const client = new OpenAI({
>     apiKey: "PORTKEY_API_KEY",
>     baseURL: "https://aigw.portkey.ai/v1",
>     defaultHeaders: { "x-portkey-provider": "@anthropic" }
> });
>
> const file = await client.files.retrieve("<file_id>");
>
> console.log(file);
> ```

## Delete file

> [tab] REST
>
> ```sh theme={"system"}
> curl -X DELETE https://aigw.portkey.ai/v1/files/<file_id> \
>   -H "Authorization: Bearer $PORTKEY_API_KEY" \
>   -H "x-portkey-provider: @anthropic" \
>   -H "anthropic-beta: files-api-2025-04-14"
> ```

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url="https://aigw.portkey.ai/v1",
>     default_headers={"x-portkey-provider": "@anthropic"}
> )
>
> response = client.files.delete("<file_id>")
>
> print(response)
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai';
>
> const client = new OpenAI({
>     apiKey: "PORTKEY_API_KEY",
>     baseURL: "https://aigw.portkey.ai/v1",
>     defaultHeaders: { "x-portkey-provider": "@anthropic" }
> });
>
> const response = await client.files.delete("<file_id>");
>
> console.log(response);
> ```

## Supported file types

Anthropic's Files API supports the following file types:

| Type | MIME types |
| - | - |
| PDF | `application/pdf` |
| Images | `image/jpeg`, `image/png`, `image/gif`, `image/webp` |

## Limitations

* The Files API is only available on **direct Anthropic API** — it is not supported on Bedrock or Vertex AI
* Files API is currently in **beta** and requires the `files-api-2025-04-14` beta header for cURL requests
* Refer to [Anthropic's documentation](https://docs.anthropic.com/en/docs/build-with-claude/files) for the latest file size and rate limits


## Related topics

- [Files](https://docs.portkey.ai/docs/aigw/integrations/llms/claude-platform-aws/files.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.