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 withBASETEN_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
- Droid
- OpenCode
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.- Built-in provider
- Config file
To call Model APIs from Pi:To store the key in
auth.json:- Run
/loginin Pi. - Select Baseten and store the key in
~/.pi/agent/auth.json.
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.
-
Trust Baseten’s Homebrew tap:
-
Install the formula:
- Try to open Baseten Switch once so macOS registers the block.
- Open System Settings > Privacy & Security and scroll to Security.
- Select Open Anyway next to Baseten Switch.
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.
- Claude Code
- Codex CLI
- Pi
To route Claude Code through Baseten:
-
Initialize the configuration and sign in when prompted:
-
Start the gateway and install the menu bar app:
-
Point new Claude Code sessions at the gateway:
- Restart Claude Code.
-
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.