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

# SDK reference

> Import paths, options, and return values for @agentmuxer/sdk.

The SDK exports three framework-specific helpers. Each reads `AGENTMUXER_API_KEY` unless you pass `apiKey`. All connect to `https://mcp.agentmuxer.com/mcp`.

<ParamField body="apiKey" type="string">
  Your application key, supplied from a server-side secret store. Omit it to use `AGENTMUXER_API_KEY`. Empty values, surrounding whitespace, and non-printable characters are rejected. Browser use is rejected.
</ParamField>

<Tabs>
  <Tab title="OpenAI Agents">
    ```ts theme={null}
    import { agentmuxer } from "@agentmuxer/sdk/openai";

    const tool = agentmuxer({
      allowedTools: [
        "search_offerings",
        "inspect_offering",
        "call_offering",
        "report_outcome",
      ],
      requireApproval: "never",
    });
    ```

    Returns the framework's hosted MCP tool configuration. Add it to `tools` on an OpenAI agent. OpenAI receives the application key and connects to AgentMuxer.

    <ParamField body="allowedTools" type="string[] | { toolNames?: string[] }">
      Optional tool-name filter. The example exposes all four tools, including purchases. Omit this option to expose every tool the server provides; narrow the list when your application needs fewer tools.
    </ParamField>

    <ParamField body="requireApproval" type="&#x22;always&#x22; | &#x22;never&#x22;" 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.
    </ParamField>

    [Runnable OpenAI example](/sdk/openai) · [OpenAI MCP options](https://openai.github.io/openai-agents-js/guides/mcp/)
  </Tab>

  <Tab title="Claude Agent SDK">
    ```ts theme={null}
    import { agentmuxer } from "@agentmuxer/sdk/claude-agent";

    const server = agentmuxer({
      tools: [{ name: "search_offerings", permission_policy: "always_allow" }],
      timeout: 60_000,
      alwaysLoad: true,
    });
    // Pass under options.mcpServers.agentmuxer.
    ```

    Returns an HTTP MCP server configuration with bearer authentication.

    <ParamField body="tools" type="McpServerToolPolicy[]">
      Each entry identifies a tool by `name`. Set `permission_policy` to `"always_allow"`, `"always_ask"`, or `"always_deny"`. The example preapproves search; unlisted tools retain their normal permissions. This option does not hide tools.
    </ParamField>

    <ParamField body="timeout" type="number">
      Optional per-tool-call timeout in milliseconds. Claude ignores values below 1,000 ms. The helper does not override the framework default.
    </ParamField>

    <ParamField body="alwaysLoad" type="boolean">
      Set `true` to include this server's tools in the model context immediately instead of deferring them to Claude's tool search. Omit it to keep the framework default.
    </ParamField>

    Configure `allowedTools`, `disallowedTools`, and `canUseTool` on your Claude agent, not on this helper. Preapproving a framework tool does not bypass AgentMuxer's payment policy.

    [Runnable Claude example](/sdk/claude-agent) · [Claude MCP guide](https://platform.claude.com/docs/en/agent-sdk/mcp)
  </Tab>

  <Tab title="Vercel AI SDK">
    ```ts theme={null}
    import { agentmuxer } from "@agentmuxer/sdk/ai-sdk";

    const mux = await agentmuxer({
      initializationOptions: { timeout: 10_000 },
    });
    // Pass mux.tools to your agent; await mux.close() after it finishes.
    ```

    Returns a promise for a connection. Automatic MCP tool-call retries are disabled.

    <ParamField body="initializationOptions" type="{ signal?: AbortSignal; timeout?: number; maxTotalTimeout?: number }">
      Optional connection-initialization controls accepted by `@ai-sdk/mcp`. Timeouts are in milliseconds. These options do not set a purchase budget or a timeout for later tool calls.
    </ParamField>

    <ParamField body="onUncaughtError" type="(error: unknown) => void">
      Optional callback for uncaught MCP client errors. Use it to report connection failures to your application. Redact credentials and sensitive tool data before logging errors.
    </ParamField>

    <ResponseField name="tools" type="tool set">
      The discovered AgentMuxer tools, including purchases. Pass to your agent's `tools`.
    </ResponseField>

    <ResponseField name="close" type="() => Promise<void>">
      Release the connection after the complete result or stream is consumed. Call in `finally`; HTTP streams also need cleanup on completion, error, and cancellation.
    </ResponseField>

    [Runnable Vercel example](/sdk/ai-sdk) · [Vercel MCP guide](https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools)
  </Tab>
</Tabs>

## Controls outside the helper

Choose models, prompts, turn limits, and framework permissions in your agent framework. Configure balance, application spending limits, and account payment confirmation in AgentMuxer.

The helpers do not add an SDK-wide dollar budget, change your account settings, or supply model-provider credentials.

<Card title="Billing, limits, and approvals" href="/guides/billing">Understand which controls enforce spending and which guide agent behavior.</Card>
