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
- It supports Anthropic, Amazon Bedrock, OpenAI, and OpenAI-compatible APIs.
- You can configure timeouts, fallback, logging, Prometheus metrics, and Agent Observability.
- Licensing differs by module
- The SDK itself is Apache-2.0.
- The separate ai-gateway/ module is AGPL-3.0-only.
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
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques