Skip to main content

Python SDK Overview

The surfacedocs package provides everything you need to save LLM-generated documents.

Exports

ExportTypePurpose
SurfaceDocsclassHTTP client for saving, reading, versioning, and managing documents
SYSTEM_PROMPTstrInstructions for LLMs to generate documents in the correct format
DOCUMENT_SCHEMAdictJSON schema for LLM structured output (generic)
OPENAI_DOCUMENT_SCHEMAdictSchema compatible with OpenAI strict mode
GEMINI_DOCUMENT_SCHEMAdictSchema compatible with Google Gemini’s response_schema
SearchResultdataclassA document search result
VersionResultdataclassResult from pushing or restoring a version
VersionSummarydataclassSummary of a document version

Initialization

Methods

MethodDescription
save(content, folder_id=None)Save a document from LLM JSON output
save_raw(title, blocks, ...)Save a document with explicit parameters
get_document(document_id)Retrieve a document by ID
search_documents(query, tag, ...)Search documents by title or tag
delete_document(document_id)Delete a document by ID
create_folder(name, parent_id=None)Create a new folder
list_folders(parent_id=None)List folders
push_version(document_id, content)Push a new version from LLM output
push_version_raw(document_id, title, blocks, ...)Push a version with explicit parameters
list_versions(document_id)List all versions of a document
get_version(document_id, version)Get a specific version with blocks
restore_version(document_id, version)Restore a previous version as latest

Error Handling

Environment Variables

VariableDescription
SURFACEDOCS_API_KEYAPI key (alternative to passing in constructor)