Skip to main content

Welcome to Agent Human API

Transform your applications with AI-powered video avatars that respond in real-time. Agent Human provides a simple REST API and WebSocket interface to generate lifelike talking head videos from audio, perfect for customer service, virtual assistants, education, and more. Architecture: We handle the complexity of real-time video generation using GPU-accelerated processing, while Daily.co manages WebRTC streaming for you. Just send audio commands and receive professional avatar video.

Base URL

All API requests should be made to:
https://api.agenthuman.com

What You Can Build

The Agent Human API enables you to:
  • Create Interactive Sessions - Start WebRTC video sessions with AI avatars using Daily.co infrastructure
  • Select Professional Avatars - Choose from a library of ready-to-use avatars for your sessions
  • Real-time Video Generation - Send audio and receive synchronized talking head video
  • Track Analytics - Monitor session duration, status, and usage metrics

Quick Start

Get started in minutes:

Step 1: Get Your API Key

  1. Log in to your Agent Human Dashboard
  2. Navigate to Settings → API Keys
  3. Click “Create New Key”
  4. Name your key (e.g., “Development” or “Production”)
  5. Copy and save the key securely - it won’t be shown again!
API keys are shown only once. Store them securely and never commit to version control.
Store your API key as an environment variable:Linux/macOS:
export AGENTHUMAN_API_KEY="ah_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Windows (PowerShell):
$env:AGENTHUMAN_API_KEY="ah_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Or in a .env file:
AGENTHUMAN_API_KEY=ah_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Using environment variables keeps your API keys secure and out of your source code.

Step 2: List Available Avatars

// Load environment variables
require('dotenv').config();
const API_KEY = process.env.AGENTHUMAN_API_KEY;

const headers = { 'x-api-key': API_KEY };

// AgentHuman avatars are organized as:
// - Characters (top-level): parent_id = null
// - Looks (session-ready): parent_id = <character_id>
//
// Sessions must be created with a LOOK (an avatar with parent_id).

// 1) List characters (default behavior)
const charactersRes = await fetch('https://api.agenthuman.com/v1/avatars', { headers });
const { avatars: characters } = await charactersRes.json();
console.log(`Found ${characters.length} characters`);

// Pick a character
const character = characters[0];
console.log(`Character: ${character.name} (${character.avatar_id})`);

// 2) List looks for that character (usable for sessions)
const looksRes = await fetch(
  `https://api.agenthuman.com/v1/avatars?parent_id=${encodeURIComponent(character.avatar_id)}`,
  { headers }
);
const { avatars: looks } = await looksRes.json();
console.log(`Found ${looks.length} looks for ${character.name}`);

// Pick a look
const look = looks[0];
console.log(`Look: ${look.name} (${look.avatar_id})`);

Step 3: Create a Session

// Create a new video session with the LOOK
const sessionResponse = await fetch('https://api.agenthuman.com/v1/sessions', {
  method: 'POST',
  headers: {
    'x-api-key': API_KEY,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    avatar_id: look.avatar_id,
    metadata: {
      user_name: 'John Doe',
      purpose: 'Demo session'
    }
  })
});

const { success, session, message } = await sessionResponse.json();
console.log(message); // "Session created successfully"
console.log(`Session ID: ${session.session_id}`);
console.log(`Status: ${session.status}`); // "created"
console.log(`Access Token: ${session.access_token}`);

// Session is now ready to be started via WebRTC
Sessions are created in created status with a Daily.co video room. Call the Start Session endpoint to activate the avatar server and transition to started status.
Daily.co Integration: Each session includes a daily_room object with the video room URL and authentication token for WebRTC connectivity.

Core Concepts

Sessions

Video conversations with avatars. Lifecycle: CreatedStartedEnded. Each session gets a Daily.co room for WebRTC video streaming.

Avatars

Pre-configured visual characters for video sessions. Select from available avatars to bring your AI conversations to life.

Response Format

Most /v1/* API responses include a success field. Authentication and some middleware responses may instead return an error string.

Success Responses

{
  "success": true,
  "sessions": [
    {
      "session_id": "sess_01H3Z8G9YR3K2N5M6P7Q8W4T",
      "avatar": {
        "avatar_id": "avat_01H3Z8G9YR3K2N5M6P7Q8W4T",
        "name": "Professional Avatar",
        "url": "https://example.com/avatar.jpg"
      },
      "status": "started",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}

Error Responses

All errors include helpful messages and optional suggestions:
{
  "success": false,
  "error": {
    "message": "Avatar not found",
    "suggestion": "Verify the avatar_id is correct and the avatar exists"
  }
}

Resource IDs

All resources use prefixed IDs for easy identification:
ResourcePrefixExample
Sessionssess_sess_01H3Z8G9YR3K2N5M6P7Q8W4T
Avatarsavat_avat_01H3Z8G9YR3K2N5M6P7Q8W4T
API Keysah_live_ / ah_test_ah_live_1234567890abcdef...
Resource IDs are immutable and globally unique. Use them for reliable references across API calls.

HTTP Status Codes

Status CodeDescription
200Success - Request completed successfully
201Created - Resource created successfully
400Bad Request - Invalid request parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Resource does not exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Server error
503Service Unavailable - Service temporarily offline

Rate Limiting

Agent Human implements rate limiting to ensure fair usage and system stability. Limits apply per API key.

Rate Limits by Endpoint Type

Endpoint TypeLimitWindowHTTP Status
Read Operations (GET)100 requests1 minute429
Write Operations (POST, PUT, DELETE)60 requests1 minute429
Session Start10 requests1 minute429
Subscription Tiers: Higher-tier subscriptions may have increased rate limits. Check your dashboard for your specific limits.

Rate Limit Headers

Every API response includes rate limit information in the headers:
RateLimit-Limit: 60
RateLimit-Remaining: 45
RateLimit-Reset: 12
HeaderDescription
RateLimit-LimitMaximum requests allowed in the current window
RateLimit-RemainingRequests remaining in the current window
RateLimit-ResetSeconds until the current window resets

When Rate Limited

Response (429 Too Many Requests): You may receive a 429 response with a simple message body, for example:
Too many requests, please slow down.
Headers included:
Retry-After: 60
RateLimit-Reset: 60

Best Practices

Track RateLimit-Remaining in your application and slow down requests when approaching the limit.
const response = await fetch('https://api.agenthuman.com/v1/sessions', {
  headers: { 'x-api-key': API_KEY }
});

const remaining = response.headers.get('RateLimit-Remaining');
if (parseInt(remaining) < 10) {
  console.warn('Approaching rate limit, consider slowing down');
}
When you receive a 429 response, wait before retrying with exponentially increasing delays.
async function fetchWithRetry(url, options, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    const response = await fetch(url, options);
    
    if (response.status !== 429) {
      return response;
    }
    
    // Exponential backoff: 1s, 2s, 4s, etc.
    const delay = Math.pow(2, i) * 1000;
    await new Promise(resolve => setTimeout(resolve, delay));
  }
  
  throw new Error('Max retries exceeded');
}
Instead of making multiple individual requests, batch operations where the API supports it.
  • Use GET /v1/sessions to fetch all sessions at once instead of individual requests
  • Cache avatar lists and session data locally to reduce API calls
Cache API responses that don’t change frequently (avatars, session details).
const cache = new Map();
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes

async function getCachedAvatars() {
  const cached = cache.get('avatars');
  if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
    return cached.data;
  }
  
  const response = await fetch('https://api.agenthuman.com/v1/avatars', {
    headers: { 'x-api-key': API_KEY }
  });
  const data = await response.json();
  
  cache.set('avatars', { data, timestamp: Date.now() });
  return data;
}

Rate Limit Scope

Rate limits are applied per API key, meaning:
  • Different API keys have independent rate limits
  • Test and production keys have separate quotas
  • Team members with different keys don’t share limits
Session Limits: In addition to API rate limits, your subscription plan may have limits on concurrent sessions and total session time. These are separate from API request rate limits.

Working with the API

Prerequisites

Before you begin, ensure you have:
  • An Agent Human account (Sign up here)
  • Your API key from the dashboard
  • An HTTP client library for your language

SDK & HTTP Clients

Agent Human works with any standard HTTP client:
Recommended libraries:
  • fetch (built-in in Node.js 18+)
  • axios - Full-featured HTTP client
  • node-fetch - Node.js implementation of fetch
npm install axios dotenv
Recommended libraries:
  • requests - Simple and elegant HTTP library
  • httpx - Modern async-capable HTTP client
  • aiohttp - Async HTTP client/server
pip install requests python-dotenv
  • PHP: Guzzle, cURL
  • Ruby: Net::HTTP, HTTParty, Faraday
  • Go: net/http, resty
  • Java: OkHttp, Apache HttpClient
  • .NET: HttpClient, RestSharp

Best Practices

Secure Keys

Store API keys in environment variables, never in source code or version control

Handle Errors

Check success field and handle errors gracefully with retry logic

Respect Limits

Monitor rate limit headers and implement exponential backoff

Use HTTPS

Always use HTTPS endpoints for secure communication

Common Workflows

A typical session flow from creation to completion:
const headers = { 'x-api-key': API_KEY };

// 1) List characters
const charactersRes = await fetch('https://api.agenthuman.com/v1/avatars', { headers });
const { avatars: characters } = await charactersRes.json();
const character = characters[0];

// 2) List looks (session-ready avatars) for that character
const looksRes = await fetch(
  `https://api.agenthuman.com/v1/avatars?parent_id=${encodeURIComponent(character.avatar_id)}`,
  { headers }
);
const { avatars: looks } = await looksRes.json();
const look = looks[0];

// 2. Create a session
const createRes = await fetch('https://api.agenthuman.com/v1/sessions', {
  method: 'POST',
  headers: { ...headers, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    avatar_id: look.avatar_id,
    metadata: { user_id: 'user_123' }
  })
});
const { session } = await createRes.json();

// 3. Start the session to activate the avatar server
const startRes = await fetch(
  `https://api.agenthuman.com/v1/sessions/${session.session_id}/start`,
  {
    method: 'POST',
    headers: { 'x-api-key': API_KEY }
  }
);
const { ws_uri } = await startRes.json();

// 4. Connect to Daily.co room for WebRTC video
// Use session.daily_room.url and session.daily_room.token

// 5. End the session when done
const endRes = await fetch(
  `https://api.agenthuman.com/v1/sessions/${session.session_id}/end`,
  {
    method: 'POST',
    headers: { 'x-api-key': API_KEY }
  }
);
const { session: endedSession } = await endRes.json();
console.log(`Session duration: ${endedSession.duration} seconds`);
Query sessions with filters and track their status:
import requests

API_KEY = os.getenv('AGENTHUMAN_API_KEY')
headers = {'x-api-key': API_KEY}

# Get all active sessions
active_res = requests.get(
  'https://api.agenthuman.com/v1/sessions?status=started',
  headers=headers
)
active_sessions = active_res.json()['sessions']
print(f"Active sessions: {len(active_sessions)}")

# Get sessions for a specific avatar
avatar_res = requests.get(
  f'https://api.agenthuman.com/v1/sessions?avatar_id={avatar_id}',
  headers=headers
)
avatar_sessions = avatar_res.json()['sessions']

# Get detailed info for a specific session
session_res = requests.get(
  f'https://api.agenthuman.com/v1/sessions/{session_id}',
  headers=headers
)
session_details = session_res.json()['session']
print(f"Session with {session_details['avatar']['name']}")
Always check the success field and handle errors appropriately:
async function createSessionSafely(avatarId) {
  try {
    const response = await fetch('https://api.agenthuman.com/v1/sessions', {
      method: 'POST',
      headers: {
        'x-api-key': API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ avatar_id: avatarId })
    });
    
    const data = await response.json();
    
    // Most /v1 endpoints return { success: boolean, ... }, but auth/middleware
    // failures may return { error: string }.
    if (!response.ok || data.success === false) {
      const errorMessage =
        typeof data.error === 'string'
          ? data.error
          : data.error?.message || data.error || 'Request failed';

      console.error('API Error:', errorMessage);

      const suggestion = typeof data.error === 'object' ? data.error?.suggestion : undefined;
      if (suggestion) console.log('Suggestion:', suggestion);

      return null;
    }
    
    return data.session;
  } catch (error) {
    // Handle network error
    console.error('Network error:', error.message);
    return null;
  }
}

Next Steps

OpenAPI Specification

For developers building with LLMs, SDKs, or automated tooling:

Download OpenAPI 3.0.3 Spec

Machine-readable API specification for SDK generation and LLM tool calling
What’s included:
  • Complete endpoint schemas with request/response types
  • Action-oriented operation IDs (createSession, listAvatars, etc.)
  • Detailed examples and error codes
  • Compatible with OpenAI, Claude, and SDK generators

Need Help?

Email Support

[email protected]Our team typically responds within 24 hours

API Status

status.agenthuman.comMonitor real-time API uptime and performance
Stuck? Check our detailed endpoint documentation or reach out to our support team. We’re here to help!