Skip to main content
Prerequisites: Node.js 16+ and completed Deploy Your First Agent tutorial

Overview

The JavaScript SDK provides native-feeling access to RunAgent agents with full TypeScript support, async/await patterns, and streaming capabilities. It’s designed to work seamlessly in both Node.js and browser environments.

Installation

Basic Usage

Synchronous Calls

Asynchronous Calls

Advanced Features

1. Streaming Responses

2. Batch Processing

3. Error Handling

4. Custom Headers and Metadata

Configuration

Environment Variables

Configuration File

Create ~/.runagent/config.json:

Programmatic Configuration

Best Practices

1. Connection Management

2. Retry Logic

3. Logging and Monitoring

Common Patterns

1. Agent Factory Pattern

2. Agent Wrapper Pattern

3. Agent Pool Pattern

Error Handling

Common Error Types

Performance Optimization

1. Connection Pooling

2. Caching

Testing

Unit Testing

Integration Testing

Browser Usage

HTML Integration

Next Steps

Async Patterns

Learn advanced async patterns for JavaScript

Production Deployment

Deploy your JavaScript applications to production

Multi-Language Integration

Integrate with other programming languages

Performance Tuning

Optimize your JavaScript applications for production
🎉 Great work! You’ve learned how to use RunAgent agents from JavaScript applications. The JavaScript SDK provides native-feeling access with full TypeScript support and async/await patterns!