Files in conversations
Reference an uploaded image, text file or PDF by file ID.
See the file service for uploads, expiry, downloads and deletion.
Use file_id to reference images, text files or PDFs uploaded with purpose=user_data. Pass {"type":"file","file":{"file_id":"ID returned by upload"}} in message content. Acceptance does not guarantee that the selected model can read the content. Files uploaded for vision or assistants are not used as image input here.
Verified on Develop on 2026-10-13: qwen3.8-flash extracted the requested phrase from both text and PDF files. For the same PDF, deepseek-flash returned HTTP 200 but reported conversion failure (provider_rejected) and stated that the file was not read. Switch to a verified model or place extracted text directly in the message. HTTP 200 alone does not prove the file was read.
Image input still requires an image-capable model; this example uses qwen3-vl-plus.
Install openai and set PRAXIS_API_KEY. For Develop, set PRAXIS_API_BASE=https://api-develop.deepraxis.ai. The example uploads a tiny PNG, asks for a description and deletes the file.
import base64
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["PRAXIS_API_KEY"],
base_url=os.environ.get("PRAXIS_API_BASE", "https://api.deepraxis.com") + "/openai/v1",
)
image = base64.b64decode(
"iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAIAAABMXPacAAABWklEQVR4nO3OQQ0AMBAEofVv+iqDxzRBALvtg/wgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwgzg/i/CDOD+L8IM4P4vwg7gEgaMOyrMtNTwAAAABJRU5ErkJggg=="
)
file = client.files.create(file=("pixel.png", image, "image/png"), purpose="user_data")
try:
response = client.chat.completions.create(
model="qwen3-vl-plus",
max_tokens=80,
messages=[{"role": "user", "content": [
{"type": "text", "text": "Describe this image in one sentence."},
{"type": "file", "file": {"file_id": file.id}},
]}],
)
print(response.choices[0].message.content)
finally:
client.files.delete(file.id)Expected: a brief image description; the file is deleted when the request finishes.