Authenticating...

Sending files

Copy Page as Markdown

There are two ways to put a document in front of a SubQ model: inline the bytes as base64 on the request, or upload the file once and reference it by file_id. The part type depends on the endpoint:

Chat CompletionsResponses API
Part typefileinput_file
Inline base64file_dataNot supported
Uploaded filefile_idfile_id (required)

Inline a document on Chat Completions with a file part on a user message. On the Responses API, upload first and pass input_file with file_id.

Choosing an approach

Inline base64Uploaded file
Sent asfile_data on the requestfile_id from an earlier upload
Extra requestNonePOST /v1/files once per file
ReuseRe-sends the bytes every timeReference the same file_id repeatedly
Accepted formatsPDF and plain textPDF, plain text, JSON / JSONL, XML, and Word
SizeBounded by your request size50 MB per file
LifetimeRequest-scopedStored per organization until deleted

Inline base64 is the shortest path for a one-off Chat Completions request. Upload the file instead when you are calling Responses, when the same document is used across several requests, when it is large, or when it is a format inline input does not accept.

Inline base64

Inline file_data is Chat Completions only. Include a text part with your instruction, then one or more file parts for the documents.

cURLNode.jsTypeScriptPython

Set file_data to the base64-encoded file content. Do not use a data URL prefix such as data:application/pdf;base64,.

cURL with files

Use openssl base64 -A to inline local files without line wrapping. For remote files, download them first (for example with curl -fsS -o /tmp/report.pdf <url>), then base64-encode the local file as shown below. Avoid piping a remote download directly into the request body.

curl -sS -X POST https://api.subq.ai/v1/chat/completions \
  -H "Authorization: Bearer $SUBQ_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<EOF
{"model":"subq-preview","messages":[{"role":"user","content":[
{"type":"text","text":"Summarize these documents."},
{"type":"file","filename":"financial-report-2026.pdf","mime_type":"application/pdf","file_data":"$(openssl base64 -A -in /tmp/financial-report-2026.pdf)"},
{"type":"file","filename":"board-deck-q1.pdf","mime_type":"application/pdf","file_data":"$(openssl base64 -A -in /tmp/board-deck-q1.pdf)"},
{"type":"file","filename":"meeting-notes.txt","mime_type":"text/plain","file_data":"$(openssl base64 -A -in /tmp/meeting-notes.txt)"}
]}],"stream":false}
EOF

File part

FieldTypeRequiredDescription
typestringYesMust be "file".
filenamestringNoRecommended. File name to associate with the document, such as financial-report-2026.pdf or meeting-notes.txt.
mime_typestringYesMIME type for the file, such as "application/pdf" or "text/plain".
file_datastringYesBase64-encoded file content.

Accepted file types

Set mime_type to match the file you send.

CategoryExtensionsMIME type
PDF.pdfapplication/pdf
Plain text.txttext/plain

Other file types are rejected inline. Upload them instead — the Files API accepts a wider set.

Uploaded files

Upload the document once, then pass the id it returns as file_id. Chat Completions uses a file part; Responses uses input_file.

Chat Completions:

{
  "model": "subq-preview",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "Summarize this document." },
        { "type": "file", "file_id": "file_abc123" }
      ]
    }
  ]
}

Responses:

{
  "model": "subq-preview",
  "input": [
    { "type": "input_file", "file_id": "file_abc123" },
    { "type": "input_text", "text": "Summarize this document." }
  ]
}

An uploaded file is visible only to the organization that created it and stays available until you delete it. Non-text formats finish extracting text before they can be used — wait for status to reach processed. See Files API for upload mechanics, the full format list, and the file lifecycle. Responses does not accept inline file_data; see Responses input.

Notes

  • Use plain base64 in file_data; line wrapping is not required.
  • Multiple files are allowed per request.