Skip to main content

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.

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.
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.
CategoryFormats
DocumentsPDF, DOCX, PPTX
SpreadsheetsXLSX, XLS, CSV
Text and dataTXT, Markdown, JSON
Source codeMost common code files, including .py, .js, .ts, .c, .cpp, .java, .go, .rs, .ps1, .sh, .yaml, and .sql
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:
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)

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:
{
  "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"
          }
        }
      ]
    }
  ]
}
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.
{
  "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 typeData URL prefix
PDFdata:application/pdf;base64,
DOCXdata:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,
PPTXdata:application/vnd.openxmlformats-officedocument.presentationml.presentation;base64,
XLSXdata:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,
CSVdata:text/csv;base64,
Markdowndata:text/markdown;base64,
Plain textdata:text/plain;base64,
JSONdata: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.
  • Use stream: true when you expect a long response.

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 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.
NeedUse
Ask a model about a document in one requestChat file input
Extract text without model inferenceText Parser API
Check extracted token count before promptingText Parser API
Reuse extracted text across many requestsText 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.

Troubleshooting

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.
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.
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.”
File inputs are available on compatible chat models. Check the Models page for current model capabilities and context limits, or try a current large-context text model.