Documentation Index
Fetch the complete documentation index at: https://docs.run-agent.ai/llms.txt
Use this file to discover all available pages before exploring further.
JavaScript SDK Getting Started
The RunAgent JavaScript SDK provides a native-feeling interface for calling your deployed agents from JavaScript and TypeScript applications.
Installation
Basic Usage
Initialize the Client
import { RunAgentClient } from 'runagent';
const client = new RunAgentClient({
agentId: 'your-agent-id',
entrypointTag: 'your-tag',
local: true // Set to false for production
});
Call Your Agent
// Non-streaming call
const result = await client.run({
message: "Hello, world!",
role: "user"
});
console.log(result);
Streaming Response
// Streaming call
const stream = await client.runStream({
message: "Tell me a story",
role: "user"
});
for await (const chunk of stream) {
process.stdout.write(chunk);
}
TypeScript Support
The SDK comes with full TypeScript support:
import { RunAgentClient, RunAgentConfig } from 'runagent';
const config: RunAgentConfig = {
agentId: 'your-agent-id',
entrypointTag: 'your-tag',
local: true
};
const client = new RunAgentClient(config);
Error Handling
try {
const result = await client.run({ message: "Hello" });
console.log(result);
} catch (error) {
if (error.code === 'AGENT_NOT_FOUND') {
console.error('Agent not found');
} else if (error.code === 'TIMEOUT') {
console.error('Request timed out');
} else {
console.error('Unexpected error:', error.message);
}
}
Next Steps