Skip to main content

Installation

pip install agent-office

Documentation

View the full SDK on PyPI:

agent-office on PyPI

Complete Python SDK documentation and API reference

Quick Example

from agent_office import AgentOffice
from uuid import uuid4

# Initialize the client
client = AgentOffice(api_key="YOUR_API_KEY")

# Upload a document with tracked changes enabled
doc = client.documents.create(
    file="document.docx",
    return_markdown=True,
    tracked_changes=True,
    author_name="John Doe"
)

# Edit the document
edit = client.edit(
    doc_id=doc.doc_id,
    edit_uid=str(uuid4()),
    edit_instructions="Change the title to 'My New Title'",
    save_chunks_for_review=False
)

# Download the edited document
result = client.documents.download(doc_id=doc.doc_id)
print(result.download_url)

Features

  • 📝 Upload and convert documents (DOCX, PDF, etc.)
  • ✏️ AI-powered document editing
  • 📖 Read document content as Markdown
  • 💾 Download edited documents
  • 🔄 Track changes support

Error Handling

The SDK provides specific exception types for different error conditions:
from agent_office import (
    AgentOffice,
    AgentOfficeError,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    RateLimitError,
    ServerError,
)

client = AgentOffice(api_key="YOUR_API_KEY")

try:
    doc = client.documents.create("document.docx")
except AuthenticationError:
    print("Invalid API key")
except NotFoundError:
    print("Document not found")
except ValidationError as e:
    print(f"Validation error: {e.message}")
except RateLimitError:
    print("Rate limit exceeded")
except ServerError:
    print("Server error")
except AgentOfficeError as e:
    print(f"General error: {e.message}")