Skip to main content
Router Core includes a first-party runtime built on @mupt-ai/pi-ai. Pi translates normalized router requests into provider API calls and converts output back into the framework’s completion or stream contract. Supports OpenAI, Anthropic, Google, Bedrock, OpenRouter, Fireworks-hosted models, and any OpenAI-compatible API in Pi’s catalog.

Inject Credentials

When all models use the same credential:
Router Core never reads environment variables. The host reads keys and injects them.

Declare Catalog Models

pi.model() validates a model exists in Pi’s catalog and creates a RouterModel declaration:

What Gets Translated

Pi carries these normalized features into provider calls:
  • Messages, images, tool calls, tool results
  • Prior-turn reasoning and hosted web_search calls
  • Function tools, named/required tool choice, strict/parallel tools
  • Temperature, top-p, token limits, stop sequences
  • Provider-independent reasoning effort and token budgets
  • Text, JSON object, and JSON Schema output formats
  • Cache keys, streaming, cancellation
Base64 images work out of the box. Remote image URLs are rejected — download and validate them in the host, or use a custom executor.

Retries And Errors

maxRetries controls Pi’s same-model retries. Provider failures, malformed output, invalid streams, and cancellation become RouterFrameworkError. Cross-model fallback belongs to createRouter, not the runtime: enable it with the fallback option and it works with the Pi executor like any other. For fully managed retries and fallback chains, use Dari’s managed platform.

Per-API Option Gating

Some normalized options can’t be expressed on every provider API. Pi rejects those combinations up front as invalid_request (HTTP 400) instead of surfacing a provider 5xx:
  • stop sequences on openai-responses / azure-openai-responses
  • top_p on anthropic-messages
  • Forcing a specific tool with tool_choice on google-generative-ai / google-vertex
  • response_format: json_object on bedrock-converse-stream
  • Non-auto image detail on APIs that can’t preserve it (details are auto, low, or high and pass through on the OpenAI APIs)
Two options degrade instead of failing: json_object on anthropic-messages becomes a permissive JSON Schema (Anthropic has no native JSON-object mode), and metadata is never forwarded — only user, which maps to Anthropic’s metadata.user_id and nothing on other APIs.

Mix Pi And Custom Executors

See Custom Executors for the output contracts.