Skip to main content

surface_file

Saves a generated or computed file and returns a time-limited download card in the chat. Use when the agent (or your code) has produced a file at runtime — reports, exports, CSVs, processed images, generated PDFs. Exactly one of content, content_base64, or source_path must be provided.

Parameters

Returns

On failure: { "error": "...", "details": { "hint": "..." } }.

Examples

Text content — CSV report

Text content — Markdown document

Binary content — PDF (JavaScript)

Binary content — PDF (Python)

Pair with render_ui to show a preview card alongside the download


Notes

  • Always registered.
  • Generated files are stored securely; the download link expires after expires_hours (default 24).
  • For files that already exist in data_public (not generated at runtime), use present_public_file instead.
  • For binary output, always base64-encode and pass via content_base64 — do not embed raw bytes in content.