> ## 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 Claude Platform on AWS through Portkey

Portkey supports Anthropic's [Files API](https://docs.anthropic.com/en/docs/build-with-claude/files) (beta) for Claude Platform on AWS, enabling file upload, listing, retrieval, and deletion 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. Portkey 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] Python
>
> ```python theme={"system"}
> from portkey_ai import Portkey
>
> portkey = Portkey(
>     api_key="PORTKEY_API_KEY",
>     provider="@claude-platform-aws-provider"
> )
>
> file = portkey.files.create(
>     purpose="assistants",
>     file=open("document.pdf", "rb")
> )
>
> print(file.id)
> ```

> [tab] NodeJS
>
> ```js theme={"system"}
> import Portkey from 'portkey-ai';
> import fs from 'fs';
>
> const portkey = new Portkey({
>     apiKey: "PORTKEY_API_KEY",
>     provider: "@claude-platform-aws-provider"
> });
>
> const file = await portkey.files.create({
>     purpose: "assistants",
>     file: fs.createReadStream("document.pdf")
> });
>
> console.log(file.id);
> ```

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

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
> from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url=PORTKEY_GATEWAY_URL,
>     default_headers=createHeaders(
>         provider="@claude-platform-aws-provider",
>         api_key="PORTKEY_API_KEY"
>     )
> )
>
> 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 { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai';
> import fs from 'fs';
>
> const client = new OpenAI({
>     apiKey: "PORTKEY_API_KEY",
>     baseURL: PORTKEY_GATEWAY_URL,
>     defaultHeaders: createHeaders({
>         provider: "@claude-platform-aws-provider",
>         apiKey: "PORTKEY_API_KEY"
>     })
> });
>
> 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 chat completions:

> [tab] Python
>
> ```python theme={"system"}
> from portkey_ai import Portkey
>
> portkey = Portkey(api_key="PORTKEY_API_KEY")
>
> response = portkey.chat.completions.create(
>     model="@claude-platform-aws-provider/claude-sonnet-4-6",
>     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"}}
>         ]
>     }]
> )
>
> print(response.choices[0].message.content)
> ```

> [tab] NodeJS
>
> ```js theme={"system"}
> import Portkey from 'portkey-ai';
>
> const portkey = new Portkey({
>     apiKey: "PORTKEY_API_KEY"
> });
>
> const response = await portkey.chat.completions.create({
>     model: "@claude-platform-aws-provider/claude-sonnet-4-6",
>     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" } }
>         ]
>     }]
> });
>
> console.log(response.choices[0].message.content);
> ```

> [tab] REST
>
> ```sh theme={"system"}
> curl -X POST https://api.portkey.ai/v1/chat/completions \
>   -H "x-portkey-api-key: $PORTKEY_API_KEY" \
>   -H "anthropic-beta: files-api-2025-04-14" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "model": "@claude-platform-aws-provider/claude-sonnet-4-6",
>     "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] Python
>
> ```python theme={"system"}
> from portkey_ai import Portkey
>
> portkey = Portkey(
>     api_key="PORTKEY_API_KEY",
>     provider="@claude-platform-aws-provider"
> )
>
> files = portkey.files.list()
>
> print(files)
> ```

> [tab] NodeJS
>
> ```js theme={"system"}
> import Portkey from 'portkey-ai';
>
> const portkey = new Portkey({
>     apiKey: "PORTKEY_API_KEY",
>     provider: "@claude-platform-aws-provider"
> });
>
> const files = await portkey.files.list();
>
> console.log(files);
> ```

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

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
> from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url=PORTKEY_GATEWAY_URL,
>     default_headers=createHeaders(
>         provider="@claude-platform-aws-provider",
>         api_key="PORTKEY_API_KEY"
>     )
> )
>
> files = client.files.list()
>
> print(files)
> ```

> [tab] OpenAI NodeJS
>
> ```js theme={"system"}
> import OpenAI from 'openai';
> import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai';
>
> const client = new OpenAI({
>     apiKey: "PORTKEY_API_KEY",
>     baseURL: PORTKEY_GATEWAY_URL,
>     defaultHeaders: createHeaders({
>         provider: "@claude-platform-aws-provider",
>         apiKey: "PORTKEY_API_KEY"
>     })
> });
>
> const files = await client.files.list();
>
> console.log(files);
> ```

## Get file

> [tab] Python
>
> ```python theme={"system"}
> from portkey_ai import Portkey
>
> portkey = Portkey(
>     api_key="PORTKEY_API_KEY",
>     provider="@claude-platform-aws-provider"
> )
>
> file = portkey.files.retrieve(file_id="<file_id>")
>
> print(file)
> ```

> [tab] NodeJS
>
> ```js theme={"system"}
> import Portkey from 'portkey-ai';
>
> const portkey = new Portkey({
>     apiKey: "PORTKEY_API_KEY",
>     provider: "@claude-platform-aws-provider"
> });
>
> const file = await portkey.files.retrieve("<file_id>");
>
> console.log(file);
> ```

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

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
> from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url=PORTKEY_GATEWAY_URL,
>     default_headers=createHeaders(
>         provider="@claude-platform-aws-provider",
>         api_key="PORTKEY_API_KEY"
>     )
> )
>
> file = client.files.retrieve("<file_id>")
>
> print(file)
> ```

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

## Delete file

> [tab] Python
>
> ```python theme={"system"}
> from portkey_ai import Portkey
>
> portkey = Portkey(
>     api_key="PORTKEY_API_KEY",
>     provider="@claude-platform-aws-provider"
> )
>
> response = portkey.files.delete(file_id="<file_id>")
>
> print(response)
> ```

> [tab] NodeJS
>
> ```js theme={"system"}
> import Portkey from 'portkey-ai';
>
> const portkey = new Portkey({
>     apiKey: "PORTKEY_API_KEY",
>     provider: "@claude-platform-aws-provider"
> });
>
> const response = await portkey.files.delete("<file_id>");
>
> console.log(response);
> ```

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

> [tab] OpenAI Python
>
> ```python theme={"system"}
> from openai import OpenAI
> from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders
>
> client = OpenAI(
>     api_key="PORTKEY_API_KEY",
>     base_url=PORTKEY_GATEWAY_URL,
>     default_headers=createHeaders(
>         provider="@claude-platform-aws-provider",
>         api_key="PORTKEY_API_KEY"
>     )
> )
>
> response = client.files.delete("<file_id>")
>
> print(response)
> ```

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

## Supported file types

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

## See Also

* [Claude Platform on AWS integration overview](https://docs.portkey.ai/docs/integrations/llms/claude-platform-aws/claude-platform-aws.md)
* [Anthropic Files API documentation](https://docs.anthropic.com/en/docs/build-with-claude/files)

***

> [card] [Portkey is now PRISMA AIRS AI Gateway. See it in action.](https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey\&utm_medium=referral\&utm_campaign=prisma_airs\&utm_content=docs_nav#contact)
>
> Contact Us


## Related topics

- [Files](https://docs.portkey.ai/docs/integrations/llms/anthropic/files.md)


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