Route Pi LLM providers through Tailscale Aperture

Route Pi LLM providers and connector tools through Tailscale Aperture, a managed AI gateway on your tailnet.
Aperture handles API key injection and request routing server-side, so Pi never needs upstream provider credentials. This extension offers three capabilities:
aperture provider whose models come from the gateway.pi install npm:@aliou/pi-ts-aperture
After installing, run the onboarding wizard:
/aperture:onboarding
The wizard asks for your Aperture URL (with a health check), lets you pick capabilities and providers, then saves and reloads Pi. You can change everything later with /aperture:settings.
Registers a standalone aperture provider listing the models your gateway exposes. Include all gateway providers or filter to specific ones, and each model is routed through the Pi API that matches its Aperture compatibility.
Capabilities (context window, vision input, reasoning, thinking levels) come from the first source that knows the model: ~/.pi/agent/models.json, then Pi’s model registry, then models.dev, then safe defaults. Costs come from the gateway. The resolved catalog is cached in Pi’s models store, so models load instantly on startup, even offline.
Reroutes existing Pi providers through Aperture. Each provider keeps its own model definitions and settings; only the base URL, API key, and headers are overridden. Use this when you want Pi’s native per-provider model configuration but want requests to go through Aperture for server-side credentials.
Provider selection matches your local Pi providers against the providers enabled on the gateway. Optional per-provider verification warns when configured local models are missing from the gateway. Set keepGatewayModelsOnly: true on a provider to go further and filter those models out of the model picker entirely, so it only shows models the gateway can actually serve.
Aperture can expose MCP connectors (GitHub, your own internal tools, …) at /v1/mcp. When enabled, this extension surfaces gateway tools to Pi in one of two ways:
aperture_connector_list, aperture_connector_tool_search, aperture_connector_tool_describe, and aperture_connector_tool_call let the model find and call connector tools on demand, keeping individual tool schemas out of the system prompt.Enable connectors in /aperture:settings. Pin changes take effect on the next Pi restart (Pi cannot unregister tools at runtime).
| Command | Description |
|---|---|
/aperture:onboarding | Onboarding wizard. Only available while onboarding is enabled. |
/aperture:settings | Edit connection, capabilities, providers, and pinned connector tools. |
Configuration is saved globally to ~/.pi/agent/extensions/aperture.json. The settings UI covers everything, but you can also edit the file directly. The APERTURE_BASE_URL environment variable, when set, overrides the configured baseUrl (it is not written back to the config file):
{
"baseUrl": "http://ai.your-tailnet.ts.net",
"proxy": {
"enabled": true,
"upstreamProviders": [
{ "id": "anthropic", "shouldCheckGatewayModels": true }
]
},
"dedicated": {
"enabled": true,
"providers": [
{ "id": "anthropic", "name": "Anthropic", "enabled": true },
{ "id": "openrouter", "name": "OpenRouter", "enabled": true, "api": "anthropic-messages" },
{ "id": "google", "name": "Google", "enabled": false }
]
},
"connectors": {
"enabled": false,
"discoveryTools": true,
"pinnedTools": [
{ "connectorId": "github", "toolName": "github_list_repos" }
]
}
}
Notes:
keepGatewayModelsOnly (per proxy provider, default false) hides that provider’s local models the gateway doesn’t serve instead of letting them fail at request time. Also editable per provider from the Proxy tab in /aperture:settings.api (per provider, unset by default) routes that provider’s models through a specific Pi API (openai-completions, anthropic-messages, openai-responses, google-generative-ai, google-vertex, bedrock-converse-stream) instead of the one auto-picked from the gateway’s compatibility map. Useful for providers Aperture serves through more than one API. Only values the provider reports as supported are offered in /aperture:settings; an override the gateway stops serving falls back to auto with a warning.dedicated.providers list means all gateway providers are included. Passthrough providers are excluded: the dedicated provider never forwards a client credential.~/.pi/agent/models.json, not in the extension config.Referer and x-session-id (the live Pi session id, injected per-request via the before_provider_headers hook) for grouping requests in the Aperture dashboard. Turn them off with "shouldSendProvenanceHeaders": false or the Provenance headers toggle in /aperture:settings. Independent of that setting, the headers are skipped whenever Pi telemetry is disabled (PI_TELEMETRY=0 or enableInstallTelemetry: false in Pi settings) — the same gate Pi uses for its own provider attribution headers.http:// or https://).