ReqAnthropic.Files (ReqAnthropic v0.2.1)

Copy Markdown View Source

The Files API: upload files for use across multiple requests.

This is a beta endpoint and the files-api-2025-04-14 beta header is added automatically.

{:ok, file} = ReqAnthropic.Files.create(path: "report.pdf")
ReqAnthropic.Files.list()
ReqAnthropic.Files.delete(file["id"])

Summary

Functions

Download the raw bytes of a file.

Upload a file. Pass either :path (a path on disk) or :content (an iodata body) plus :filename. :content_type is optional but recommended.

Functions

content(id, opts \\ [])

@spec content(
  String.t(),
  keyword()
) :: {:ok, binary()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

Download the raw bytes of a file.

create(opts)

@spec create(keyword()) ::
  {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

Upload a file. Pass either :path (a path on disk) or :content (an iodata body) plus :filename. :content_type is optional but recommended.

delete(id, opts \\ [])

@spec delete(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

get(id, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}

list(opts \\ [])

@spec list(keyword()) ::
  {:ok, map()} | {:error, ReqAnthropic.Error.t() | Exception.t()}