The AI SDK is a standalone Go library for building production AI applications. It provides type-safe text generation, structured output via generics, agent orchestration, multi-tier memory, RAG pipelines, workflow engines, and native safety guardrails -- all built for Go's concurrency model with zero external dependencies for core features.
Installation01
go get github.com/xraph/ai-sdkKey Features02
Type-safe generics -- structured output with compile-time type checking
Multiple LLM providers -- OpenAI, Anthropic, Ollama, Azure, HuggingFace, LM Studio
Agent patterns -- ReAct (Reasoning + Acting) and Plan-Execute agents
Multi-tier memory -- working, short-term, long-term, and episodic memory with automatic consolidation
RAG pipeline -- document chunking, embedding, semantic search, and reranking
Workflow engine -- DAG-based orchestration with parallel execution
Tool system -- auto-discovery from Go functions with JSON schema validation
Native guardrails -- zero-cost PII detection, toxicity filtering, and prompt injection prevention
Cost management -- budget tracking, usage analytics, and optimization recommendations
Resilience -- circuit breakers, retries with exponential backoff, and rate limiting
Streaming -- real-time token streaming with thinking/reasoning extraction
MCP support -- Model Context Protocol client and server
17+ integrations -- pgvector, Qdrant, Pinecone, Redis, PostgreSQL, and more
Documentation03
Install the SDK, configure a provider, and run your first generation in minutes.
Fluent builder API for text generation with prompt templates and callbacks.
Generate typed Go structs from LLM responses with automatic JSON schema validation.
Real-time token streaming with reasoning extraction and UI component generation.
LLM provider interface, built-in providers, and manager configuration.
Stateful agents with tool integration, state persistence, and multi-agent orchestration.
Reasoning and Acting agent pattern with reflection and confidence tracking.
Plan-then-execute agent with verification and replanning.
Tool registry with auto-discovery from Go functions and JSON schema validation.
Multi-tier memory system with automatic consolidation and semantic recall.
Retrieval-Augmented Generation with chunking, embeddings, and reranking.
DAG-based workflow engine with parallel execution and conditional branching.
Native PII detection, toxicity filtering, and prompt injection prevention.
Usage tracking, budget enforcement, and optimization recommendations.
Circuit breakers, retry policies, and rate limiting.
Distributed tracing, structured logging, and metrics collection.
Vector stores, state stores, caches, and embedding providers.
Model Context Protocol client and server for external data and tools.
Using the AI SDK inside a Forge application via the AI extension.