Upload File
Upload a file for text content extraction, image understanding, or video understanding. Supports text-based formats such as pdf, doc, and txt.
Supported Formats
Supported Formats
.pdf, .txt, .csv, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .md, .dot, .epub, .html, .json, .mobi, .log, .go, .h, .c, .cpp, .cxx, .cc, .cs, .java, .js, .css, .jsp, .php, .py, .py3, .asp, .yaml, .yml, .ini, .conf, .ts, .tsx, and more.Note: Image files no longer support content extraction (file-extract). For image understanding, upload images with purpose="image". See Use Vision Models.File Content Extraction Example
File Content Extraction Example
purpose="file-extract" if you want the model to use the extracted file contents as context.- python
- curl
- node.js
$MOONSHOT_API_KEY with your own API key, or set it as an environment variable before making the call.Multi-file Chat Example
Multi-file Chat Example
Image or Video Understanding
Image or Video Understanding
purpose="image" or purpose="video".Please refer to Using Vision Models for end-to-end examples.Authorizations
The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the API keys page in your dashboard.
Body
The file to upload
Specifies how the uploaded file will be processed. file-extract: extract content from text-based files (such as pdf, doc, txt); images are not supported; image: upload images for vision understanding; video: upload videos for video understanding; batch: upload JSONL files for batch processing
file-extract, image, video, batch Response
Uploaded file metadata
Unique file identifier
Object type
"file"
File size in bytes
Unix timestamp when the file was created
Original file name
Purpose used when uploading the file. file-extract: extract content from text-based files (such as pdf, doc, txt); images are not supported; image: upload images for vision understanding; video: upload videos for video understanding; batch: upload JSONL files for batch processing
file-extract, image, video, batch Processing status of the file
"ready"
Additional status details when processing fails or returns warnings