> ## 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

> Get started with the RunAgent JavaScript SDK

# JavaScript SDK Getting Started

The RunAgent JavaScript SDK provides a native-feeling interface for calling your deployed agents from JavaScript and TypeScript applications.

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install runagent
  ```

  ```bash yarn theme={null}
  yarn add runagent
  ```

  ```bash pnpm theme={null}
  pnpm add runagent
  ```

  ```bash bun theme={null}
  bun add runagent
  ```
</CodeGroup>

## Basic Usage

### Initialize the Client

```javascript theme={null}
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

```javascript theme={null}
// Non-streaming call
const result = await client.run({
  message: "Hello, world!",
  role: "user"
});

console.log(result);
```

### Streaming Response

```javascript theme={null}
// 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:

```typescript theme={null}
import { RunAgentClient, RunAgentConfig } from 'runagent';

const config: RunAgentConfig = {
  agentId: 'your-agent-id',
  entrypointTag: 'your-tag',
  local: true
};

const client = new RunAgentClient(config);
```

## Error Handling

```javascript theme={null}
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

* [API Reference](/sdk/python/api-reference) - Complete API documentation
* [Streaming Guide](/sdk/python/streaming) - Advanced streaming patterns
* [Examples](/resources/examples) - Real-world usage examples
