/** * Gateway provider from env — the launch knob a HOST embeds pi-gui with. * * pi bakes each provider's base URL into its definition; there is no env var that moves it. * A host that routes model traffic through its own Anthropic-Messages-compatible endpoint * (a local proxy, a relay, any LiteLLM-style gateway) therefore needs exactly one seam: set * `PI_GUI_GATEWAY_URL` and pi-gui registers an IN-MEMORY provider pointed there — nothing is * written to `~/.pi`, and none of this engages when the variable is absent, so standalone * use is byte-for-byte unaffected. * * PI_GUI_GATEWAY_URL endpoint origin (anthropic-messages wire) * PI_GUI_GATEWAY_KEY credential, read at request time (sent as x-api-key) * PI_GUI_GATEWAY_MODELS comma-separated model ids, VERBATIM on the wire * (e.g. "google/gemini-3.5-flash,claude-sonnet-5") * PI_GUI_GATEWAY_PROVIDER pi-local provider id, default "gateway" — only an addressing * prefix ("/"), never sent upstream * PI_GUI_MODEL default model override, e.g. "gateway/google/gemini-3.5-flash" * * Both hosting shapes consume the same config: the pi runtime (TUI/print/rpc) via * `pi.registerProvider(...)` with {@link gatewayProviderConfig}, and the bare pi-agent-core * `run` path via {@link gatewayProvider}. Kept import-light on purpose — pi-ai is loaded * lazily so `pi-gui mcp` and plain env parsing never pay for it. */ import type { Api, Provider } from "@earendil-works/pi-ai"; export declare const GATEWAY_URL_ENV = "PI_GUI_GATEWAY_URL"; export declare const GATEWAY_KEY_ENV = "PI_GUI_GATEWAY_KEY"; export declare const GATEWAY_MODELS_ENV = "PI_GUI_GATEWAY_MODELS"; export declare const GATEWAY_PROVIDER_ENV = "PI_GUI_GATEWAY_PROVIDER"; export interface GatewayConfig { /** pi-local provider id (addressing prefix only). */ providerId: string; /** Endpoint origin the anthropic-messages wire is sent to. */ baseUrl: string; /** Model ids offered, verbatim wire ids. */ models: string[]; } /** Parse the knob. Null when the knob is off (no URL) or unusable (no models — warned once). */ export declare function gatewayFromEnv(env?: NodeJS.ProcessEnv): GatewayConfig | null; /** The default model spec for a gateway launch: PI_GUI_MODEL wins, else the first roster entry. */ export declare function gatewayDefaultModel(cfg: GatewayConfig, env?: NodeJS.ProcessEnv): string; /** * Plain config for the pi runtime's `pi.registerProvider(id, config)` (TUI/print/rpc path). * The `$ENV` apiKey form defers the credential read to request time, so a key rotated by the * host between requests is picked up without a relaunch. */ export declare function gatewayProviderConfig(cfg: GatewayConfig): { name: string; baseUrl: string; apiKey: string; api: Api; models: Array<{ id: string; name: string; reasoning: boolean; input: ("text" | "image")[]; cost: { input: number; output: number; cacheRead: number; cacheWrite: number; }; contextWindow: number; maxTokens: number; }>; }; /** * A live pi-ai Provider for the bare pi-agent-core `run` path (which never reads pi's * models.json or extension registrations). Reuses the builtin anthropic provider's stream * implementation — same wire, different endpoint + credential source. */ export declare function gatewayProvider(cfg: GatewayConfig): Promise;