> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sb0.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# File Uploads

> Learn how to send files to your agent

## Overview

You can send files to your agent by including them as base64-encoded parts in the request.

## File Part Structure

```json theme={null}
{
  "type": "file",
  "name": "data.csv",
  "mimeType": "text/csv",
  "base64": "YSxiCjIsMTIzCi0zLDQxMjQKMSw3Cg=="
}
```

### Fields

* **`type`** - Always `"file"` for file uploads
* **`name`** - Filename (e.g., `"data.csv"`, `"image.png"`)
* **`mimeType`** - MIME type (e.g., `"text/csv"`, `"image/png"`, `"application/pdf"`)
* **`base64`** - Base64-encoded file content

## Complete Example

```bash theme={null}
# The base64 string below decodes to a CSV file with content:
# a,b
# 2,123
# -3,4124
# 1,7

curl -N \
  -H "Content-Type: application/json" \
  -X POST http://127.0.0.1:8080/query \
  -d @- <<'EOF'
{
  "kwargs": {
    "session_id": "my-session"
  },
  "parts": [
    {
      "type": "file",
      "name": "test.csv",
      "mimeType": "text/csv",
      "base64": "YSxiCjIsMTIzCi0zLDQxMjQKMSw3Cg=="
    },
    {
      "type": "text",
      "text": "What's the sum of the first column"
    }
  ]
}
EOF
```

## Encoding Files to Base64

### With Python

```python theme={null}
import base64

with open('data.csv', 'rb') as f:
    encoded = base64.b64encode(f.read()).decode('utf-8')
    print(encoded)
```

### With Bash

```bash theme={null}
base64 -i data.csv
```

### With JavaScript

```javascript theme={null}
// In Node.js
const fs = require('fs');
const content = fs.readFileSync('data.csv');
const encoded = content.toString('base64');
console.log(encoded);

// In Browser
const file = document.getElementById('fileInput').files[0];
const reader = new FileReader();
reader.onload = (e) => {
  const base64 = e.target.result.split(',')[1];
  console.log(base64);
};
reader.readAsDataURL(file);
```

## Supported File Types

Your agent can receive any file type. Common examples:

* **Text files** - `.txt`, `.csv`, `.json`, `.md`
* **Images** - `.png`, `.jpg`, `.gif`, `.webp`
* **Documents** - `.pdf`, `.docx`, `.xlsx`
* **Code files** - `.py`, `.js`, `.html`, `.css`

<Note>
  The maximum file size depends on your deployment configuration and API limits.
</Note>

## Multiple Files

You can send multiple files in a single request:

```json theme={null}
{
  "parts": [
    {
      "type": "file",
      "name": "data1.csv",
      "mimeType": "text/csv",
      "base64": "..."
    },
    {
      "type": "file",
      "name": "data2.csv",
      "mimeType": "text/csv",
      "base64": "..."
    },
    {
      "type": "text",
      "text": "Compare these two files"
    }
  ],
  "kwargs": {}
}
```

## Next Steps

* Learn about [request format](/v0-docs/api-reference/request-format)
* Understand [response format](/v0-docs/api-reference/response-format)
