Skip to main content

Install the SDK

Install the Contextbase Python SDK using pip:
pip install contextbase

Requirements

  • Python 3.8 or higher
  • An active Contextbase account with API key

Get Your API Key

  1. Sign up at app.contextbase.dev
  2. Navigate to your account settings
  3. Generate a new API key
  4. Store it securely - you’ll need it for authentication

Quick Setup

Set your API key as an environment variable:
export CONTEXTBASE_API_KEY="your-api-key-here"
Or pass it directly when initializing the client:
from contextbase import Contextbase

client = Contextbase(api_key="your-api-key-here")

Verify Installation

Test your installation with a simple script:
from contextbase import Contextbase

# Initialize client
client = Contextbase()

# Test connection (this will fail gracefully if no API key is set)
try:
    response = client.resolve_context("test-context")
    print("✅ SDK installed successfully!")
except Exception as e:
    if "API key" in str(e):
        print("⚠️ SDK installed but API key not configured")
    else:
        print(f"❌ Installation issue: {e}")