Providers and models
PiSharp has every provider and chat API that Pi v1.2.0 has, with Pi’s model catalogs. Pi’s Providers and Models pages apply.
Sign in
Section titled “Sign in”Type /login in the terminal UI and pick a provider. Every built-in provider takes an API key. These also offer a browser or device sign-in: Anthropic, OpenAI (ChatGPT), OpenAI Codex, GitHub Copilot, OpenRouter, xAI, Kimi, Meta and Radius. /logout removes a sign-in.
Sign-ins are saved in ~/.pi/agent/auth.json, which Pi uses too.
You can also set the provider’s environment variable, such as ANTHROPIC_API_KEY, OPENAI_API_KEY or GEMINI_API_KEY. pisharp --help lists them all. --api-key sets a key for one run.
Some providers need more than a key:
- Amazon Bedrock uses the AWS credential chain:
AWS_PROFILE, access keys, SSO,credential_processor a Bedrock API key inAWS_BEARER_TOKEN_BEDROCK. SetAWS_REGION. - Google Vertex takes an API key or Application Default Credentials (user, service account, impersonated service account and workload identity federation).
- Cloudflare needs
CLOUDFLARE_ACCOUNT_ID, andCLOUDFLARE_GATEWAY_IDfor AI Gateway. - Azure OpenAI reads the
AZURE_OPENAI_*variables.AZURE_OPENAI_BASE_URLwins; otherwiseAZURE_OPENAI_RESOURCE_NAMEbecomeshttps://<name>.openai.azure.com/openai/v1. As in Pi, the name is taken as given and read as a URL, so names with dots or upper case work. - llama.cpp connects to a local router server. See Local models with llama.cpp.
Choose a model
Section titled “Choose a model”/modelin the terminal UI, orCtrl+Pto cycle.--model sonnet:high,--model openai/gpt-4o: an id,provider/idor fuzzy match, with an optional thinking level.--modelsor theenabledModelssetting limits which modelsCtrl+Pcycles through.--list-models [search]prints the models you can use.
At startup, interactive mode refreshes the model catalogs from pi.dev, as Pi does. --offline or PI_OFFLINE=1 turns that off. pisharp update --models refreshes them by hand.
With an OpenRouter key or sign-in, the refresh also asks OpenRouter which chat models that key may use, as Pi 1.2.0 does. The OpenRouter list then shows only those models, with the key’s context size, output limit and prices, and is saved for offline use. A baseUrl for OpenRouter in models.json, such as a regional endpoint, is used for that request.
Your own endpoints and models
Section titled “Your own endpoints and models”~/.pi/agent/models.json adds providers and models, or overrides built-in ones, in Pi’s format. A baseUrl there also works for built-in providers, for example to send Anthropic requests through a proxy.
Classifier and image models
Section titled “Classifier and image models”Pi’s classifier APIs (OpenAI decisions, TypeSafe and Cloudflare system-one, llama.cpp) and OpenRouter image generation work. Codemode scripts reach them through models.classify() and models.generateImages(), and extensions through ctx.modelRegistry. TypeScript and C# extensions can register their own classifier and image providers.
OpenAI Codex transport
Section titled “OpenAI Codex transport”As in Pi, Codex requests go over a WebSocket first. If the WebSocket fails before the first event, PiSharp falls back to server-sent events and stays on them for the rest of the session. Request bodies sent over server-sent events are compressed with zstd. The transport setting (also in /settings) chooses:
| Value | Behaviour |
|---|---|
auto (default) |
WebSocket. Later turns reuse the open connection and send only the new input. |
websocket-cached |
The same as auto. |
websocket |
WebSocket, sending the whole request every turn. |
sse |
Server-sent events only. |
The WebSocket connection gets 15 seconds to open. PiSharp doesn’t read Pi’s websocketConnectTimeoutMs setting yet.
Differences from Pi
Section titled “Differences from Pi”- Requests to Anthropic, Azure, Bedrock, Mistral and OpenAI-compatible endpoints carry a
PiSharpuser agent instead of the SDK’s. - PiSharp’s zstd frames are valid zstd but not byte for byte what Node’s zstd writes.
The Parity page lists the smaller differences.