Grafana AI SDK
An open-source Go SDK for building streaming, tool-calling AI backends that are wire-compatible with Vercel's AI SDK React frontend hooks.
At a Glance
About Grafana AI SDK
Grafana AI SDK is an open-source Go library published by Grafana Labs under the Apache License 2.0. It gives Go applications a unified API for language model calls, streaming responses, tool execution, structured output, and multi-step agent loops across multiple providers. The SDK follows the design of Vercel's AI SDK and maintains wire-compatibility with its TypeScript frontend hooks, so a Go backend can stream Server-Sent Events directly to React hooks like useChat without a protocol adapter.
What It Is
Grafana AI SDK is a Go developer library in the ai-development-libraries category. Its core job is to let Go services call large language models, stream results to clients, and execute composable tools — all through a single, consistent API. It is designed as a Go-native counterpart to Vercel's AI SDK, enabling teams to replace or complement a TypeScript backend with Go while keeping the same React frontend unchanged.
Core Capabilities
The SDK ships with a focused set of primitives:
StreamText/GenerateText— stream a response token-by-token or wait for the complete result, with built-in retries and multi-step tool execution- React compatibility — serve
useChat,useCompletion, anduseObjecthooks over SSE without any adapter layer - Composable tools — call plain Go functions from a model; require human approval for consequential actions
- Structured output — generate schema-validated objects, arrays, and choices
- Production controls — configurable timeouts, fallback providers, logging, Prometheus metrics, and an Agent Observability middleware
Provider Support
The SDK ships provider packages for several model backends:
- Anthropic (e.g., Claude Sonnet)
- Amazon Bedrock
- OpenAI and OpenAI-compatible APIs
- Grafana's internally provisioned hosted endpoint (for internal services)
Each provider is installed as a separate Go module, keeping the core dependency footprint small.
Architecture and Deployment Model
The SDK sits entirely in the Go backend. A typical deployment pairs a Go HTTP handler that calls aisdk.StreamText(...) with a React frontend using useChat. The Go handler writes SSE frames in the AI SDK wire format; the React hook consumes them directly. The README describes the flow as: Go backend ── SSE ──▶ React frontend. The SDK also supports backend-only usage with no frontend dependency.
The design follows spec-driven development with OpenSpec and maintains upstream parity with Vercel's AI SDK protocol, as documented in CONTRIBUTING.md.
Current Status
The repository was created in late July 2026 and last pushed on July 31, 2026, indicating it is a very recently launched project. It is hosted at github.com/grafana/ai-sdk, carries 186 stars and 6 forks as of early August 2026, and has 4 open issues. The project is actively maintained by Grafana Labs and accepts community contributions under its Code of Conduct.
Community Discussions
Be the first to start a conversation about Grafana AI SDK
Share your experience with Grafana AI SDK, ask questions, or help others learn from your insights.
Pricing
Open Source
Fully free and open-source under the Apache License 2.0. Use, modify, and distribute freely.
- StreamText and GenerateText
- React frontend compatibility
- Composable tool calling
- Structured output
- Multi-step agent loops
Capabilities
Key Features
- StreamText and GenerateText for model calls
- React frontend compatibility (useChat, useCompletion, useObject)
- Server-Sent Events (SSE) streaming
- Composable tool calling with Go functions
- Human-in-the-loop approval for consequential tool actions
- Structured output with schema validation
- Multi-step agent loops
- Multiple provider support (Anthropic, Amazon Bedrock, OpenAI, OpenAI-compatible, Grafana hosted)
- Retries and fallback configuration
- Prometheus metrics integration
- Agent Observability middleware
- Configurable timeouts and logging
