Skip to main content

Build your first AI agent in three steps

Create an intelligent sessional agent and have your first interaction in minutes.

Prerequisites

Before you begin, you’ll need:
  • An AgentHuman account (Sign up here)
  • Your API key from the dashboard
  • Node.js 16+ or Python 3.7+ installed

Step 1: Get your API key

  1. Log in to your AgentHuman Dashboard
  2. Navigate to Settings → API Keys
  3. Click “Create New Key”
  4. Name your key (e.g., “Development”)
  5. Save the key securely - it won’t be shown again!
Keep your API key secure and never commit it to version control.
Store your API key as an environment variable:
export AGENTHUMAN_API_KEY="ds_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Or in a .env file:
AGENTHUMAN_API_KEY=ds_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Step 2: Create your first session

Install the HTTP client:
npm install axios dotenv
Create a new file agent.js:
const axios = require('axios');
require('dotenv').config();

const API_KEY = process.env.AGENTHUMAN_API_KEY;
const BASE_URL = 'https://jwhite.tail8bf327.ts.net/api/v1';

async function createSession() {
  try {
    const response = await axios.post(
      `${BASE_URL}/sessions`,
      {
        name: 'My First Agent',
        custom_greeting: 'Hello! I\'m your AI assistant. How can I help you today?',
        context: 'You are a helpful and friendly AI assistant.',
        language: 'en'
      },
      {
        headers: {
          'x-api-key': API_KEY,
          'Content-Type': 'application/json'
        }
      }
    );
    
    console.log('Session created:', response.data);
    return response.data.session.id;
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

createSession();
Run it:
node agent.js
Install the requests library:
pip install requests python-dotenv
Create a new file agent.py:
import os
import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv('AGENTHUMAN_API_KEY')
BASE_URL = 'https://jwhite.tail8bf327.ts.net/api/v1'

def create_session():
    headers = {
        'x-api-key': API_KEY,
        'Content-Type': 'application/json'
    }
    
    data = {
        'name': 'My First Agent',
        'custom_greeting': 'Hello! I\'m your AI assistant. How can I help you today?',
        'context': 'You are a helpful and friendly AI assistant.',
        'language': 'en'
    }
    
    response = requests.post(
        f'{BASE_URL}/sessions',
        json=data,
        headers=headers
    )
    
    if response.status_code == 200:
        result = response.json()
        print('Session created:', result)
        return result['session']['id']
    else:
        print('Error:', response.json())
        return None

session_id = create_session()
Run it:
python agent.py

Step 3: Send your first message

Now let’s send a message to your agent and get a response:
async function sendMessage(sessionId, message) {
  try {
    const response = await axios.post(
      `${BASE_URL}/sessions/${sessionId}/messages`,
      {
        message: message,
        role: 'user'
      },
      {
        headers: {
          'x-api-key': API_KEY,
          'Content-Type': 'application/json'
        }
      }
    );
    
    console.log('User:', message);
    console.log('Agent:', response.data.response.content);
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

// Example usage
const sessionId = await createSession();
await sendMessage(sessionId, 'What can you help me with?');
Your agent will respond based on the context and personality you configured!

Next steps

Now that you’ve created your first agent, explore these advanced features:

Common use cases

const supportAgent = {
  name: 'Support Assistant',
  context: `You are a customer support specialist. 
            Be empathetic, solution-oriented, and professional.
            Always acknowledge the customer's concern first.`,
  custom_greeting: 'Hello! I\'m here to help. What issue can I assist you with today?',
  role_id: 1 // Customer Support role
}
const salesAgent = {
  name: 'Sales Advisor',
  context: `You are a knowledgeable sales assistant.
            Help customers find the right products.
            Be consultative, not pushy.`,
  custom_greeting: 'Welcome! I can help you find the perfect solution for your needs.',
  role_id: 2 // Sales role
}
const tutorAgent = {
  name: 'Study Assistant',
  context: `You are an educational tutor.
            Explain concepts clearly and encourage learning.
            Use examples and check understanding.`,
  custom_greeting: 'Hi there! Ready to learn something new today?',
  role_id: 3 // Educator role
}

SDK & Libraries

We’re working on official SDKs. For now, you can use any HTTP client:
  • JavaScript: axios, fetch, node-fetch
  • Python: requests, httpx, aiohttp
  • PHP: Guzzle, cURL
  • Ruby: Net::HTTP, HTTParty
  • Go: net/http
  • Java: OkHttp, Apache HttpClient
Need help? Check our API Reference or contact [email protected].