POST
/
v1
/
files
curl -X POST "https://api.anthropic.com/v1/files" \
     -H "x-api-key: $ANTHROPIC_API_KEY" \
     -H "anthropic-version: 2023-06-01" \
     -H "anthropic-beta: files-api-2025-04-14" \
     -F "file=@/path/to/document.pdf"
{
  "created_at": "2023-11-07T05:31:56Z",
  "downloadable": false,
  "filename": "<string>",
  "id": "<string>",
  "mime_type": "<string>",
  "size_bytes": 1,
  "type": "file"
}

API файлов позволяет вам загружать и управлять файлами для использования с API Anthropic без необходимости повторной загрузки содержимого с каждым запросом. Для получения дополнительной информации об API файлов см. руководство разработчика по файлам.

API файлов в настоящее время находится в бета-версии. Чтобы использовать API файлов, вам нужно включить заголовок бета-функции: anthropic-beta: files-api-2025-04-14.

Пожалуйста, свяжитесь с нами через форму обратной связи, чтобы поделиться своим опытом использования API файлов.

Headers

anthropic-beta
string[]

Optional header to specify the beta version(s) you want to use.

To use multiple betas, use a comma separated list like beta1,beta2 or specify the header multiple times for each beta.

anthropic-version
string
required

The version of the Anthropic API you want to use.

Read more about versioning and our version history here.

x-api-key
string
required

Your unique API key for authentication.

This key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the Console. Each key is scoped to a Workspace.

Body

multipart/form-data
file
file
required

The file to upload

Response

200
application/json
Successful Response
created_at
string
required

RFC 3339 datetime string representing when the file was created.

filename
string
required

Original filename of the uploaded file.

Required string length: 1 - 500
id
string
required

Unique object identifier.

The format and length of IDs may change over time.

mime_type
string
required

MIME type of the file.

Required string length: 1 - 255
size_bytes
integer
required

Size of the file in bytes.

Required range: x >= 0
type
enum<string>
required

Object type.

For files, this is always "file".

Available options:
file
downloadable
boolean
default:false

Whether the file can be downloaded.