Getting Started

    Quick start guide to get your first AI agent running

    Quick Start

    New

    Deploy your first AI agent in 5 minutes

    5 min

    Quick Start Guide

    Welcome to Fantomu! This guide will help you create and deploy your first AI agent in just 5 minutes.

    Prerequisites

    • A Fantomu account (sign up at fantomu.com)
    • Node.js 18+ or Python 3.8+
    • Basic programming knowledge

    Step 1: Install the SDK

    bash
    # JavaScript/Node.js
    npm install @fantomu/sdk
    
    # Python
    pip install fantomu-sdk
    

    Step 2: Get Your API Key

    • Log in to your Fantomu dashboard

    • Navigate to Settings > API Keys
    • Create a new API key
    • Copy the key (you won't see it again!)

    Step 3: Create Your First Agent

    javascript
    import { FantomuClient } from '@fantomu/sdk';
    
    const client = new FantomuClient({
      apiKey: 'your-api-key-here'
    });
    
    // Create an agent
    const agent = await client.agents.create({
      name: 'My First Agent',
      description: 'A simple AI agent for testing',
      capabilities: ['text_processing', 'basic_reasoning']
    });
    
    console.log('Agent created:', agent.id);
    

    Step 4: Execute Your First Task

    javascript
    // Execute a simple task
    const result = await agent.execute({
      task: 'Write a short greeting message',
      context: {
        recipient: 'new user',
        tone: 'friendly'
      }
    });
    
    console.log('Result:', result.result);
    

    Next Steps

    • Explore more capabilities in our [API Reference](/docs/api)

    • Check out [code examples](/docs/examples) for inspiration
    • Join our [community](/community) for help and support

    Congratulations! You've successfully created and deployed your first AI agent.

    Installation

    Set up Fantomu SDK and CLI tools

    3 min

    Installation Guide

    This guide covers installing the Fantomu SDK and CLI tools for your preferred programming language.

    JavaScript/Node.js

    Using npm

    bash
    npm install @fantomu/sdk
    

    Using yarn

    bash
    yarn add @fantomu/sdk
    

    Using pnpm

    bash
    pnpm add @fantomu/sdk
    

    Python

    Using pip

    bash
    pip install fantomu-sdk
    

    Using pipenv

    bash
    pipenv install fantomu-sdk
    

    Using poetry

    bash
    poetry add fantomu-sdk
    

    Go

    bash
    go get github.com/fantomu/go-sdk
    

    PHP

    bash
    composer require fantomu/php-sdk
    

    CLI Tools

    Install the Fantomu CLI for managing agents from the command line:

    bash
    # Install globally
    npm install -g @fantomu/cli
    
    # Or use npx
    npx @fantomu/cli --help
    

    Verify Installation

    Test your installation with a simple script:

    javascript
    // test.js
    import { FantomuClient } from '@fantomu/sdk';
    
    const client = new FantomuClient({
      apiKey: process.env.FANTOMU_API_KEY
    });
    
    console.log('SDK version:', client.version);
    

    Run it:

    bash
    node test.js
    

    Environment Variables

    Set up your API key as an environment variable:

    bash
    # .env
    FANTOMU_API_KEY=your-api-key-here
    

    Troubleshooting

    Common Issues

    • Module not found: Ensure you're in the correct directory and have run npm install

    • API key invalid: Double-check your API key in the dashboard
    • Network errors: Verify your internet connection and firewall settings

    Getting Help

    • Check our [troubleshooting guide](/docs/troubleshooting)
    • Join our [Discord community](/community)
    • Open an issue on [GitHub](https://github.com/fantomu/sdk)

    Authentication

    Get your API keys and configure access

    2 min

    Authentication

    Learn how to authenticate with the Fantomu API using API keys and configure access for your applications.

    API Keys

    Fantomu uses API keys for authentication. Each key is associated with your account and has specific permissions.

    Creating an API Key

    • Log in to your [Fantomu Dashboard](https://app.fantomu.com)
    • Navigate to Settings > API Keys
    • Click Create New Key
    • Give your key a descriptive name
    • Select the permissions you need
    • Click Create Key
    • Copy the key immediately - you won't be able to see it again!

    Key Permissions

    • Read: View agents and tasks
    • Write: Create and modify agents
    • Execute: Run tasks with agents
    • Admin: Full account access

    Using API Keys

    Environment Variables (Recommended)

    bash
    # .env
    FANTOMU_API_KEY=sk-1234567890abcdef
    

    javascript
    import { FantomuClient } from '@fantomu/sdk';
    
    const client = new FantomuClient({
      apiKey: process.env.FANTOMU_API_KEY
    });
    

    Direct Usage

    javascript
    const client = new FantomuClient({
      apiKey: 'sk-1234567890abcdef'
    });
    

    Security Best Practices

    1. Never Commit API Keys

    bash
    # Add to .gitignore
    .env
    *.env
    

    2. Use Environment Variables

    Always use environment variables in production:

    javascript
    const apiKey = process.env.NODE_ENV === 'production' 
      ? process.env.FANTOMU_API_KEY 
      : 'dev-key-for-testing';
    

    3. Rotate Keys Regularly

    • Rotate API keys every 90 days
    • Use different keys for different environments
    • Revoke unused keys immediately

    4. Monitor Usage

    • Check API usage in your dashboard
    • Set up alerts for unusual activity
    • Review logs regularly

    Testing Authentication

    javascript
    // Test your API key
    const client = new FantomuClient({
      apiKey: process.env.FANTOMU_API_KEY
    });
    
    try {
      const account = await client.account.get();
      console.log('Authenticated as:', account.email);
    } catch (error) {
      console.error('Authentication failed:', error.message);
    }
    

    Error Handling

    Invalid API Key

    json
    {
      "error": "invalid_api_key",
      "message": "The provided API key is invalid"
    }
    

    Insufficient Permissions

    json
    {
      "error": "insufficient_permissions",
      "message": "This API key doesn't have permission to perform this action"
    }
    

    Rate Limited

    json
    {
      "error": "rate_limited",
      "message": "Too many requests. Please try again later."
    }
    

    Next Steps

    • Learn about [creating agents](/docs/getting-started/first-agent)

    • Explore the [API reference](/docs/api)
    • Check out [code examples](/docs/examples)

    First Agent

    Create and deploy your first AI agent

    10 min

    Creating Your First Agent

    This comprehensive guide will walk you through creating, configuring, and deploying your first AI agent with Fantomu.

    What is an AI Agent?

    An AI agent is an autonomous system that can:

    • Understand natural language instructions
    • Perform complex tasks
    • Make decisions based on context
    • Learn from interactions
    • Integrate with external systems

    Agent Architecture

    text
    ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
    │   User Input    │───▶│   AI Agent      │───▶│   Task Result   │
    │   (Task)        │    │   (Processing)  │    │   (Output)      │
    └─────────────────┘    └─────────────────┘    └─────────────────┘
                                  │
                                  ▼
                           ┌─────────────────┐
                           │   External      │
                           │   Integrations  │
                           └─────────────────┘
    

    Step 1: Define Your Agent's Purpose

    Before coding, clearly define what your agent should do:

    • Primary Function: What is the main task?

    • Input Format: What data does it need?
    • Output Format: What should it return?
    • Integrations: What external services does it need?

    Example: Email Assistant Agent

    • Purpose: Help users manage emails
    • Capabilities: Draft, send, schedule, analyze emails
    • Input: Email requests, context, preferences
    • Output: Drafted emails, schedules, analysis

    Step 2: Create the Agent

    javascript
    import { FantomuClient } from '@fantomu/sdk';
    
    const client = new FantomuClient({
      apiKey: process.env.FANTOMU_API_KEY
    });
    
    // Define agent configuration
    const agentConfig = {
      name: 'Email Assistant',
      description: 'AI agent for email management and drafting',
      capabilities: [
        'email_drafting',
        'email_scheduling',
        'email_analysis',
        'contact_management'
      ],
      settings: {
        maxResponseLength: 2000,
        temperature: 0.7,
        model: 'gpt-4'
      }
    };
    
    // Create the agent
    const agent = await client.agents.create(agentConfig);
    console.log('Agent created:', agent.id);
    

    Step 3: Configure Agent Behavior

    javascript
    // Add custom instructions
    await agent.update({
      instructions: `You are a professional email assistant. 
      
      Guidelines:
      - Always use professional tone
      - Be concise but complete
      - Include relevant details
      - Suggest follow-up actions when appropriate`
    });
    
    // Set up integrations
    await agent.integrations.add({
      type: 'email',
      provider: 'gmail',
      credentials: {
        clientId: process.env.GMAIL_CLIENT_ID,
        clientSecret: process.env.GMAIL_CLIENT_SECRET
      }
    });
    

    Step 4: Test Your Agent

    javascript
    // Test basic functionality
    const testResult = await agent.execute({
      task: 'Draft a professional follow-up email',
      context: {
        recipient: 'client@example.com',
        subject: 'Project Update - Q1 Review',
        previousEmails: 2,
        meetingDate: '2024-01-15'
      }
    });
    
    console.log('Test result:', testResult.result);
    

    Step 5: Deploy to Production

    Environment Setup

    javascript
    // production.js
    const client = new FantomuClient({
      apiKey: process.env.FANTOMU_API_KEY,
      environment: 'production'
    });
    
    // Enable monitoring
    client.monitoring.enable({
      logLevel: 'info',
      metrics: true,
      alerts: true
    });
    

    Error Handling

    javascript
    async function executeTaskSafely(agent, task, context) {
      try {
        const result = await agent.execute({ task, context });
        return { success: true, result };
      } catch (error) {
        console.error('Task execution failed:', error);
        
        // Implement fallback logic
        if (error.code === 'RATE_LIMITED') {
          // Retry with exponential backoff
          await new Promise(resolve => setTimeout(resolve, 1000));
          return executeTaskSafely(agent, task, context);
        }
        
        return { 
          success: false, 
          error: error.message,
          fallback: 'Please try again later'
        };
      }
    }
    

    Step 6: Monitor and Optimize

    Set Up Monitoring

    javascript
    // Monitor agent performance
    client.monitoring.on('task_completed', (data) => {
      console.log('Task completed:', {
        agentId: data.agentId,
        duration: data.duration,
        success: data.success
      });
    });
    
    client.monitoring.on('error', (error) => {
      console.error('Agent error:', error);
      // Send alert to your team
    });
    

    Performance Optimization

    javascript
    // Optimize based on usage patterns
    const analytics = await agent.getAnalytics({
      period: '30d',
      metrics: ['response_time', 'success_rate', 'usage_patterns']
    });
    
    // Adjust settings based on data
    if (analytics.responseTime > 5000) {
      await agent.update({
        settings: {
          ...agent.settings,
          temperature: 0.5, // More focused responses
          maxTokens: 1000   // Shorter responses
        }
      });
    }
    

    Best Practices

    1. Start Simple

    • Begin with basic functionality
    • Add complexity gradually
    • Test thoroughly at each step

    2. Handle Errors Gracefully

    • Implement proper error handling
    • Provide meaningful error messages
    • Have fallback strategies

    3. Monitor Performance

    • Track key metrics
    • Set up alerts
    • Regular optimization

    4. Document Everything

    • Document agent capabilities
    • Keep configuration in version control
    • Maintain change logs

    Next Steps

    • Explore [advanced agent features](/docs/core-concepts)
    • Learn about [workflows](/docs/workflows)
    • Check out [integration options](/docs/integrations)
    • Join our [community](/community) for support