xonecas.io
6312
Ga

go-opencode-ai-zen-sdk / files

go-opencode-ai-zen-sdk / README.md

1.2 KB
1# go-opencode-ai-zen-sdk
2
3Minimal Go SDK for OpenCode Zen.
4
5## Install
6
7```bash
8go get github.com/sacenox/go-opencode-ai-zen-sdk
9```
10
11## Examples
12
13See `examples/` for runnable examples (agent loop, tools, streaming).
14
15## List Models
16
17```go
18resp, err := client.ListModels(context.Background())
19if err != nil {
20	panic(err)
21}
22fmt.Println(len(resp.Data))
23```
24
25## Development
26
27```bash
28gofmt -w *.go
29go test ./...
30golangci-lint run
31```
32
33## Disclaimer
34
35This project is not affiliated with opencode.ai.
36
37## Notes
38
39- Base URL defaults to `https://opencode.ai/zen/v1`.
40- Unified routing uses model prefixes:
41  - `gpt-*` -> `/responses`
42  - `claude-*` -> `/messages`
43  - `gemini-*` -> `/models/<model>`
44  - fallback -> `/chat/completions`
45- **Streaming and timeouts:** `Config.Timeout` defaults to `0` (no timeout). Do not
46  set it for streaming calls — `http.Client.Timeout` is a total round-trip deadline
47  that fires while the SSE body is still being read, causing spurious
48  `context deadline exceeded (Client.Timeout ...)` errors. Use the request
49  `context.Context` to enforce deadlines instead.
50- **Gemini tool calls:** preserve `ThoughtSignature` across tool call → tool result turns.