rinukkusu

Anthropic Agent SDK Relay — Development skill for Claude Code

Development community

Anthropic Messages API endpoint answered by the Claude Agent SDK, so self-hosted n8n can use a Claude subscription instead of per-token API billing.

How to install Anthropic Agent SDK Relay

This entry records only its repository, not the path inside it, so there is no exact command to give. Open rinukkusu/anthropic-agent-sdk-relay and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Anthropic Agent SDK Relay does

Anthropic Messages API endpoint answered by the Claude Agent SDK, so self-hosted n8n can use a Claude subscription instead of per-token API billing.

Alternatives in Development

  • Claude API — Build apps with the Claude API or Anthropic SDK 94.1k ★
  • Ccusage — CLI for analyzing Claude Code/Codex usage from local JSONL files 11.8k ★
  • Microsandbox — Open-source self-hosted MicroVM sandboxes with sub-200ms startup, hardware-level isolation via libkrun 5k ★

README

anthropic-agent-sdk-relay

An Anthropic Messages API endpoint that is answered by the Claude Agent SDK instead of the Claude API, so a self-hosted n8n can use a Claude subscription rather than per-token API billing.

Point n8n's Anthropic credential at this service and the Agent node works as usual, tools included.

What it does

n8n Agent node  ──POST /v1/messages──▶  relay  ──▶  Claude Agent SDK  ──▶  Claude
        ▲                                 │
        └────── tool_use / tool_result ───┘

The interesting part is tool calling. n8n runs its own tools and expects the model to emit `tool_use` blocks; the Agent SDK does the opposite and executes tools itself. The relay closes that gap:

  1. Every tool the client declares is registered as an in-process MCP tool.
  2. When Claude calls one, the handler's promise is parked, not resolved.
  3. The HTTP response ends with stop_reason: "tool_use" carrying that call.
  4. n8n runs the tool and posts a history ending in tool_result.
  5. The relay matches the result to the parked promise and the same live session carries on.

Because the session stays open between requests, nothing is replayed and the agent loop never learns that a tool round-trip crossed a network boundary.

Requirements

  • Bun 1.2 or newer
  • A Claude Pro or Max subscription
  • Claude Code credentials reachable by the process (see below)

Quick start

bun install
cp .env.example .env   # set RELAY_API_KEY
bun run start

Or pull the published image, built for amd64 and arm64 on every push to `main`:

docker run --rm -p 8787:8787 --env-file .env ghcr.io/rinukkusu/anthropic-agent-sdk-relay:latest
curl http://127.0.0.1:8787/v1/messages -H "x-api-key: $RELAY_API_KEY" -H 'content-type: application/json' -d '{"model":"claude-sonnet-5","max_tokens":256,"messages":[{"role":"user","content":"pong?"}]}'

Authentication

Two separate secrets are in play.

**Callers to the relay** present `RELAY_API_KE