Project

go-ai

experimental

Unified LLM API for Go — streaming, tool calling, model registry, and multi-provider support.

Overview

go-ai is a Go port of @mariozechner/pi-ai: a unified LLM library that exposes the same high-level Stream()/Complete() API across multiple providers. It supports streaming deltas, typed tool calling, cross-provider message/context types, automatic model discovery, cost tracking, and provider-specific OAuth flows.

How it works

At the center is a registry-driven core: API providers register streaming implementations, models are registered in a global model registry, and callers invoke Stream() or Complete() with a Context, Model, and optional tool definitions. Provider packages translate the common Go types into each provider's wire protocol and emit a unified event stream (TextDelta, ThinkingDelta, ToolCallStart, Done, etc.). OAuth helpers and generated model metadata sit alongside the core so the same library can drive OpenAI, Anthropic, Google, Mistral, Bedrock, Codex, and compatible APIs without changing the calling code.

Features
🔄
Unified streaming API

Same Stream() / Complete() surface across providers.

🧰
Tool calling

Typed tools with JSON Schema parameters and streamed tool-call deltas.

🌐
Multi-provider

OpenAI, Anthropic, Google, Mistral, Bedrock, Codex, Azure/OpenAI-compatible APIs.

🧠
Cross-language compatible context

JSON-compatible with pi-ai types for Go ↔ TypeScript hand-off.

💵
Cost tracking

Per-request token usage and USD cost breakdown.

🔐
OAuth support

Built-in device flow / PKCE helpers for supported providers.

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