Skip to content
中文

Files in conversations

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.

qwen3.8-flash extracts the requested phrase from both text and PDF files; for the same PDF, deepseek-flash may return HTTP 200 but report a conversion failure and state 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. 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.

Next steps

  • Plugins: Convert PDFs, Office files and images before the call and reuse the parse.
  • Multimodal input: Send images and other inputs inline instead of uploading.
  • Limits and errors: Error codes, retry strategy and rate-limit numbers.