JavaScript & TypeScript
Attachments
Send files and images as attachments with your requests.
Supported Formats
Attachments can be sent in the following ways:
- Base64 encoded data: For files you have locally or want to upload directly
- Remote URLs: For files hosted on the web that the AI can access
Using URLs
Using Base64
Multiple Attachments
You can send multiple attachments in a single request:
Attachment Object Structure
Property | Type | Required | Description |
---|---|---|---|
file | string | Yes | The file data as base64 string or URL |
mimeType | string | No | The MIME type of the file (e.g., “image/png”, “application/pdf”). Auto-detected, but helps the AI understand the file type. |
Supported MIME Types
Common MIME types that work well with AI models:
Images
image/jpeg
- JPEG imagesimage/png
- PNG imagesimage/gif
- GIF imagesimage/webp
- WebP imagesimage/svg+xml
- SVG images
Documents
application/pdf
- PDF documentstext/plain
- Plain text filestext/markdown
- Markdown filesapplication/msword
- Word documentsapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
- Word documents (.docx)
Data
application/json
- JSON filestext/csv
- CSV filesapplication/xml
- XML files