Go LLM SDK for streaming, tool-calling AI backends (plus frontend React lib)
Summary
Grafana released an AI SDK for Go that provides a unified API for LLM calls, streaming, tool execution, and structured output, with built-in compatibility with Vercel's AI SDK React frontend.
View Cached Full Text
Cached at: 07/30/26, 01:49 PM
grafana/ai-sdk
Source: https://github.com/grafana/ai-sdk
Call language models, stream responses, execute tools, and serve AI-powered endpoints from Go. Use the SDK on its own or pair it with an AI SDK React frontend.
Why
The SDK gives Go applications one API for model calls, streaming, tools,
structured output, and multi-step agents across supported providers. It follows
the design of Vercel’s AI SDK and stays wire-compatible
with its TypeScript frontend hooks. A Go endpoint can stream Server-Sent Events
(SSE) directly to hooks such as useChat.
Go backend React frontend
────────── ──────────────
aisdk.StreamText(...) ── SSE ──▶ useChat({ transport })
aisdk.WriteUIMessageStream(w, …) // same protocol
See How a request runs for the generation, tool, and streaming flow. Reuse an existing AI SDK React frontend or replace a TypeScript backend with Go without adding a protocol adapter.
Features
StreamText/GenerateText— stream a response or wait for the complete result, with retries and multi-step tool execution- React compatibility — serve
useChat,useCompletion, anduseObject - Composable tools — call plain Go functions from a model and require approval for consequential actions
- Structured output — generate schema-validated objects, arrays, and choices
- Multiple providers — call Anthropic, Amazon Bedrock, OpenAI, OpenAI-compatible APIs, and Grafana’s hosted endpoint from internal services
- Production controls — configure timeouts, fallback, logging, Prometheus metrics, and Agent Observability
Install
Create a Go project and install the core module and one provider:
mkdir ai-sdk-quickstart
cd ai-sdk-quickstart
go mod init example.com/ai-sdk-quickstart
go get github.com/grafana/ai-sdk
go get github.com/grafana/ai-sdk/providers/anthropic
See Choose a provider for Amazon Bedrock, OpenAI, OpenAI-compatible APIs, and the internally provisioned Grafana hosted endpoint.
Quick start
Save this complete program as main.go. It makes one model call and prints the
response:
package main
import (
"context"
"fmt"
"log"
"os"
aisdk "github.com/grafana/ai-sdk"
"github.com/grafana/ai-sdk/provider"
"github.com/grafana/ai-sdk/providers/anthropic"
)
func main() {
apiKey := os.Getenv("ANTHROPIC_API_KEY")
if apiKey == "" {
log.Fatal("ANTHROPIC_API_KEY is required")
}
model := anthropic.New(apiKey, "claude-sonnet-5")
result, err := aisdk.GenerateText(context.Background(), model,
aisdk.WithModelMessages(provider.UserText("Explain goroutines in one sentence.")),
)
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Text)
}
Run it with an Anthropic API key:
ANTHROPIC_API_KEY=sk-... go run .
For project initialization and credential guidance, follow Installation. To stream this response to a React client, continue with Build a full-stack chat.
Where to go next
| Goal | Start here |
|---|---|
| Make model calls from Go | Generate text from Go |
| Build a React chat | Full-stack chat |
| Return typed data | Structured output |
| Let a model call Go code | Tools |
| Build a reusable agent | Agent loops |
| Choose a model provider | Provider overview |
| Add logging or observability | Middleware overview |
| Prepare for production | Production checklist |
Full index: Documentation · Runnable code: Examples · Exact APIs: pkg.go.dev
Contributing
Contributions are welcome. CONTRIBUTING.md covers the development setup, the two conventions that make this repository unusual — upstream parity with the Vercel AI SDK, and spec-driven development with OpenSpec — and the pull request checklist. All participants follow our Code of Conduct.
License
Apache License 2.0. This SDK follows the design of Vercel’s AI SDK, also Apache-2.0 licensed; attribution is recorded in NOTICE.
Similar Articles
@ggerganov: llama.cpp now has an official website: https://llama.app Our goal is to make local AI accessible to everyone, and impro…
llama.cpp, the popular local AI inference tool, now has an official website (llama.app) with a cross-platform installer and improved user experience to make local AI more accessible.
Agentic Workflow Visualization and API Gateway
Building an open-source API gateway for agentic AI workflows that provides visualization of multi-LLM and tool calls, tracking tokens, cost, and latency without requiring code instrumentation. Uses Rust and Go servers with a Python correlator, seeking collaborators and feedback from AI ops users.
Show HN: GoModel – an open-source AI gateway in Go; 44x lighter than LiteLLM
GoModel is a new open-source AI gateway written in Go that offers a unified OpenAI-compatible API for multiple providers and claims to be 44× lighter than LiteLLM.
Inference Engines for LLMs & Local AI Hardware (2026 Edition)
This article provides a comprehensive guide to LLM inference engines for local AI hardware in 2026, explaining how to choose based on hardware strategy, workload, and serving model, and covering engines like llama.cpp, MLX, ExLlamaV2/3, vLLM, SGLang, TensorRT-LLM, and NVIDIA Dynamo.
@llmgateway: https://x.com/llmgateway/status/2090875947285393595
TanStack AI releases a first-party LLM Gateway adapter, enabling developers to access over 200 AI models from 40+ providers with a single API key and one-line model switching.