ai-gateway setup — Complete guided setup (install, login, configure)ai-gateway login — Authenticate via SSOai-gateway logout — Clear stored tokenai-gateway status — Show login and proxy service statusai-gateway run <command> — Start the proxy if needed, then run any command with the gateway environmentai-gateway serve — Start proxy in foregroundThe command does not have to be one of the tools the gateway configures: an
unknown name gets every supported tool's variables. So anything speaking the OpenAI
API (OPENAI_BASE_URL, OPENAI_API_KEY) works unmodified:
ai-gateway run claudeai-gateway run make evalai-gateway run python my_script.pyNo API key is needed. The key variables are set to the placeholder
value proxy; the local proxy replaces it with your real credential on the way
out. Because it relies on that local proxy, this does not cover CI runners or other
machines where you cannot log in with ai-gateway.
The Anthropic and Google/Vertex variables are set too, so the official SDKs work
the same way. ANTHROPIC_BASE_URL points at the proxy, which serves the Messages
API. Every ai-gateway run sets it, but ai-gateway env deliberately does not:
in a general shell it would redirect Claude Code when Claude Code is signed in to a
Claude subscription rather than the gateway. So wrap Anthropic SDK scripts in
ai-gateway run, or set the variable yourself for the command that needs it. Your own
ANTHROPIC_API_KEY is left alone when you run a known tool — apart from goose,
which uses that variable to reach the gateway. An unknown command gets the
placeholder, like every other provider key.
One caveat for the unknown-name case: the variables include
GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION, so a script that also calls
gcloud, bq or terraform under ai-gateway run targets the gateway's Vertex
project. Set them explicitly in the script if that is not what you want.
On Linux with systemd the proxy runs as a background service and your shell already
has the variables, so run is optional there. On macOS and WSL nothing starts the
proxy in the background, so use run, or keep ai-gateway serve going in a
dedicated terminal — ai-gateway env alone leaves the variables pointing at a
port with nothing listening.
ai-gateway env — Output environment variables for AI tools; apply them to the current shell with eval "$(ai-gateway env)", or ai-gateway env | source under fishai-gateway shell-init [--add] — Detect and configure shellai-gateway disable <tool> — Stop the gateway from configuring a toolai-gateway enable <tool> — Re-enable gateway configuration for a toolai-gateway disable --list — Show which tools are currently disabledai-gateway service install — Install systemd user serviceai-gateway service start|stop|status — Manage the service