Skip to main content

Overview

Acontext provides official SDKs for Python and TypeScript/JavaScript, making it easy to integrate Acontext into your applications. The SDKs handle authentication, request formatting, and provide type-safe interfaces to all Acontext features.

Installation

Requirements

  • Python 3.10 or newer
  • pip (Python package installer)

Install via pip

pip install acontext
If you’re using uv for faster Python package management:
uv add acontext
The Python SDK automatically includes dependencies for OpenAI and Anthropic message formats.

Quick Start

After installation, verify your setup with a quick connection test:
from acontext import AcontextClient

# Initialize the client
client = AcontextClient(
    api_key="sk-ac-your-root-api-bearer-token",
    base_url="http://localhost:8029/api/v1"
)

# Test the connection
try:
    client.ping()
    print("✓ Connected to Acontext successfully!")
except Exception as e:
    print(f"✗ Connection failed: {e}")
If you see the success message, you’re ready to start using Acontext!

Async Support

The Python SDK provides both synchronous and asynchronous clients:
from acontext import AsyncAcontextClient

async def main():
    client = AsyncAcontextClient(
        api_key="sk-ac-your-root-api-bearer-token",
        base_url="http://localhost:8029/api/v1"
    )
    
    session = await client.sessions.create()
    print(f"Session created: {session.id}")
    
    await client.close()

# Run with asyncio
import asyncio
asyncio.run(main())
Use AsyncAcontextClient for better performance in async applications and when handling multiple concurrent operations.

Troubleshooting

  • Verify your Acontext server is running
  • Check that the base_url is correct
  • Ensure no firewall is blocking the connection
  • For local development, confirm you’re using http://localhost:8029/api/v1
  • Verify your API key is correct
  • Check that the API key has the necessary permissions
  • Ensure you’re passing the API key in the correct format
  • Confirm the package is installed: pip list | grep acontext (Python) or npm list @acontext/acontext (TypeScript)
  • Try reinstalling the package
  • Check your Python version is 3.10+ or Node.js version is 16+
  • Ensure you’re using TypeScript 4.5 or newer
  • Run npm install to ensure all type definitions are installed
  • Check that your tsconfig.json has proper settings for module resolution

Next Steps