pi-ai uses a registry of API implementations. A provider offers models through a specific API — for example, Anthropic usesDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/earendil-works/pi/llms.txt
Use this file to discover all available pages before exploring further.
anthropic-messages, while OpenAI uses openai-responses. Many third-party providers reuse the openai-completions API (OpenAI Chat Completions format).
Built-in APIs
| API identifier | Description | Exports |
|---|---|---|
anthropic-messages | Anthropic Messages API | streamAnthropic, AnthropicOptions |
google-generative-ai | Google Generative AI API | streamGoogle, GoogleOptions |
google-vertex | Google Vertex AI API | streamGoogleVertex, GoogleVertexOptions |
mistral-conversations | Mistral Conversations API | streamMistral, MistralOptions |
openai-completions | OpenAI Chat Completions API (widely compatible) | streamOpenAICompletions, OpenAICompletionsOptions |
openai-responses | OpenAI Responses API | streamOpenAIResponses, OpenAIResponsesOptions |
openai-codex-responses | OpenAI Codex Responses API | streamOpenAICodexResponses, OpenAICodexResponsesOptions |
azure-openai-responses | Azure OpenAI Responses API | streamAzureOpenAIResponses, AzureOpenAIResponsesOptions |
bedrock-converse-stream | Amazon Bedrock Converse API | streamBedrock, BedrockOptions |
Provider to API mapping
| Provider | API |
|---|---|
anthropic | anthropic-messages |
google | google-generative-ai |
google-vertex | google-vertex |
openai | openai-responses |
openai-codex | openai-codex-responses |
azure-openai-responses | azure-openai-responses |
mistral | mistral-conversations |
amazon-bedrock | bedrock-converse-stream |
fireworks | anthropic-messages (Anthropic-compatible) |
kimi-coding | anthropic-messages (Anthropic-compatible) |
xiaomi | anthropic-messages (Anthropic-compatible) |
xai, groq, cerebras, deepseek, openrouter, vercel-ai-gateway, minimax, cloudflare-workers-ai, cloudflare-ai-gateway, github-copilot, opencode, opencode-go | openai-completions |
Custom models
Define aModel<TApi> directly for local servers, proxied endpoints, or any OpenAI-compatible API:
- Ollama
- LiteLLM
- Proxied endpoint
- Ollama reasoning model
OpenAI compatibility settings
Many OpenAI-compatible servers differ in which features they support. Thecompat field on a Model<'openai-completions'> lets you override the library’s URL-based auto-detection:
compat is not set, the library falls back to URL-based detection. If compat is partially set, unspecified fields use the detected defaults. Common cases:
- LiteLLM proxies: Set
supportsStore: false - Ollama / vLLM / SGLang: Set
supportsDeveloperRole: false,supportsReasoningEffort: false - Custom inference servers: May use
maxTokensField: 'max_tokens'or non-standard features
openai-responses models, the compat field only supports Responses-specific flags (sendSessionIdHeader, supportsLongCacheRetention).
Environment variables
Set these in Node.js to avoid passingapiKey explicitly on every call:
| Provider | Environment variable(s) |
|---|---|
| OpenAI | OPENAI_API_KEY |
| Azure OpenAI | AZURE_OPENAI_API_KEY + AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME; optional: AZURE_OPENAI_API_VERSION, AZURE_OPENAI_DEPLOYMENT_NAME_MAP |
| Anthropic | ANTHROPIC_API_KEY or ANTHROPIC_OAUTH_TOKEN |
| DeepSeek | DEEPSEEK_API_KEY |
GEMINI_API_KEY | |
| Vertex AI | GOOGLE_CLOUD_API_KEY or GOOGLE_CLOUD_PROJECT + GOOGLE_CLOUD_LOCATION + ADC |
| Mistral | MISTRAL_API_KEY |
| Groq | GROQ_API_KEY |
| Cerebras | CEREBRAS_API_KEY |
| Cloudflare AI Gateway | CLOUDFLARE_API_KEY + CLOUDFLARE_ACCOUNT_ID + CLOUDFLARE_GATEWAY_ID |
| Cloudflare Workers AI | CLOUDFLARE_API_KEY + CLOUDFLARE_ACCOUNT_ID |
| xAI | XAI_API_KEY |
| Fireworks | FIREWORKS_API_KEY |
| OpenRouter | OPENROUTER_API_KEY |
| Vercel AI Gateway | AI_GATEWAY_API_KEY |
| zAI | ZAI_API_KEY |
| MiniMax | MINIMAX_API_KEY |
| OpenCode Zen / OpenCode Go | OPENCODE_API_KEY |
| Kimi For Coding | KIMI_API_KEY |
| Xiaomi MiMo (API billing) | XIAOMI_API_KEY |
| Xiaomi MiMo Token Plan (China) | XIAOMI_TOKEN_PLAN_CN_API_KEY |
| Xiaomi MiMo Token Plan (Amsterdam) | XIAOMI_TOKEN_PLAN_AMS_API_KEY |
| Xiaomi MiMo Token Plan (Singapore) | XIAOMI_TOKEN_PLAN_SGP_API_KEY |
| GitHub Copilot | COPILOT_GITHUB_TOKEN or GH_TOKEN or GITHUB_TOKEN |
Faux provider for testing
registerFauxProvider() registers an in-memory provider for deterministic tests and demos. It is opt-in and not part of the built-in provider set.
Faux provider notes
Faux provider notes
- Responses are consumed from a queue in request start order
- If the queue is empty, the provider returns an error message:
"No more faux responses queued" - Use
setResponses([...])to replace the queue;appendResponses([...])to add more registration.modelsexposes all registered faux models;getModel()returns the first one,getModel(id)a specific one- Usage is estimated at roughly 1 token per 4 characters
- When
sessionIdis present andcacheRetentionis not"none", prompt cache reads and writes are simulated - Tool call arguments stream incrementally via
toolcall_deltachunks - By default, each streamed chunk is emitted on its own microtask; set
tokensPerSecondto pace delivery in real time - Use one registration per deterministic scripted flow; register separate faux providers for independent concurrent flows