Skip to main content

Documents

The Python SDK exposes the canonical document viewer through client.documents. Use it when you need full parsed text for a preview, editor, or custom document UI.

Attachments

from agentflow import AsyncAgentFlow

async with AsyncAgentFlow.from_profile("local") as client:
    document = await client.documents.attachment("file_abc123")
    print(document.filename)
    print(document.content)
For agent-scoped attachment checks, pass agent:
document = await client.documents.attachment("file_abc123", agent="agent_abc123")
client.attachments.content(file_id, agent=...) returns the same model and uses the canonical viewer endpoint under the hood.

Knowledge Base Documents

Prefer document_id from client.knowledge_bases.list_files(...) or client.knowledge_bases.list_documents(...).
files = await client.knowledge_bases.list_files("kb_abc123")
document = await client.documents.knowledge_base(
    "kb_abc123",
    document_id=files[0].document_id,
)

print(document.file_type)
print(document.content)
You can also call the KB convenience method:
document = await client.knowledge_bases.view_document(
    "kb_abc123",
    document_id="doc_abc123",
)
Use file_path only when the caller has a source path but no document ID:
document = await client.documents.knowledge_base(
    "kb_abc123",
    file_path="handbook.md",
)

Response Model

All viewer helpers return DocumentContent.
FieldTypeDescription
filenamestrDisplay filename
file_pathstr | NoneSource path or viewer path
contentstrFull parsed text
sizeintSource file size in bytes when available
last_modifieddatetime | NoneLast modified timestamp when available
file_typestr | NoneFile extension/type label
encodingstr | NoneText encoding
summarystr | NoneAttachment summary when available