Dedalus Labs Documentation

Getting Started

Dedalus Labs is a managed platform for creating and deploying AI agents with custom tools. This documentation will guide you through setting up your first agent and integrating it with your application.

What you'll need:

  • A Dedalus Labs account with API access
  • Your API key
  • Basic knowledge of Python

Installation

Install the Dedalus Labs client library using pip:

pip install dedalus-labs

For JavaScript/TypeScript applications, install our client library using npm or yarn:

npm install @dedalus-labs/client

Agent Setup

Setting up an agent is simple. Define your tools, configure your agent, and get an API endpoint in minutes.

Python Example

import dedalus as ddls

# Define your tools
tools = [
    {
        "name": "execute_code",
        "description": "Execute Python code",
        "parameters": {
            "type": "object",
            "properties": {
                "code": {
                    "type": "string",
                    "description": "The Python code to execute"
                }
            },
            "required": ["code"]
        }
    }
]

# Define your tool implementation
def execute_code(code):
    try:
        # Set up a secure execution environment
        result = {}
        exec(code, {}, result)
        return {"result": str(result.get("result", "No result"))}
    except Exception as err:
        return {"error": str(err)}

# Create your agent
agent = ddls.create_agent(
    api_key="your-api-key",
    name="code-execution-agent",
    model="gpt-4",
    tools=tools,
    tool_implementations={
        "execute_code": execute_code
    },
    instructions="You are a helpful assistant that can write and execute Python code."
)

# Get your agent's API URL
api_url = agent.api_url
print(f"Your agent is available at: {api_url}")

# Optionally, test your agent
response = agent.run("Calculate the factorial of 5")
print(response)

JavaScript/TypeScript Example

import { DedalusLabs } from '@dedalus-labs/client';

// Initialize with your API key
const dedalus = new DedalusLabs('your-api-key');

// Define your tools
const tools = [
  {
    name: 'searchWeb',
    description: 'Search the web for information',
    parameters: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'The search query'
        }
      },
      required: ['query']
    }
  }
];

// Define your tool implementation
const toolImplementations = {
  searchWeb: async (query) => {
    // In a real implementation, you would call a search API
    return { results: `Results for: ${query}` };
  }
};

// Create your agent
const createAgent = async () => {
  const agent = await dedalus.createAgent({
    name: 'search-agent',
    model: 'gpt-4',
    tools,
    toolImplementations,
    systemPrompt: 'You are a helpful assistant that can search the web.'
  });

  // Get your agent's API URL
  console.log(`Your agent is available at: ${agent.apiUrl}`);

  // Optionally, test your agent
  const response = await agent.run('What is the capital of France?');
  console.log(response);
};

createAgent();

Custom Tools

Custom tools are the heart of Dedalus Labs. They allow your agent to perform specific actions based on user input.

Defining Tools

Tools are defined using a JSONSchema-compatible format:

{
  "name": "toolName",
  "description": "Detailed description of what the tool does",
  "parameters": {
    "type": "object",
    "properties": {
      "param1": {
        "type": "string",
        "description": "Description of param1"
      },
      "param2": {
        "type": "number",
        "description": "Description of param2"
      }
    },
    "required": ["param1"]
  }
}

Implementing Tool Functions

Each tool requires an implementation function that will be called when the agent uses the tool:

# Python
def tool_function(param1, param2=None):
    # Implement your tool logic here
    result = do_something(param1, param2)
    return {"result": result}

# Register the implementation
tool_implementations = {
    "toolName": tool_function
}

# JavaScript
const toolFunction = async (param1, param2) => {
  // Implement your tool logic here
  const result = await doSomething(param1, param2);
  return { result };
};

// Register the implementation
const toolImplementations = {
  toolName: toolFunction
};

API Reference

Agent Creation

POST https://api.dedalus.ai/v1/agents

{
  "name": "my-agent",
  "model": "gpt-4",
  "tools": [...],
  "system_prompt": "You are a helpful assistant..."
}

Agent Invocation

POST https://api.dedalus.ai/v1/agents/{agent_id}/run

{
  "user_input": "User query or command",
  "stream": true,
  "context": {
    // Optional context information
  }
}

Agent Management

GET https://api.dedalus.ai/v1/agents
GET https://api.dedalus.ai/v1/agents/{agent_id}
PUT https://api.dedalus.ai/v1/agents/{agent_id}
DELETE https://api.dedalus.ai/v1/agents/{agent_id}

Example Projects

Code Assistant

A complete example of a code assistant agent that can write, test, and debug code.

View on GitHub

Data Analysis Agent

A data analysis agent that can process CSV files, generate charts, and provide insights.

View on GitHub

Customer Support Bot

A customer support agent that can answer questions, search documentation, and create tickets.

View on GitHub

Web Researcher

An agent that can search the web, extract information, and compile research reports.

View on GitHub