Skip to content

Commit b20a655

Browse files
docs(openai): document the PDF document-input support
Add a changeset (minor bump for `@tanstack/openai-base` and `@tanstack/ai-openai`) and a multimodal-content docs example for the new `document` content part support on the Responses adapter. The example uses `gpt-5.5`, one of the models that declares the `document` input modality; the "Supported modalities by model" list is expanded to include it and points readers at `model-meta.ts` for the full, authoritative list.
1 parent 260c0fc commit b20a655

3 files changed

Lines changed: 52 additions & 4 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'@tanstack/openai-base': minor
3+
'@tanstack/ai-openai': minor
4+
---
5+
6+
feat(ai-openai): support PDF `document` content parts in the Responses adapter.
7+
8+
`openaiText`'s Responses adapter now accepts PDF `document` content parts, for any model whose `model-meta` entry declares the `document` input modality. Base64 data sources are sent as `input_file` with a `file_data` data URL and a `filename` (from `metadata.filename`, defaulting to `document.pdf`). URL sources are sent as `input_file` with `file_url`.
9+
10+
```ts
11+
const adapter = openaiText('gpt-5.5')
12+
13+
const message = {
14+
role: 'user',
15+
content: [
16+
{ type: 'text', content: 'Summarize this document' },
17+
{
18+
type: 'document',
19+
source: { type: 'data', value: pdfBase64, mimeType: 'application/pdf' },
20+
metadata: { filename: 'report.pdf' },
21+
},
22+
],
23+
}
24+
```
25+
26+
Non-PDF MIME types are rejected before the request is sent — including pre-wrapped `data:` URLs whose media type disagrees with `mimeType` — so callers get an actionable message instead of an opaque provider `400`. `OpenAIDocumentMetadata` gains `filename` and `detail`. The Chat Completions adapter throws a document-specific error pointing here, since documents are Responses-only.

docs/advanced/multimodal-content.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ const response = await chat({
9494

9595
### OpenAI
9696

97-
OpenAI supports images and audio in their vision and audio models:
97+
OpenAI supports images, audio, and PDF documents in their vision, audio, and
98+
document-capable models:
9899

99100
```typescript
100101
import { openaiText } from '@tanstack/ai-openai'
101-
import { imageBase64 } from './data'
102+
import { imageBase64, pdfBase64 } from './data'
102103

103104
const adapter = openaiText('gpt-5.5')
104105

@@ -116,10 +117,30 @@ const message = {
116117
}
117118
```
118119

120+
```typescript
121+
import { pdfBase64 } from './data'
122+
123+
// PDF document via base64 data (the API requires a filename alongside
124+
// inline data; defaults to "document.pdf" when omitted)
125+
const documentMessage = {
126+
role: 'user',
127+
content: [
128+
{ type: 'text', content: 'Summarize this document' },
129+
{
130+
type: 'document',
131+
source: { type: 'data', value: pdfBase64, mimeType: 'application/pdf' },
132+
metadata: { filename: 'report.pdf' }
133+
}
134+
]
135+
}
136+
```
137+
119138
**Supported modalities by model:**
120-
- `gpt-5.2`, `gpt-5-mini`: text, image
139+
- `gpt-5.5`, `gpt-5.2`, `gpt-5-mini` (among others): text, image, PDF document
121140
- `gpt-4o-audio`: text, audio
122141

142+
Check each model's `supports.input` in `@tanstack/ai-openai`'s `model-meta.ts` for the authoritative per-model list.
143+
123144
### Anthropic
124145

125146
Anthropic's Claude models support images and PDF documents:

docs/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@
439439
{
440440
"label": "Multimodal Content",
441441
"to": "advanced/multimodal-content",
442-
"addedAt": "2026-04-15"
442+
"addedAt": "2026-04-15",
443+
"updatedAt": "2026-07-21"
443444
},
444445
{
445446
"label": "Per-Model Type Safety",

0 commit comments

Comments
 (0)