https://github.com/x2d7/interlude
Stream-first LLM library for Go
https://github.com/x2d7/interlude
ai go golang llm streaming tool-calling
Last synced: 13 days ago
JSON representation
Stream-first LLM library for Go
- Host: GitHub
- URL: https://github.com/x2d7/interlude
- Owner: x2d7
- License: mit
- Created: 2026-01-06T18:27:03.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-03-10T22:57:23.000Z (3 months ago)
- Last Synced: 2026-05-26T19:36:30.919Z (18 days ago)
- Topics: ai, go, golang, llm, streaming, tool-calling
- Language: Go
- Homepage:
- Size: 158 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# interlude
Go library for streaming LLM interactions with tool calling support.
Handles streaming, multi-step tool calls, and user approval flows — so you don't have to.
## Install
```bash
go get github.com/x2d7/interlude
```
## Quick Start
See [examples/](examples/) for usage examples.
```go
client := openai.OpenAIClient{
Endpoint: "https://openrouter.ai/api/v1",
APIKey: os.Getenv("API_KEY"),
Model: "gpt-4o",
}
c := chat.Chat{
Messages: chat.NewMessages(),
}
for event := range c.SendUserStream(ctx, &client, "Hello!") {
switch v := event.(type) {
case chat.EventToken:
fmt.Print(v.Content)
case chat.EventError:
log.Fatal(v.Error)
}
}
```
## Tool Calling
```go
toolList := tools.NewTools()
tool, _ := tools.NewTool("get_weather", "Returns weather for a city", func(input struct {
City string `json:"city"`
}) (string, error) {
return "Sunny, 22°C", nil
})
toolList.Add(tool)
c := chat.Chat{
Messages: chat.NewMessages(),
Tools: toolList,
}
for event := range c.SendUserStream(ctx, &client, "What's the weather in Berlin?") {
switch v := event.(type) {
case chat.EventToken:
fmt.Print(v.Content)
case chat.EventToolCall:
v.Resolve(true) // approve the call
case chat.EventCompletionEnded:
fmt.Println()
}
}
```
Tool input schema is generated automatically from your struct using `jsonschema` tags.
## Providers
- OpenAI-compatible APIs (OpenAI, OpenRouter, etc.)
## License
MIT