xonecas.io

go-opencode-ai-zen-sdk

Not affiliated with opencode.ai

post-AI small backend ai-agent

12 commits · 2026-02-17 to 2026-02-19 · 26 files

xonecasfix: preserve gemini thought signatures across tool calls1d803d22026-02-19
▸ cmd/ 2026-02-19
▸ examples/ 2026-02-19
· .golangci.yml 2026-02-17
· auth.go 2026-02-19
· client.go 2026-02-19
· config.go 2026-02-19
· errors.go 2026-02-17
· go.mod 2026-02-17
· http.go 2026-02-19
· marshal.go 2026-02-17
· models.go 2026-02-19
· normalize_helpers_test.go 2026-02-19
· normalized.go 2026-02-19
· normalized_test.go 2026-02-19
· parse.go 2026-02-19
· parse_test.go 2026-02-19
· README.md 2026-02-19
· stream.go 2026-02-19
· stream_test.go 2026-02-19
· tool_calls.go 2026-02-19
· types_chat.go 2026-02-19
· types_gemini.go 2026-02-19
· types_messages.go 2026-02-19
· types_responses.go 2026-02-19
· unified.go 2026-02-19
· unified_test.go 2026-02-19

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-* -> /responses
    • claude-* -> /messages
    • gemini-* -> /models/<model>
    • fallback -> /chat/completions
  • Streaming and timeouts: Config.Timeout defaults to 0 (no timeout). Do not set it for streaming calls — http.Client.Timeout is a total round-trip deadline that fires while the SSE body is still being read, causing spurious context deadline exceeded (Client.Timeout ...) errors. Use the request context.Context to enforce deadlines instead.
  • Gemini tool calls: preserve ThoughtSignature across tool call → tool result turns.