JSPM

@elizaos/api-client

1.5.8-beta.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1931
    • Score
      100M100P100Q123384F

    Type-safe API client for ElizaOS server

    Package Exports

      This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@elizaos/api-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

      Readme

      @elizaos/api-client

      Type-safe API client for ElizaOS server.

      Installation

      bun add @elizaos/api-client

      Usage

      import { ElizaClient } from '@elizaos/api-client';
      
      // Create client instance
      const client = ElizaClient.create({
        baseUrl: 'http://localhost:3000',
        apiKey: 'your-api-key', // optional
      });
      
      // List all agents
      const { agents } = await client.agents.listAgents();
      
      // Create a new agent
      const agent = await client.agents.createAgent({
        name: 'My Agent',
        description: 'A helpful assistant',
      });
      
      // Send a message
      const message = await client.messaging.postMessage(channelId, 'Hello, world!');
      
      // Create a session for user-agent conversation
      const session = await client.sessions.createSession({
        agentId: agent.id,
        userId: 'user-123',
        metadata: { platform: 'web' },
      });
      
      // Send a message in the session
      const sessionMessage = await client.sessions.sendMessage(session.sessionId, {
        content: 'Hello, agent!',
      });
      
      // Upload media
      const upload = await client.media.uploadAgentMedia(agentId, {
        file: myFile,
        filename: 'image.png',
      });

      API Domains

      Agents

      • CRUD operations for agents
      • Agent lifecycle management (start/stop)
      • World management
      • Plugin panels and logs

      Messaging

      • Message submission and management
      • Channel operations
      • Server management
      • Message search

      Sessions

      • Create and manage user-agent conversation sessions
      • Send and retrieve messages within sessions
      • Session metadata and lifecycle management
      • Automatic cleanup of inactive sessions

      Memory

      • Agent memory management
      • Room operations
      • World management

      Audio

      • Speech processing
      • Text-to-speech
      • Audio transcription

      Media

      • File uploads for agents and channels

      Server

      • Health checks and status
      • Runtime debugging
      • Log management

      System

      • Environment configuration

      Error Handling

      import { ApiError } from '@elizaos/api-client';
      
      try {
        await client.agents.getAgent(agentId);
      } catch (error) {
        if (error instanceof ApiError) {
          console.error(`Error ${error.code}: ${error.message}`);
          if (error.details) {
            console.error('Details:', error.details);
          }
        }
      }

      TypeScript Support

      This package is written in TypeScript and provides full type definitions for all API endpoints, request parameters, and responses.