Sending files
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 Completions | Responses API | |
|---|---|---|
| Part type | file | input_file |
| Inline base64 | file_data | Not supported |
| Uploaded file | file_id | file_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 base64 | Uploaded file | |
|---|---|---|
| Sent as | file_data on the request | file_id from an earlier upload |
| Extra request | None | POST /v1/files once per file |
| Reuse | Re-sends the bytes every time | Reference the same file_id repeatedly |
| Accepted formats | PDF and plain text | PDF, plain text, JSON / JSONL, XML, and Word |
| Size | Bounded by your request size | 50 MB per file |
| Lifetime | Request-scoped | Stored 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.
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}
EOFFile part
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "file". |
filename | string | No | Recommended. File name to associate with the document, such as financial-report-2026.pdf or meeting-notes.txt. |
mime_type | string | Yes | MIME type for the file, such as "application/pdf" or "text/plain". |
file_data | string | Yes | Base64-encoded file content. |
Accepted file types
Set mime_type to match the file you send.
| Category | Extensions | MIME type |
|---|---|---|
.pdf | application/pdf | |
| Plain text | .txt | text/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.
Related
- Files API — upload, list, retrieve, and delete stored files.
- Chat Completions API —
fileparts onmessages. - Responses API —
input_fileparts oninput. - Models — supported model IDs.