Open-Dedalus Python SDK

August 23, 2025 ยท View on GitHub

Open-source implementation of the Dedalus Labs SDK with BYOK (Bring Your Own Key) support.

Features

  • Multi-Provider Support: Works with OpenAI, Anthropic, Google Gemini, and 10+ other AI providers
  • BYOK (Bring Your Own Key): Use your own API keys from any supported provider
  • Tool Execution: Execute Python functions as tools with automatic schema generation
  • Streaming Support: Real-time streaming responses
  • Multi-Model Handoffs: Intelligent routing between different models
  • Policy System: Dynamic behavior control during execution
  • MCP Integration: Model Context Protocol support (coming soon)

Supported Providers

ProviderEnvironment VariableModels
OpenAIOPENAI_API_KEYgpt-4, gpt-4o-mini, etc.
AnthropicANTHROPIC_API_KEYclaude-3-5-sonnet, etc.
GoogleGOOGLE_API_KEYgemini-pro, etc.
Fireworks AIFIREWORKS_API_KEYVarious models
xAIXAI_API_KEYgrok models
PerplexityPERPLEXITY_API_KEYsonar models
DeepSeekDEEPSEEK_API_KEYdeepseek models
GroqGROQ_API_KEYFast inference models
CohereCOHERE_API_KEYcommand models
Together AITOGETHERAPI_KEYVarious models
CerebrasCEREBRAS_API_KEYcerebras models
MistralMISTRAL_API_KEYmistral models

Quick Start

Installation

# Install from source
git clone https://github.com/your-username/open-dedalus.git
cd open-dedalus/python
pip install -e .

# Or install with development dependencies
pip install -e .[dev]

Basic Usage

import asyncio
from dedalus_labs import AsyncDedalus, DedalusRunner
from dotenv import load_dotenv

load_dotenv()

async def main():
    client = AsyncDedalus()
    runner = DedalusRunner(client)

    response = await runner.run(
        input="What is the capital of France?",
        model="openai/gpt-4o-mini"
    )

    print(response.final_output)

if __name__ == "__main__":
    asyncio.run(main())

Using Tools

import asyncio
from dedalus_labs import AsyncDedalus, DedalusRunner
from dotenv import load_dotenv

load_dotenv()

def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

def multiply(a: int, b: int) -> int:
    """Multiply two numbers."""
    return a * b

async def main():
    client = AsyncDedalus()
    runner = DedalusRunner(client)

    result = await runner.run(
        input="Calculate (15 + 27) * 2", 
        model="openai/gpt-4o-mini", 
        tools=[add, multiply]
    )

    print(f"Result: {result.final_output}")

if __name__ == "__main__":
    asyncio.run(main())

Streaming

import asyncio
from dedalus_labs import AsyncDedalus, DedalusRunner
from dedalus_labs.utils.streaming import stream_async
from dotenv import load_dotenv

load_dotenv()

async def main():
    client = AsyncDedalus()
    runner = DedalusRunner(client)

    result = runner.run(
        input="Write a short story about AI",
        model="openai/gpt-4o-mini",
        stream=True
    )

    await stream_async(result)

if __name__ == "__main__":
    asyncio.run(main())

Multi-Model Handoffs

import asyncio
from dedalus_labs import AsyncDedalus, DedalusRunner

async def main():
    client = AsyncDedalus()
    runner = DedalusRunner(client)

    result = await runner.run(
        input="Research the latest AI developments and write a creative summary",
        model=["openai/gpt-4o-mini", "anthropic/claude-3-5-sonnet-20241022"],
        stream=False
    )

    print(result.final_output)

if __name__ == "__main__":
    asyncio.run(main())

Policy System

import asyncio
from dedalus_labs import AsyncDedalus, DedalusRunner

def policy(ctx: dict) -> dict:
    step = ctx.get("step", 1)
    pol = {}
    
    if step == 2:
        pol.update({"message_prepend": [{"role": "system", "content": "Be very concise."}]})
    
    pol.setdefault("max_steps", 3)
    return pol

async def main():
    client = AsyncDedalus()
    runner = DedalusRunner(client)

    result = await runner.run(
        input="Explain quantum computing",
        model="openai/gpt-4o-mini",
        policy=policy
    )

    print(result.final_output)

if __name__ == "__main__":
    asyncio.run(main())

Environment Setup

Create a .env file with your API keys:

# Choose one or more providers
OPENAI_API_KEY=your-openai-key-here
ANTHROPIC_API_KEY=your-anthropic-key-here
GOOGLE_API_KEY=your-google-key-here
# ... etc for other providers

Model Naming

Use the format provider/model-name:

  • openai/gpt-4o-mini
  • anthropic/claude-3-5-sonnet-20241022
  • google/gemini-pro

Or use bare model names (will auto-detect provider):

  • gpt-4o-mini (detected as OpenAI)
  • claude-3-5-sonnet-20241022 (detected as Anthropic)

Development

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black dedalus_labs/

# Type checking
mypy dedalus_labs/

License

MIT License - see LICENSE file for details.