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

> ## Agent Instructions
> The Venice API is OpenAI-compatible: use any OpenAI SDK with the base URL `https://api.venice.ai/api/v1` and a Venice API key, or pay per request from a USDC wallet through x402 with no account.
> Read model IDs from `GET /models` or `GET /models/traits` at runtime instead of hardcoding them from memory or from these pages. Models are added and retired often.
> Every model's price is in https://docs.venice.ai/pricing.md. Quote video and audio jobs with `POST /video/quote` or `POST /audio/quote` before you queue them.
> Search these docs from an MCP client at https://docs.venice.ai/mcp. The full agent guide is https://docs.venice.ai/agents.md.

# File Inputs

> Attach PDFs, documents, and source code to Venice chat completions for summarization.

File inputs let you attach documents and source files directly to a `/chat/completions` request. Venice extracts the file to text before sending it to the selected model, so you can ask questions, summarize, compare, or transform file content without building your own parser first.

Use file inputs when your prompt depends on the contents of a document, spreadsheet, markdown file, JSON file, or code file. They are request-scoped inputs, not persistent file storage, so include the file in each request that needs it.

> [!NOTE]
>
> File inputs use the OpenAI-compatible chat content array. Add a content block with `type: "file"` and provide the file content in `file.file_data`.

## Supported File Types

The chat API accepts file inputs as either base64 data URLs or publicly accessible URLs.

The maximum file size is **25MB per file**, measured after decoding a base64 data URL or after fetching a URL.

| Category | Formats |
| - | - |
| Documents | PDF, DOCX, PPTX |
| Spreadsheets | XLSX, XLS, CSV |
| Text and data | TXT, Markdown, JSON |
| Source code | Most common code files, including `.py`, `.js`, `.ts`, `.c`, `.cpp`, `.java`, `.go`, `.rs`, `.ps1`, `.sh`, `.yaml`, and `.sql` |

> [!NOTE]
>
> Files are extracted to text before inference. The extracted text counts toward the model's input context, so choose a model with enough `availableContextTokens` for the file plus your instructions and expected answer.

## Basic Usage

Send a `messages` array where the user message `content` is an array of text and file blocks:

```python Python theme={"system"}
import base64
import os
from pathlib import Path

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["VENICE_API_KEY"],
    base_url="https://api.venice.ai/api/v1",
)

path = Path("q3-report.pdf")
file_data = "data:application/pdf;base64," + base64.b64encode(path.read_bytes()).decode("utf-8")

response = client.chat.completions.create(
    model="openai-gpt-55",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Summarize this report in five bullets and list the main risks.",
                },
                {
                    "type": "file",
                    "file": {
                        "file_data": file_data,
                        "filename": "q3-report.pdf",
                    },
                },
            ],
        }
    ],
)

print(response.choices[0].message.content)
```

```javascript Node.js theme={"system"}
import OpenAI from "openai";
import { readFile } from "node:fs/promises";

const client = new OpenAI({
  apiKey: process.env.VENICE_API_KEY,
  baseURL: "https://api.venice.ai/api/v1",
});

const pdf = await readFile("q3-report.pdf");
const fileData = `data:application/pdf;base64,${pdf.toString("base64")}`;

const response = await client.chat.completions.create({
  model: "openai-gpt-55",
  messages: [
    {
      role: "user",
      content: [
        {
          type: "text",
          text: "Summarize this report in five bullets and list the main risks.",
        },
        {
          type: "file",
          file: {
            file_data: fileData,
            filename: "q3-report.pdf",
          },
        },
      ],
    },
  ],
});

console.log(response.choices[0].message.content);
```

```bash cURL theme={"system"}
PDF_BASE64=$(base64 < q3-report.pdf | tr -d '\n')

curl https://api.venice.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
  "model": "openai-gpt-55",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Summarize this report in five bullets and list the main risks."
        },
        {
          "type": "file",
          "file": {
            "file_data": "data:application/pdf;base64,$PDF_BASE64",
            "filename": "q3-report.pdf"
          }
        }
      ]
    }
  ]
}
EOF
```

## File URLs

If the file is already hosted at a public HTTP or HTTPS URL, pass the URL in `file_data` instead of base64 encoding it:

```json theme={"system"}
{
  "model": "openai-gpt-55",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Identify the governing law, renewal terms, and termination rights in this agreement."
        },
        {
          "type": "file",
          "file": {
            "file_data": "https://example.com/contracts/vendor-agreement.pdf",
            "filename": "vendor-agreement.pdf"
          }
        }
      ]
    }
  ]
}
```

> [!WARNING]
>
> Only use public URLs that Venice can fetch without authentication. For private files, send a base64 data URL.

## Multiple Files

You can include more than one file block in the same message. Put a short text instruction before the files so the model knows how to use them.

```json theme={"system"}
{
  "model": "openai-gpt-55",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Compare these two policy drafts. Return the material differences and recommend which version is clearer."
        },
        {
          "type": "file",
          "file": {
            "file_data": "data:application/pdf;base64,JVBERi0xLjQK...",
            "filename": "policy-v1.pdf"
          }
        },
        {
          "type": "file",
          "file": {
            "file_data": "data:application/pdf;base64,JVBERi0xLjQK...",
            "filename": "policy-v2.pdf"
          }
        }
      ]
    }
  ]
}
```

For best results, name each file clearly and refer to those names in your prompt.

## Data URLs

For local files, encode the file bytes as base64 and prefix them with the correct MIME type:

| File type | Data URL prefix |
| - | - |
| PDF | `data:application/pdf;base64,` |
| DOCX | `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,` |
| PPTX | `data:application/vnd.openxmlformats-officedocument.presentationml.presentation;base64,` |
| XLSX | `data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,` |
| CSV | `data:text/csv;base64,` |
| Markdown | `data:text/markdown;base64,` |
| Plain text | `data:text/plain;base64,` |
| JSON | `data:application/json;base64,` |

If you do not know the exact MIME type, use `application/octet-stream`. Including an accurate `filename` still helps Venice identify and display the file.

## Working With Large Files

Because files become prompt text, large files can increase latency, token usage, and cost. Keep the model's context window in mind.

The raw file must be 25MB or smaller. Base64 encoding increases request size by about 33%, so a file near the 25MB limit will produce a larger JSON request body.

Good patterns for large files:

* Ask for a specific task instead of a broad "analyze everything" prompt.
* Include only the documents needed for the current answer.
* Use models with larger `availableContextTokens` for long reports or codebases.
* Put stable, repeated documents before dynamic user questions if you are also using [prompt caching](https://docs.venice.ai/guides/features/prompt-caching.md).
* Use `stream: true` when you expect a long response.

### Request limits

* **Per file:** each file must be 25MB or smaller.
* **Images:** a single message can include up to 10 images. The cap applies per message, not per request.

### When a file fails

A file that can't be processed, for example because it exceeds the per-file size limit, does not fail the whole request. Venice replaces that file with an error note, the model still answers, and the request is billed as normal. If an answer seems to ignore a file, check that the file is within the limits above before retrying.

## File Inputs vs. Text Parser

Use chat file inputs when you want the model to reason over the file immediately.

Use the [Text Parser API](https://docs.venice.ai/api-reference/endpoint/augment/text-parser.md) when you want to extract text first, inspect the token count, store the extracted text in your own system, or send the same extracted text to multiple requests.

| Need | Use |
| - | - |
| Ask a model about a document in one request | Chat file input |
| Extract text without model inference | Text Parser API |
| Check extracted token count before prompting | Text Parser API |
| Reuse extracted text across many requests | Text Parser API, then include the text in prompts |

## Best Practices

* Include `filename` whenever possible, especially when sending multiple files.
* Put the instruction before the file blocks so the model knows the task before reading the extracted content.
* Use public URLs only for files that can be fetched without cookies, headers, or signed session state.
* Prefer base64 data URLs for private files or files generated inside your application.
* Ask focused questions and specify the output format you want.
* For structured extraction, combine file inputs with [structured responses](https://docs.venice.ai/guides/features/structured-responses.md).

## Troubleshooting

> [accordion] The model says it cannot access the file
>
> Make sure the message content uses an array and includes a `type: "file"` block. If you used a URL, verify it is publicly reachable without authentication.

> [accordion] The request is slow or expensive
>
> The file may extract to a large amount of text. Use a larger-context model, narrow the task, send fewer files, or pre-extract and trim the text with the Text Parser API.

> [accordion] The response ignores one of my files
>
> Give each file a descriptive `filename` and refer to the filenames directly in your prompt. For example, "Compare `policy-v1.pdf` against `policy-v2.pdf`."
>
> If the file failed to process, for example because it was over 25MB, the model receives an error note in its place and answers without it. See [When a file fails](#when-a-file-fails).

> [accordion] A model rejects the file content
>
> File inputs are available on compatible chat models. Check the [Models page](https://docs.venice.ai/models/overview.md) for current model capabilities and context limits, or try a current large-context text model.


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