Go LLM SDK for streaming, tool-calling AI backends (plus frontend React lib)
TL;DR Highlight
A Go backend streams SSE straight into React useChat using the Vercel AI SDK protocol
Who Should Read
A backend developer building an AI chat backend in Go who wants to connect a React useChat frontend without a protocol adapter
Core Mechanics
- Go talks directly to Vercel AI SDK frontends
- It is designed to be wire-compatible with the Vercel AI SDK's TypeScript frontend hooks.
- A Go endpoint streams Server-Sent Events (SSE) directly to hooks such as useChat.
- No protocol adapter when swapping backends
- You can reuse an existing AI SDK React frontend.
- You can also replace a TypeScript backend with Go without an adapter.
- One API for calls, streaming, tools, and agents
- StreamText and GenerateText stream a response or return the full result, with retries and multi-step tool execution.
- It also generates schema-validated structured output (objects, arrays, choices).
- Plain Go functions as tools, with approval
- A model can call plain Go functions.
- Consequential actions can require approval.
- Providers and production controls included
Community Reactions
- A commenter asked what the SDK is for
- They asked why use it instead of calling the OpenAI API directly.
- A reply explained it is a Go backend wire-compatible with the Vercel AI UI SDK.
- Resumable streaming is missing, one commenter said
- They said it misses resumable streaming after a dropped SSE connection, and multi-device support.
- Their view is that such SDKs are easy to drop in but hard to build resilient systems on.
- Requests to compare with similar SDKs
- Commenters asked how it compares to genkit and Google's ADK.
- One commenter said they have been building a Go project called gollem for five months.
- Skepticism about AI-generated code
- One commenter asked whether a human designed it or it is AI slop.
- They said they are much more conservative about adding packages to production and would review it later.
How to Apply
- Run the quick-start example locally
- Create a Go module and go get the core and anthropic provider packages.
- Set ANTHROPIC_API_KEY and run the GenerateText example with go run.
- Point your useChat frontend at a Go endpoint
- Change the URL your AI SDK React transport points to so it hits the Go server.
- On the server, write the StreamText result to SSE with WriteUIMessageStream.
- Test reconnect behavior before adopting
- Cut the network mid-stream and observe what happens on reconnect.
- If you need recovery, decide on a separate layer first.
- Put approval gates on risky tools
- Mark high-impact Go functions like payments or deletes as requiring approval.
- Expose read-only functions as tools without approval.
Try It
# Run in a terminal: quick start (install and example as in the README)
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
# Save as main.go
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
ANTHROPIC_API_KEY=sk-... go run .
# Next: follow Build a full-stack chat in the docs to connect StreamText to React useChatTerminology
Related Papers
Same Simulation, Different Evidence: Where Retrieved Tool Output Costs LLM Agents Accuracy
Saving long tool output to files cut GPT-5.1 accuracy by 11.3 points; naming the authoritative file restored it.
Fake News, Real Crashes: Information Injection Attacks on LLM Financial Trading Agents
Fake headlines hijacked LLM trading agents 62% of the time versus 14% for prompt injection.
Harness Engineering 101: The LLM is the brain, the harness is the body
An agent is a loop managing a JSON array; 16 chapters build one from scratch
Harness2 by Google Research – Recursive Agent Harnessing
Recursively refining the harness with fixed model weights raised benchmark scores by up to 11.8 points.
Ousted Savannah police officer gave ICE agent husband access to Flock system
A police officer shared her Flock login with her ICE-agent husband; an audit found 983 searches and she was fired
Tmux and Claude Code: Sessions, Send-Keys, and the Ceiling
Running Claude Code agents in tmux works well, but limits appear around four agents.