Documentation Index
Fetch the complete documentation index at: https://developers.datagrid.com/llms.txt
Use this file to discover all available pages before exploring further.
Files enable you to pass documents, PDFs, images, and other file types to the converse API. This guide shows you how to upload files and include them in your conversations.
import os
from datagrid_ai import Datagrid
client = Datagrid(api_key=os.environ.get("DATAGRID_API_KEY"))
# Step 1: Upload a file
with open("report.pdf", "rb") as file:
uploaded_file = client.files.create(file=file)
# Step 2: Include the file in a conversation
response = client.converse(
prompt=[
{
"role": "user",
"content": [
{"type": "input_text", "text": "Summarize this document"},
{"type": "input_file", "file_id": uploaded_file.id}
]
}
]
)
print(response.content[0].text)