Current collected state Current
Observed since 20 Oct, 22:48 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Python SDK for Agent Office API - AI-powered document editing
Python SDK for the Agent Office API - AI-powered document editing for agentic workflows.
pip install agent-office
from agent_office import AgentOffice
from uuid import uuid4
# Initialize the client
client = AgentOffice(api_key="sk_ao_your_api_key") # Get your key from https://agentoffice.dev
# Upload a document
doc = client.documents.create(
file="document.docx",
return_markdown=True
)
print(f"Uploaded: {doc.doc_id}")
# Edit the document
edit = client.edit(
doc_id=doc.doc_id,
edit_uid=str(uuid4()),
edit_instructions="Change the title to 'My New Title'",
tracked_changes=False
)
print(f"Edit applied: {edit.edit_applied}")
# Download the edited document
result = client.documents.download(doc_id=doc.doc_id)
print(f"Download URL: {result.download_url}")
# You can then download the file using requests
import requests
response = requests.get(result.download_url)
with open(f"edited_{doc.name}", "wb") as f:
f.write(response.content)
client = AgentOffice(
api_key="sk_ao_your_api_key", # Required: Your API key
base_url="https://api.agentoffice.dev", # Optional: API base URL
timeout=60 # Optional: Request timeout in seconds
)
doc = client.documents.create(
file="path/to/document.docx", # File path or file-like object
return_markdown=True, # Return markdown content
ttl_seconds=3600 # Time to live in seconds (300-21600)
)
doc = client.documents.create_from_url(
file_url="https://example.com/document.docx",
ttl_seconds=3600
)
docs = client.documents.list()
for doc in docs.documents:
print(f"{doc.name}: {doc.doc_id}")
result = client.documents.download(
doc_id="doc-id",
expires_in=3600 # Presigned URL expiration in seconds
)
print(result.download_url)
result = client.documents.exists(doc_id="doc-id")
if result.exists:
print(f"Document exists: {result.document.name}")
edit = client.edit(
doc_id="doc-id",
edit_uid=str(uuid4()), # Unique identifier for the edit
edit_instructions="Change the title to 'My New Title'", # Natural language instructions
lookup_text="Section 1", # Optional: Text to locate edit position
tracked_changes=False, # Enable track changes
use_large_model=False # Use larger AI model
)
result = client.read(doc_id="doc-id")
print(result.markdown)
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="sk_ao_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}")
git clone https://github.com/agentoffice/python-sdk.git
cd python-sdk
pip install -e .
pip install -e ".[dev]"
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.0.4 | 20 Oct 2025 | 5 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:48 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:603bf0b96ebb1fd63c7a53a5e05a83fd5c412f409408bea2de2ba8fa71b43f11