https://github.com/coder/aisdk-go
A Go implementation of Vercel's AI SDK Data Stream Protocol.
https://github.com/coder/aisdk-go
ai go sdk vercel
Last synced: about 1 month ago
JSON representation
A Go implementation of Vercel's AI SDK Data Stream Protocol.
- Host: GitHub
- URL: https://github.com/coder/aisdk-go
- Owner: coder
- License: mit
- Created: 2025-04-06T04:44:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-11-20T02:02:43.000Z (7 months ago)
- Last Synced: 2026-04-25T00:41:42.027Z (about 1 month ago)
- Topics: ai, go, sdk, vercel
- Language: Go
- Homepage:
- Size: 75.2 KB
- Stars: 40
- Watchers: 4
- Forks: 9
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# aisdk-go
[](https://github.com/coder/aisdk-go/releases)
[](https://godoc.org/github.com/coder/aisdk-go)
[](https://github.com/coder/aisdk-go/actions)
> [!WARNING]
> This library is super new and may change a lot.
A Go implementation of Vercel's AI SDK [Data Stream Protocol](https://sdk.vercel.ai/docs/ai-sdk-ui/stream-protocol#data-stream-example).
- Supports OpenAI, Google, and Anthropic (with Bedrock support)
- Examples for integrating `useChat`
- Chain tool usage in Go, just like `maxSteps`
```ts
// frontend.tsx
const { messages } = useChat({
// Points to our Go backend!
api: "/api/chat",
})
```
```go
// backend.go
// Accept the POST request...
var req *aisdk.Chat
messages, err := aisdk.MessagesToOpenAI(req.Messages)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// Convert the http.ResponseWriter to a Data Stream.
dataStream := aisdk.NewDataStream(w)
stream := openaiClient.Chat.Completions.NewStreaming(...)
aisdk.PipeOpenAIToDataStream(stream, dataStream)
```
## Development
Run tests with `go test`. Start the `useChat` demo with:
```bash
# any or all of these can be set
export OPENAI_API_KEY=
export ANTHROPIC_API_KEY=
export GOOGLE_API_KEY=
cd demo
bun i
bun dev
```