Octopodas
    Docs/Getting Started/Python SDK

    Python SDK

    Full control over agent memory from any Python app.

    Install

    bash
    pip install octopoda

    Requires Python 3.9+. Dependencies: requests and pydantic.


    Quick Start

    python
    from octopoda import Octopoda
     
    client = Octopoda(api_key="sk-octopoda-YOUR_KEY")
    agent = client.agent("my-agent")
     
    # Store a memory
    agent.write("user:name", "Alice")
     
    # Read it back
    name = agent.read("user:name")
    print(name) # Alice
     
    # Search by meaning
    results = agent.search("what is the user's name?")
    print(results)

    Tip: Check octopodas.com/dashboard — you should see "my-agent" with 1 memory.


    Client Methods

    python
    client = Octopoda(
    api_key="sk-octopoda-...", # or set OCTOPODA_API_KEY env var
    base_url="https://api.octopodas.com", # default
    timeout=30, # seconds
    )
    MethodReturnsDescription
    client.agent("id")AgentCreate or reconnect to an agent
    client.agents()listList all your agents
    client.me()dictYour account info
    client.system_metrics()dictSystem-wide metrics
    client.shared_spaces()listList shared memory spaces
    client.read_shared("space", "key")dictRead from shared space
    client.close()Close the HTTP session

    Agent Methods

    MethodReturnsDescription
    agent.write(key, value, tags=None)dictStore a memory
    agent.write_batch(items)dictStore multiple: [{"key": "k", "value": "v"}]
    agent.read(key)value or NoneRead a memory
    agent.list(limit=50)dictList all memories
    agent.search(query, limit=10)listSemantic search
    agent.keys(prefix="", limit=50)listSearch by key prefix
    agent.history(key)listAll versions of a memory
    agent.info()dictAgent details
    agent.delete()dictDeregister agent

    Memory Management

    python
    # Delete specific memory
    agent.forget("old_key")
     
    # Delete old memories (preserves critical importance)
    agent.forget_stale(max_age_seconds=604800) # 7 days
     
    # Delete by tag
    agent.forget_by_tag("temporary")
     
    # Find duplicates (preview — changes nothing)
    report = agent.consolidate(dry_run=True)
    print(f"Found {report['duplicate_groups']} duplicate groups")
     
    # Merge duplicates (keeps newest, removes duplicates)
    result = agent.consolidate(dry_run=False)
     
    # Memory health score
    health = agent.memory_health()
    print(f"Score: {health['score']}/100")
    for issue in health['issues']:
    print(f" - {issue}")

    Goal Tracking

    python
    agent.set_goal("Migrate database", milestones=["Backup", "Migrate", "Validate"])
    agent.update_progress(milestone_index=0, note="Backup done")
    goal = agent.get_goal()
    # {"progress": 0.33, "status": "active"}

    Agent Messaging

    python
    agent.send_message("agent_b", "Found a bug", message_type="alert")
    messages = agent.read_messages(unread_only=True)
    agent.broadcast("Deployment starting")

    Export & Import

    python
    bundle = agent.export_memories() # Export as JSON
    agent.import_memories(bundle, overwrite=False) # Import (skip existing)


    Advanced Writes

    MethodReturnsDescription
    agent.write_ttl("key", "val", ttl_seconds=3600)dictAuto-expiring memory
    agent.write_important("key", "val", importance="critical")dictWrite with importance level
    agent.write_safe("key", "val")dictWrite with conflict check
    agent.check_conflicts("key", "new_val")dictCheck before writing
    agent.flush()Wait for background processing

    Process Conversation (Recommended)

    The easiest way to add memory. Pass your conversation and Octopoda extracts knowledge automatically:

    python
    result = agent.process_conversation([
    {"role": "user", "content": "I'm Alice, CTO at TechCorp"},
    {"role": "assistant", "content": "Nice to meet you! How can I help?"},
    {"role": "user", "content": "We need to optimize our ML pipeline"},
    ])
     
    print(f"Stored {result['memories_stored']} memories")
     
    # Get relevant context for a query
    context = agent.get_context("what does the user want?")
    print(context)

    Other Utility Methods

    MethodReturnsDescription
    agent.decide("deploy", "all tests passed")dictLog a decision with reasoning
    agent.audit()listGet audit trail
    agent.recover()dictCrash recovery
    agent.share("space", "key", "value")dictWrite to shared memory
    agent.share_safe("space", "key", "value")dictShared with conflict detection
    agent.snapshot("before_deploy")dictCreate checkpoint
    agent.restore("before_deploy")dictRollback to checkpoint

    Rate Limits

    PlanRate Limit
    Free100 requests/min
    Pro300 requests/min
    Business1,000 requests/min
    Scale5,000 requests/min

    Using AI to Set Up

    Paste this into Cursor or Claude Code:

    text
    Install Octopoda memory for my Python project:
     
    1. Run: pip install octopoda
    2. Test it with this code:
     
    from octopoda import Octopoda
    client = Octopoda(api_key="sk-octopoda-MY_KEY_HERE")
    agent = client.agent("test-agent")
    result = agent.write("test", "hello world")
    print("Write:", result)
    value = agent.read("test")
    print("Read:", value)
     
    Tell me if both succeed.

    Troubleshooting

    "ModuleNotFoundError: No module named 'octopoda'"

    Run pip install octopoda. If using Python 3, try pip3 install octopoda.

    "Invalid API key" or 401 errors

    Check your key starts with sk-octopoda-. Get it from octopodas.com/dashboard/settings.

    "Connection refused" or timeout

    Open https://api.octopodas.com/health in your browser. If it shows {"status": "ok"}, the server is fine — check your firewall/VPN.

    Import works but methods fail

    Make sure you're on the latest version: pip install octopoda --upgrade


    Monitor Your Agents

    Once set up, your agent's memories appear in real-time on your dashboard. See stored memories, search quality, knowledge graph, and agent performance, all from your browser.

    Open Dashboard
    Octopoda featured on There's an AI for That