neuron-explorer
Qwen3.5‑4B 전용 조향형 뉴런 탐색기, 모든 MLP 뉴런을 밀어 결과를 보관·탐색
Grafana AI SDK for Go — streaming, tool-calling AI backends that speak fluent @ai-sdk/react
저장소 README에서 가져옴
README 전체를 불러오는 중입니다. 아래는 저장된 발췌입니다.
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.
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.README 전문 보기 ↗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.
Quick start · Documentation · Examples · API reference
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.
StreamText / GenerateText — stream a response or wait for the complete
result, with retries and multi-step tool executionuseChat, useCompletion, and useObjectCreate 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, and OpenAI-compatible APIs.
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.
| 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
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.
The reusable SDK is licensed under Apache-2.0. The separate
ai-gateway/ module is licensed under
AGPL-3.0-only. See the SDK NOTICE and Gateway
NOTICE for attribution.