Skip to main content
Connect Pi, Droid, or OpenCode directly to the OpenAI-compatible Model APIs endpoint with BASETEN_API_KEY. Use Baseten Switch to route requests from Claude Code or Codex CLI to Model APIs. Switch can also install Pi’s direct Baseten provider, compare Baseten spend with estimated costs from Anthropic or OpenAI, and route requests back to those providers. For Cline, Roo Code, LangChain, and other tools, see Integrations. To let an agent manage your Baseten workspace and search these docs, see Connect your coding agent.

Agent harnesses

Call Model APIs from Pi, Droid, or OpenCode with BASETEN_API_KEY.

Baseten Switch

Connect Claude Code, Codex CLI, or Pi.

Switch CLI

Command reference for baseten-switch.

Agent harnesses

Pi, Droid, and OpenCode call the OpenAI-compatible Model APIs endpoint with BASETEN_API_KEY. Baseten pins requests with a recognized session ID to the same replica to increase KV cache hits. Claude Code, Codex, and OpenCode include recognized session IDs, so they require no additional configuration. To pin requests from other harnesses, see Cached input tokens. Create a personal API key, export it as BASETEN_API_KEY, then configure your harness. This inference key is separate from the management key used to connect your coding agent. The examples use zai-org/GLM-5.2; replace it with any supported model.
Pi includes a Baseten provider. Use the built-in provider for the shortest setup, or add a configuration file to pin the endpoint and model list. To load the Model APIs catalog into Pi, use Baseten Switch.After you set BASETEN_API_KEY, choose a setup method.
To call Model APIs from Pi:
To store the key in auth.json:
  1. Run /login in Pi.
  2. Select Baseten and store the key in ~/.pi/agent/auth.json.
Credentials in auth.json take priority over the environment variable. Set key to an API key or "$BASETEN_API_KEY". Pi stores agent configuration in ~/.pi/agent by default. Set PI_CODING_AGENT_DIR to use another directory.

Baseten Switch

Baseten Switch is in beta. Its interfaces, configuration, and behavior can change between releases.
Baseten Switch is a local gateway for Claude Code and Codex CLI. It maps model families to Model APIs slugs, compares Baseten spend with estimated costs from Anthropic or OpenAI, and can route requests back to those providers. The same CLI installs Pi’s direct Baseten provider without starting the gateway. Switch requires macOS 13 or newer on Apple Silicon or Intel. For a complete command reference, see the Baseten Switch CLI. To install Baseten Switch:
  1. Trust Baseten’s Homebrew tap:
  2. Install the formula:
The formula installs Baseten Switch and its Baseten CLI dependency. Switch uses the current Baseten CLI profile and supports both browser OAuth and API-key authentication. To allow Baseten Switch on macOS: macOS might block the beta build because it uses an ad hoc signature and is not notarized. To allow the app:
  1. Try to open Baseten Switch once so macOS registers the block.
  2. Open System Settings > Privacy & Security and scroll to Security.
  3. Select Open Anyway next to Baseten Switch.
A managed Mac might prevent this override.

Connect a coding harness

baseten-switch up --install starts the gateway and installs the menu bar app. Use the app to toggle routing, map models, and view spend. Pi uses a direct provider installed by Switch and does not send requests through the gateway.
To route Claude Code through Baseten:
  1. Initialize the configuration and sign in when prompted:
  2. Start the gateway and install the menu bar app:
  3. Point new Claude Code sessions at the gateway:
  4. Restart Claude Code.
  5. Verify the request path:

Next steps

Connect your coding agent

Install the Baseten skill and MCP servers so your agent can manage your Baseten workspace and search these docs.

Integrations

Call Model APIs from Cline, Roo Code, LangChain, and other tools.

Model APIs pricing

See rates for hosted models.

Baseten Switch CLI

Commands for routing, models, spend, and health.

Baseten Switch README

Find upgrade, uninstall, and configuration instructions.