> ## Documentation Index
> Fetch the complete documentation index at: https://docs.remoteagent.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# claude-sdk

> Uses the official @anthropic-ai/claude-code SDK in-process for the lowest latency with Anthropic models.

The `claude-sdk` runner uses Anthropic's `@anthropic-ai/claude-code` Node.js SDK directly within the agent process — no subprocess, no CLI binary, no shell invocation. The model runs in-process, which means lower latency, better error handling, and access to the full SDK feature set including tool use and streaming.

## Requirements

* An **Anthropic API key** (`sk-ant-...`). Get one at [console.anthropic.com](https://console.anthropic.com).
* No additional binary to install. The SDK runs in-process within the RemoteAgent.CHAT binary.

## Setup

During `remoteagent init`, choose `claude-sdk` from the interactive list. When prompted for your API key, paste your Anthropic key:

```bash theme={null}
remoteagent init
# ? Which runner? claude-sdk
# ? Anthropic API key: sk-ant-...
```

The key is saved to `~/.remoteagent/agents/{agentId}.json` on your local machine. It is never transmitted to RemoteAgent.CHAT servers. Each project can use a different key — useful if you have multiple projects billed to separate Anthropic accounts.

To use this runner from the command line without the interactive wizard:

```bash theme={null}
remoteagent init --runner claude-sdk
```

## How it works

When your agent receives a command, the `claude-sdk` runner calls the `@anthropic-ai/claude-code` SDK with the prompt and the current working directory. The SDK handles:

* Model selection (latest Claude model configured in the SDK)
* Tool use (file read/write, bash execution, etc.)
* Streaming output chunks back to the agent

Each chunk is forwarded to Telegram as it arrives, so you see the response progressively rather than waiting for the full completion.

## Pros and cons

| Pros                                        | Cons                              |
| ------------------------------------------- | --------------------------------- |
| Best output quality — full SDK capability   | Requires a paid Anthropic API key |
| Lowest latency — no subprocess overhead     | API usage is billed per token     |
| Best error handling and retry logic         | —                                 |
| Access to all Claude tools (bash, file I/O) | —                                 |
| No extra installation step                  | —                                 |

## API key security

<Warning>
  Your Anthropic API key is stored locally in `~/.remoteagent/agents/{agentId}.json` and
  is **never** sent to RemoteAgent.CHAT servers or included in any network request
  made by the relay. The SDK calls Anthropic's API directly from your machine.
</Warning>

The key is stored in plain text in the config file. Make sure `~/.remoteagent/` has appropriate permissions:

```bash theme={null}
chmod 700 ~/.remoteagent
chmod 600 ~/.remoteagent/agents/*.json
```

## Costs

API usage is billed by Anthropic based on input and output tokens. RemoteAgent.CHAT does not add any markup or take a cut of API costs. Your Anthropic account is billed directly for all model usage.

Refer to [Anthropic's pricing page](https://www.anthropic.com/pricing) for current token rates.
