Project

rs-ai

experimental

Rust port of @earendil-works/pi-ai with a shared streaming event protocol and provider-neutral registry.

Overview

rs-ai is a Rust port of @earendil-works/pi-ai, built around the same model registry, message types and streaming event protocol as the TypeScript original. It targets native Rust applications that need provider switching, tools and streaming without maintaining a separate integration for each API, but it remains an early port rather than full upstream parity.

It tracks the bounded pi-ai v0.84.0 release surface. Core types, providers, OAuth, deferred response lifecycle, telemetry and generated catalogues have deterministic parity evidence; transport and runtime differences remain explicit.

How it works

The registry resolves a model and provider, reads credentials from the process environment and selects the appropriate compatibility settings. Provider implementations issue HTTP, WebSocket or AWS SDK requests and convert their responses into a shared Rust event stream.

The common layer handles retries, diagnostics, prompt-cache metadata, message transformation, partial tool-call JSON and context-overflow checks. Dropping the returned stream cancels HTTP work; this differs from the upstream abort-signal model.

Features
Shared runtime types

Messages, tools, usage, model metadata and stream events use a single provider-neutral type system.

Streaming providers

Implemented paths include OpenAI, OpenAI Responses, Anthropic, Gemini, Mistral, Codex, Bedrock, Gemini CLI and Baseten.

Native transports

Bedrock uses the AWS SDK; Codex supports WebSocket and SSE transports.

OAuth framework

Includes a PKCE-based OAuth framework and the provider-specific paths needed by supported sign-in flows.

Runtime helpers

Retry handling, logging, diagnostics, session resources, validation, prompt-cache helpers and partial JSON parsing.

Catalogues and runtime differences

The release-pinned registry contains 1,153 text models across 38 providers and 42 image models. Rust cancels work by dropping the stream; provider transport differences remain documented.

Architecture
Rust application stream · complete · tools rs-ai registry models + providers Runtime layer env · compat · retries Provider transport HTTP · WebSocket · AWS SDK Shared event stream text · reasoning · tools · usage Provider-neutral LLM streaming API for Rust