> ## 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 Prisma AIRS AI Gateway

The AI Gateway 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. 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

**REST**

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

**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": "@claude-platform-aws-provider"}
)

file = client.files.create(
    purpose="assistants",
    file=open("document.pdf", "rb")
)

print(file.id)
```

**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": "@claude-platform-aws-provider" }
});

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:

**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": "@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

**REST**

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

**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": "@claude-platform-aws-provider"}
)

files = client.files.list()

print(files)
```

**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": "@claude-platform-aws-provider" }
});

const files = await client.files.list();

console.log(files);
```

## Get file

**REST**

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

**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": "@claude-platform-aws-provider"}
)

file = client.files.retrieve("<file_id>")

print(file)
```

**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": "@claude-platform-aws-provider" }
});

const file = await client.files.retrieve("<file_id>");

console.log(file);
```

## Delete file

**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: @claude-platform-aws-provider" \
  -H "anthropic-beta: files-api-2025-04-14"
```

**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": "@claude-platform-aws-provider"}
)

response = client.files.delete("<file_id>")

print(response)
```

**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": "@claude-platform-aws-provider" }
});

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/aigw/integrations/llms/claude-platform-aws/claude-platform-aws.md)
* [Anthropic Files API documentation](https://docs.anthropic.com/en/docs/build-with-claude/files)


## Related topics

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


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