# `LangChain.FileUploader`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L1)

Behaviour for uploading files to LLM providers.

Provides a unified interface for uploading files to OpenAI, Anthropic,
and Google Gemini. Each provider returns a `LangChain.FileUploader.FileResult`
containing the file reference needed for subsequent API calls.

## Usage

    # OpenAI
    {:ok, uploader} = LangChain.FileUploader.FileOpenAI.new(%{api_key: "sk-..."})
    {:ok, result} = LangChain.FileUploader.upload(uploader, file_bytes, %{
      filename: "doc.pdf",
      mime_type: "application/pdf"
    })
    result.file_id
    #=> "file-abc123"

    # Google Gemini
    {:ok, uploader} = LangChain.FileUploader.FileGoogle.new(%{api_key: "AI..."})
    {:ok, result} = LangChain.FileUploader.upload(uploader, file_bytes, %{
      filename: "doc.pdf",
      mime_type: "application/pdf"
    })
    result.file_uri
    #=> "https://generativelanguage.googleapis.com/v1beta/files/..."

## File Metadata

The `file_meta` map passed to `upload/3` accepts the following keys:

- `:filename` (required) - The name to give the uploaded file.
- `:mime_type` (required) - The MIME type of the file content.
- `:purpose` - Provider-specific purpose string. Used by OpenAI
  (e.g. `"user_data"`, `"assistants"`). Ignored by other providers.
- `:display_name` - A human-readable display name. Used by Google.
  Falls back to `:filename` if not provided.

# `delete_result`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L53)

```elixir
@type delete_result() :: :ok | {:error, LangChain.LangChainError.t()}
```

# `file_meta`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L44)

```elixir
@type file_meta() :: %{
  :filename =&gt; String.t(),
  :mime_type =&gt; String.t(),
  optional(:purpose) =&gt; String.t(),
  optional(:display_name) =&gt; String.t()
}
```

# `get_result`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L52)

```elixir
@type get_result() ::
  {:ok, LangChain.FileUploader.FileResult.t()}
  | {:error, LangChain.LangChainError.t()}
```

# `list_result`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L54)

```elixir
@type list_result() ::
  {:ok, [LangChain.FileUploader.FileResult.t()]}
  | {:error, LangChain.LangChainError.t()}
```

# `upload_result`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L51)

```elixir
@type upload_result() ::
  {:ok, LangChain.FileUploader.FileResult.t()}
  | {:error, LangChain.LangChainError.t()}
```

# `delete`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L70)
*optional* 

```elixir
@callback delete(
  config :: struct(),
  file_ref :: LangChain.FileUploader.FileResult.t() | String.t()
) ::
  delete_result()
```

Delete a previously uploaded file by its ID or URI.

# `get`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L65)
*optional* 

```elixir
@callback get(
  config :: struct(),
  file_ref :: LangChain.FileUploader.FileResult.t() | String.t()
) ::
  get_result()
```

Retrieve metadata for a previously uploaded file by its ID.

# `list`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L75)
*optional* 

```elixir
@callback list(config :: struct()) :: list_result()
```

List files previously uploaded to the provider.

# `upload`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L59)

```elixir
@callback upload(config :: struct(), file_bytes :: binary(), file_meta :: file_meta()) ::
  upload_result()
```

Upload file bytes to the provider and return a FileResult on success.

# `delete`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L109)

```elixir
@spec delete(
  struct(),
  LangChain.FileUploader.FileResult.t() | String.t()
) :: delete_result()
```

Delete a file using any configured uploader implementation.

Returns an error if the provider does not implement `delete/2`.

# `get`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L95)

```elixir
@spec get(
  struct(),
  LangChain.FileUploader.FileResult.t() | String.t()
) :: get_result()
```

Retrieve file metadata using any configured uploader implementation.

Returns an error if the provider does not implement `get/2`.

# `list`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L123)

```elixir
@spec list(struct()) :: list_result()
```

List files using any configured uploader implementation.

Returns an error if the provider does not implement `list/1`.

# `upload`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.4/lib/file_uploaders/file_uploader.ex#L85)

```elixir
@spec upload(struct(), binary(), file_meta()) :: upload_result()
```

Upload a file using any configured uploader implementation.

Delegates to the provider module's `upload/3` callback.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
