README.md
go-opencode-ai-zen-sdk
Minimal Go SDK for OpenCode Zen.
Install
go get github.com/sacenox/go-opencode-ai-zen-sdk
Examples
See examples/ for runnable examples (agent loop, tools, streaming).
List Models
resp, err := client.ListModels(context.Background())
if err != nil {
panic(err)
}
fmt.Println(len(resp.Data))
Development
gofmt -w *.go
go test ./...
golangci-lint run
Disclaimer
This project is not affiliated with opencode.ai.
Notes
- Base URL defaults to
https://opencode.ai/zen/v1. - Unified routing uses model prefixes:
gpt-*->/responsesclaude-*->/messagesgemini-*->/models/<model>- fallback ->
/chat/completions
- Streaming and timeouts:
Config.Timeoutdefaults to0(no timeout). Do not set it for streaming calls —http.Client.Timeoutis a total round-trip deadline that fires while the SSE body is still being read, causing spuriouscontext deadline exceeded (Client.Timeout ...)errors. Use the requestcontext.Contextto enforce deadlines instead. - Gemini tool calls: preserve
ThoughtSignatureacross tool call → tool result turns.