@agentmuxer/sdk 0.6 provides a direct API client, an Admin client, and three framework adapters. The clients and adapters read AGENTMUXER_API_KEY unless you pass apiKey. The SDK README has the complete reference and runnable examples.
Direct client
AgentMuxer is both the default export and a named export.
Client options
string
default:"AGENTMUXER_API_KEY"
Your application key, supplied from a server-side secret store. The key must be non-empty, printable, and without surrounding whitespace. Keep it out of browser and mobile bundles and out of tool arguments.
string
An AgentMuxer OAuth access token, used instead of
apiKey. You own its storage and refresh.string
Separates invocations per end user of your backend. Derive it from your own verified session.
number
default:"100000"
Milliseconds per attempt.
number
default:"2"
Automatic retries per call after a lost connection, a timeout, or HTTP 408, 429, 500, 502, 503, 504, or 520–524, honoring
Retry-After up to 60 seconds. run resends the same idempotency key, so a retry never charges twice.boolean
default:"false"
Throw
RefusalError for any run result other than responded.typeof fetch
default:"global fetch"
A custom fetch implementation, also used for event streams.
string
default:"https://api.agentmuxer.com"
Another API origin. Use only an origin you trust with the key.
Methods
Every method takes its input first and per-call options second.search, inspect, getInvocation, and accountStatus return refusals as values with kind: "refused". Results carry the request id as result.requestId; include it when you contact support.
AbortSignal
Cancels the call. An abort throws
AgentMuxerError with kind "aborted" and is never retried. For run, recover with the original key, because the request may already have been sent.number
Milliseconds per attempt for this call. Overrides the client’s
timeout.number
Automatic retries for this call. Pass
0 to send once.HeadersInit
Extra headers. The SDK’s own authorization, content, partition, and idempotency headers take precedence.
run also accepts idempotencyKey and throwOnRefusal in its options.
Run input
A call names a provider, a path, and its inputs.string
required
The provider slug, such as
exa.string
required
The path template, such as
/search. Put path values in pathParams.string
Optional when the path serves one method. Pass it when the path serves several.
unknown
The request body. Put other inputs in
pathParams, query, headers, cookies, querystring, contentType, binaryBody, or multipartFiles, as inspect describes.string
default:"\"1\""
The maximum charge in USD, as an exact decimal string with up to six decimal places, such as
"0.25". Without maxCost or maxCostMicros, the maximum is $1.00. "0" means the call may not charge anything.string
The same maximum in integer USD micros, such as
"250000". Supply maxCost or maxCostMicros, not both.string
Identifies one invocation. The client generates one before sending when you omit it and returns it as
result.idempotencyKey. For crash safety, create your own random UUID and persist it before calling run.string
Accepts the exact terms of a
requires_action result with approvalKind: "agent". Repeat the unchanged request with the original key and result.nextAction.acceptTerms.pending result, a gateway_unavailable refusal, or a ConnectionError, aborted, 408, 5xx, or invalid_response error from run. client.getInvocation({ idempotencyKey }) reads the saved state. See Idempotency and recovery in the README.
Errors
Every error the SDK throws is anAgentMuxerError with a kind and, when known, the HTTP status, requestId, idempotencyKey, and retryAfterSeconds. All classes are exported from @agentmuxer/sdk.
With
throwOnRefusal, set on the client or per call, run is typed to return only responded results:
Account status
Admin client
Platforms that give each customer company its own application manage those applications from their servers with an admin key, created on the dashboard’s Applications page.apiKey, baseUrl, fetch, timeout, and a client-wide signal, and every method accepts { signal }. Admin requests run once; key creation takes your persisted idempotency key. See Admin client in the README for every method.
Framework adapters
Each adapter connects tohttps://mcp.agentmuxer.com/mcp and exposes AgentMuxer’s MCP tools: search_offerings, inspect_offering, call_offering, get_invocation, and report_outcome. See the MCP tool reference.
string
Your application key, supplied from a server-side secret store. Omit it to use
AGENTMUXER_API_KEY.- OpenAI Agents
- Claude Agent SDK
- Vercel AI SDK
tools on an OpenAI agent. OpenAI receives the application key and connects to AgentMuxer. Options type: OpenAIAgentsOptions.string[] | { toolNames?: string[] }
Optional tool-name filter. The example exposes all five tools, including purchases. Omit this option to expose every tool the server provides; narrow the list when your application needs fewer tools.
"always" | "never"
default:"never"
OpenAI tool approval policy. With
"always", handle approval interruptions and resume the run using OpenAI’s API. AgentMuxer payment confirmation and spending limits still apply.Controls outside the SDK
Choose models, prompts, turn limits, and framework permissions in your agent framework. Configure balance, application spending limits, and payment confirmation in AgentMuxer. Each call’s maximum caps that call; for loops and agents, set a lifetime spending limit on the application. The SDK never changes your account settings or supplies model-provider credentials.Billing, limits, and approvals
Understand which controls enforce spending and which guide agent behavior.