How it works

A thin gateway between Claude Code and Bedrock.

tokener implements Claude Code's official gateway protocol and runs inside your own AWS account.

The request pipeline

Every request passes through five stages. Responses stream straight back to Claude Code as SSE.

Claude CodeANTHROPIC_BASE_URL
โ†’
authhashed personal token
โ†’
policyrouting, effort, trimming
โ†’
budgetUSD and token limits
โ†’
SigV4 / API keysigns upstream call
โ†’
meteringusage, cost, EMF

On AWS

An Application Load Balancer in front of ECS Fargate. Keys, usage and policy live in DynamoDB. Metrics go to CloudWatch, alerts to SNS.

Compute

ECS Fargate behind an ALB. Two tasks are plenty for 10 developers, with auto-scaling up to 6 at 60% CPU.

State

DynamoDB for keys, usage and policy. Policy changes reach every task within 30 seconds.

Observability

CloudWatch EMF metrics, a dashboard and alarms, with SNS e-mail alerts for team-wide spend.

Two run modes, same code

LocalAWS
StorageSQLiteDynamoDB
CredentialsYour own AWS credentials or a Bedrock API keyECS task role
Startnpm run localnpx cdk deploy

Two Bedrock APIs, switchable live

Mantle

The Anthropic Messages API endpoint on Bedrock. Requests are forwarded byte for byte.

Runtime

Classic InvokeModel. The gateway translates the body, converts the AWS event stream into SSE, and calls the model through its inference profile id.

Security

The ECS task role is the only identity that can call Bedrock. Developers hold no AWS credentials.

Tokens are stored as SHA-256 hashes. Logs contain counts, the model and the session id, never prompt content.

Conversation content is never persisted. It is transformed in memory and forwarded.

A per-key allowedModels list restricts which models each developer can use.