Add to an existing agent
Add to an existing agent
Register AgentMuxer in your existing
query() options:allowedTools lets Claude call AgentMuxer tools without a separate Claude permission prompt.Before you start
- Node.js 22.18 or later with ESM; see compatibility. Your host must also support the Claude Agent SDK process requirements.
- An AgentMuxer application key and credits for paid calls.
- An Anthropic API key for the model.
This example asks the agent to spend up to $0.10 on one tool call. Model charges are separate. Set an application spending limit if you need a hard cap; the prompt alone doesn’t enforce one.This example cannot collect payment confirmation. Configure your account for unattended purchases before running it. This setting also affects your personal agents.
1
Install
In a new directory, create an ESM project and install the integration:
2
Set your keys
Set both keys in your terminal:No browser sign-in is needed. Keep both keys on your server and out of source control.
3
Run Claude with AgentMuxer
Save this as
agent.ts. The highlighted lines connect AgentMuxer and let Claude use its tools:agent.ts
query() runs Claude’s agent loop. The for await loop reads its messages; this example prints the final answer or throws if the run fails.4
Run
- Three TypeScript release changes.
- Sources for the summary.
- The actual tool cost, or the reason it could not complete the purchase.
prompt. Include the spending you allow.Customize permissions
allowedTools preapproves AgentMuxer calls in Claude. It does not bypass AgentMuxer payment confirmation or hide unlisted tools. Configure disallowedTools or canUseTool on your Claude agent when you need more control.
The helper’s tools option sets per-tool policies, not a tool allowlist. It also accepts native timeout and alwaysLoad options. See the SDK reference for details.
Applications and keys
Manage credentials and spending limits.
Run in production
Handle deployment, failures, and tracing.