Client libraries for interacting with RunAgent

Introduction

RunAgent provides native SDKs for multiple programming languages, making it easy to integrate deployed agents into your applications. All SDKs follow consistent patterns while respecting language-specific conventions.

Available SDKs

Python

Full-featured SDK with sync/async support

pip install runagent

JavaScript

Coming Soon - Node.js and browser support

npm install @runagent/sdk

Rust

Coming Soon - High-performance native SDK

cargo add runagent

Go

Coming Soon - Idiomatic Go client

go get github.com/runagent-dev/runagent-go

Common Features

All SDKs provide:

  • Authentication: API key and token management
  • Synchronous Calls: Request/response pattern
  • Asynchronous Support: Non-blocking operations
  • Streaming: Real-time response streaming
  • Error Handling: Consistent error types
  • Retry Logic: Automatic retry with backoff
  • Type Safety: Language-appropriate typing

Quick Comparison

FeaturePythonJavaScriptRustGo
Sync Support
Async Support
Streaming🚧🚧🚧
Type Hints✅ (TS)
Published🚧🚧🚧

Basic Usage Pattern

All SDKs follow a similar pattern:

Python

from runagent import RunAgentClient

client = RunAgentClient(agent_id="agent-123")
result = client.run_generic({"query": "Hello"})

JavaScript

import { RunAgentClient } from '@runagent/sdk';

const client = new RunAgentClient({ agentId: 'agent-123' });
const result = await client.runGeneric({ query: 'Hello' });

Rust

use runagent::Client;

let client = Client::new("agent-123");
let result = client.run_generic(json!({ "query": "Hello" })).await?;

Go

import "github.com/runagent-dev/runagent-go"

client := runagent.NewClient("agent-123")
result, err := client.RunGeneric(map[string]interface{}{
    "query": "Hello",
})

Authentication

SDKs support multiple authentication methods:

Environment Variable

Set RUNAGENT_API_KEY and SDKs will use it automatically:

export RUNAGENT_API_KEY="your-api-key"

Direct Configuration

Pass API key during initialization:

client = RunAgentClient(
    agent_id="agent-123",
    api_key="your-api-key"
)

Configuration File

SDKs can read from ~/.runagent/config.json:

{
  "api_key": "your-api-key",
  "api_url": "https://api.run-agent.ai"
}

Error Handling

All SDKs provide consistent error types:

Error TypeDescription
AuthenticationErrorInvalid or missing credentials
AgentNotFoundErrorAgent doesn’t exist
ValidationErrorInvalid input data
RateLimitErrorToo many requests
TimeoutErrorRequest timed out
NetworkErrorConnection issues

Advanced Features

Streaming Responses

For real-time applications:

for chunk in client.run_generic_stream({"query": "Tell a story"}):
    print(chunk, end="")

Batch Processing

Process multiple requests efficiently:

results = client.batch_run([
    {"query": "Question 1"},
    {"query": "Question 2"},
    {"query": "Question 3"}
])

Custom Headers

Add custom headers for tracking:

client = RunAgentClient(
    agent_id="agent-123",
    headers={
        "X-Request-ID": "unique-id",
        "X-User-ID": "user-123"
    }
)

SDK Selection Guide

Choose your SDK based on:

Python SDK

Best for:

  • Data science and ML applications
  • Backend services
  • Scripts and automation
  • Jupyter notebooks

JavaScript SDK

Best for:

  • Web applications
  • Node.js backends
  • React/Vue/Angular apps
  • Serverless functions

Rust SDK

Best for:

  • High-performance applications
  • Systems programming
  • WebAssembly targets
  • Embedded systems

Go SDK

Best for:

  • Microservices
  • Cloud-native applications
  • CLI tools
  • Concurrent processing

Performance Considerations

SDKStartup TimeMemory UsageThroughput
PythonMediumMediumGood
JavaScriptFastLowGood
RustFastVery LowExcellent
GoFastLowExcellent

Migration Guide

Moving between SDKs? The concepts remain the same:

  1. Client initialization - Same parameters
  2. Method names - Consistent across languages
  3. Response format - JSON-compatible structures
  4. Error handling - Similar error types

Getting Help

  • Documentation: Language-specific guides
  • Examples: GitHub repositories with samples
  • Community: Discord channels for each SDK
  • Support: [email protected]

Next Steps