Project

go-ai

experimental

Go port of Pi's AI API — multi-provider inference, tools, images and a native durable agent runtime.

Overview

go-ai brings Pi's multi-provider AI API to Go applications. It provides streaming text and reasoning, tool calls, OAuth helpers and image generation, with common message and model types across providers.

The v1.1.0 release follows pi-ai and pi-durable v1.1.0. Alongside the inference library, it includes a native durable runtime for persisted agent conversations, tasks, tools and recovery.

How it works

Applications register the provider packages they need, select a model and call Stream() or Complete(). Each provider translates the common Go request types into its API protocol and returns channel-based events for text, reasoning, tools, usage and completion.

Generated registries describe chat, image and classifier models. OAuth and transport helpers handle provider-specific sign-in, SSE and WebSocket connections. The durable runtime adds session state, compaction and recovery using memory, append-journal or SQLite stores.

Features
🔄
Shared inference API

Streaming and complete responses across OpenAI, Anthropic, Google, Mistral, Bedrock, GitHub Copilot and compatible services.

🧰
Tool calling

JSON Schema parameters, streamed arguments and partial JSON parsing, with constrained sampling where providers support it.

🧠
Reasoning and replay

Provider thinking levels, signed thinking replay, prompt-cache metadata and stop reasons.

🎨
Images and model registries

Image generation through OpenRouter, with generated chat, image and classifier catalogues.

🔐
OAuth and transports

Provider-specific login helpers, SSE streaming and Codex WebSocket support with connection reuse.

🗃
Durable agent runtime

Persisted conversations, owned tasks and tools, subscriptions, compaction and recovery. Earlier journal formats are not an upgrade compatibility guarantee.

🔁
Cross-language messages

JSON-compatible message, context, tool and usage types for supported Go/TypeScript hand-offs. JavaScript-only runtime integrations are adapted rather than copied unchanged.

Architecture
Your Go app Stream() / Complete() Config auth.json · env vars Registry provider + model discovery Tool calling auto-dispatch Context mgmt overflow/trim Providers OpenAI Chat + Responses Anthropic Messages API Copilot OAuth + token Event stream SSE deltas · tool calls SSE Unified Go inference library — multi-provider streaming with tool calling
Posts