EdgeQuake Python SDK

February 12, 2026 ยท View on GitHub

Official Python SDK for the EdgeQuake RAG API.

Features

  • Dual API: Synchronous (EdgeQuake) and asynchronous (AsyncEdgeQuake) clients
  • Type-safe: Full Pydantic v2 models for all request/response types
  • Streaming: SSE streaming for query and chat endpoints
  • Auto-pagination: Transparent iteration over paginated results
  • Auth: API key, JWT, and multi-tenant authentication
  • Retry: Automatic exponential backoff on 429/503 errors

Installation

pip install edgequake-sdk

For WebSocket support (async pipeline progress):

pip install edgequake-sdk[ws]

Quick Start

Sync Client

from edgequake import EdgeQuake

client = EdgeQuake(
    base_url="http://localhost:8080",
    api_key="your-api-key",
)

# Check health
health = client.health()
print(f"Status: {health.status}")

# Upload a document
doc = client.documents.upload(
    content="EdgeQuake is an advanced RAG framework...",
    title="About EdgeQuake",
)
print(f"Document ID: {doc.document_id}")

# Query the knowledge graph
result = client.query.execute(query="What is EdgeQuake?")
print(result.answer)

# Stream a query
for event in client.query.stream(query="Explain RAG"):
    if event.chunk:
        print(event.chunk, end="", flush=True)

Async Client

import asyncio
from edgequake import AsyncEdgeQuake

async def main():
    async with AsyncEdgeQuake(
        base_url="http://localhost:8080",
        api_key="your-api-key",
    ) as client:
        health = await client.health()
        print(f"Status: {health.status}")

        result = await client.query.execute(query="What is EdgeQuake?")
        print(result.answer)

asyncio.run(main())

๐Ÿ“ Resource Namespaces

The Python SDK provides access to 20+ resource namespaces:

NamespaceDescriptionExample
documentsDocument upload, retrieval, and managementclient.documents.upload(content="...")
queryRAG query execution (sync and streaming)client.query.execute(query="...")
graphKnowledge graph exploration and traversalclient.graph.get()
chatOpenAI-compatible chat completionsclient.chat.completions(messages=[...])
conversationsMulti-turn conversation managementclient.conversations.create(title="...")
authAuthentication (login, JWT refresh)client.auth.login(email="...", password="...")
operationsLong-running operation trackingclient.operations.list()
tenantsMulti-tenant management (admin only)client.tenants.create(name="...")
workspacesWorkspace managementclient.workspaces.stats(workspace_id="...")

API Coverage: 100+ endpoints across 9 core resources

For complete API reference, see docs/API.md.

โš™๏ธ Configuration

Configure the client with these options:

from edgequake import EdgeQuake

client = EdgeQuake(
    api_key="YOUR_API_KEY",                # Required: API authentication key
    base_url="http://localhost:8080",      # Server URL (default: http://localhost:8080)
    timeout=30,                            # Request timeout in seconds (default: 30)
    max_retries=3,                         # Retry attempts on failure (default: 3)
    workspace_id="my-workspace",           # Optional: Default workspace context
    tenant_id="my-tenant",                 # Optional: Multi-tenant context
)

Configuration Parameters:

ParameterTypeDefaultDescription
api_keystr-API key for authentication (required)
base_urlstrhttp://localhost:8080EdgeQuake server URL
timeoutint30Request timeout in seconds
max_retriesint3Number of retry attempts on failure
workspace_idstrNoneDefault workspace for multi-tenancy
tenant_idstrNoneTenant ID for multi-tenant setup

๐ŸŒ Environment Variables

The SDK reads these environment variables automatically:

VariablePurposeExample
EDGEQUAKE_API_KEYAPI authentication key (overrides parameter)sk-your-api-key-here
EDGEQUAKE_BASE_URLServer URLhttp://localhost:8080
EDGEQUAKE_URLAlternative to EDGEQUAKE_BASE_URLhttps://api.edgequake.example.com
EDGEQUAKE_WORKSPACE_IDDefault workspace IDmy-workspace
EDGEQUAKE_TENANT_IDTenant ID for multi-tenancytenant-123
EDGEQUAKE_TIMEOUTRequest timeout in seconds60

Example:

export EDGEQUAKE_API_KEY="your-api-key"
export EDGEQUAKE_BASE_URL="http://localhost:8080"
python your_script.py

Then in your code:

from edgequake import EdgeQuake

# Reads from environment variables automatically
client = EdgeQuake()

๐Ÿ’ก Examples

See the examples/ directory for complete, runnable examples:

ExampleDescription
basic_usage.pyHello world โ€” client setup, health check, simple query
document_upload.pyDocument management (upload, track, list, delete)
graph_exploration.pyNavigate the knowledge graph
query_demo.pyDifferent query modes (simple, hybrid, chat)
streaming_query.pyReal-time streaming responses (SSE)
error_handling.pyGraceful error handling patterns
configuration.pyAdvanced configuration and multi-environment setup
multi_tenant.pyTenant and workspace management

Run any example:

export EDGEQUAKE_API_KEY="your-key"
python examples/basic_usage.py

For detailed example descriptions, see examples/README.md.

Authentication

# API Key (recommended for server-side)
client = EdgeQuake(base_url="...", api_key="your-key")

# JWT Bearer token
client = EdgeQuake(base_url="...", jwt="eyJhbGciOi...")

# Multi-tenant
client = EdgeQuake(
    base_url="...",
    api_key="your-key",
    tenant_id="tenant-abc",
    workspace_id="workspace-xyz",
)

Requirements

  • Python >= 3.10
  • httpx >= 0.27
  • pydantic >= 2.0

๐Ÿ”ง Troubleshooting

Connection Errors

Problem: ConnectionError: [Errno 61] Connection refused
Solution: Ensure EdgeQuake server is running on base_url

# Check if server is reachable
curl http://localhost:8080/health

Authentication Errors

Problem: 401 Unauthorized
Solution: Verify that EDGEQUAKE_API_KEY is set correctly

echo $EDGEQUAKE_API_KEY  # Should print your API key

Timeout Errors

Problem: ReadTimeout: HTTPSConnectionPool
Solution: Increase timeout for long-running operations:

client = EdgeQuake(
    api_key="your-key",
    timeout=60  # Increase to 60 seconds
)

Streaming Issues

Problem: SSE connection drops or no output
Solution:

  1. Ensure output is flushed: print(chunk, end="", flush=True)
  2. Check network stability
  3. See docs/STREAMING.md for reconnection strategies

Import Errors

Problem: ModuleNotFoundError: No module named 'edgequake'
Solution: Install the SDK:

pip install edgequake-sdk

Empty Query Results

Problem: Queries return empty or "I don't know" responses
Solution: Upload and process documents first:

doc = client.documents.upload(content="...", title="...")
# Wait for processing to complete (check track_id status)

For more troubleshooting, see:

๐Ÿ“š Documentation

License

Apache License 2.0