@mariozechner/pi-ai package.
Import
API Types
Api
API identifier for LLM providers.Provider
Provider identifier.Model Type
Model metadata and configuration.Example
Thinking Level
Reasoning intensity for extended thinking models."off"- No extended reasoning"minimal"- Minimal reasoning (~100 tokens)"low"- Low reasoning (~500 tokens)"medium"- Medium reasoning (~2000 tokens)"high"- High reasoning (~8000 tokens)"xhigh"- Extra high reasoning (GPT-5.2/5.3 and Opus 4.6 only)
Stream Options
StreamOptions
Base options for all stream functions.number
Sampling temperature (0-2). Higher values = more random.
number
Maximum tokens to generate
AbortSignal
Abort signal for cancellation
string
API key for authentication
Transport
Transport protocol:
"sse", "websocket", or "auto"CacheRetention
Prompt cache retention:
"none", "short", or "long". Default: "short"string
Session identifier for session-based caching
(payload: unknown) => void
Callback for inspecting provider payloads
Record<string, string>
Custom HTTP headers
number
Maximum retry delay in milliseconds. Default:
60000 (60 seconds)Record<string, unknown>
Provider-specific metadata
SimpleStreamOptions
Options forstreamSimple() and completeSimple() with unified reasoning.
ThinkingLevel
Thinking level:
"off", "minimal", "low", "medium", "high", "xhigh"ThinkingBudgets
Custom token budgets for thinking levels (token-based providers only)
ThinkingBudgets
Custom token budgets for thinking levels.Transport Types
Transport
Transport protocol preference."sse"- Server-Sent Events (HTTP streaming)"websocket"- WebSocket connection"auto"- Let provider choose best transport
CacheRetention
Prompt cache retention preference."none"- No caching"short"- Cache for 5 minutes (default)"long"- Cache for 1 hour
Event Types
AssistantMessageEvent
Events emitted during streaming.Provider Options
ProviderStreamOptions
Extensible options allowing provider-specific parameters.StreamOptions with custom fields: