upload_file
Upload a local file to xAI to attach it to later chats. Supports PDFs and text documents, returns a file ID for use in chat or agent calls.
Instructions
Upload a local file to xAI so it can be attached to later chats.
Supported types include PDFs and text documents (see xAI file docs). The
returned file ID can be passed to `chat_with_files` or `grok_agent`.
Args:
file_path: Absolute or relative path to the local file.
expires_after: Optional TTL in seconds. The file is deleted from xAI
automatically once it expires (omit to keep the file indefinitely).
Returns:
Markdown block with the assigned file ID, filename, and size.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| expires_after | No |