Contributions welcome. Here's how to get started.
- Go 1.25+
golangci-lint(for linting)
git clone https://github.com/zendev-sh/goai.git
cd goai
go test ./...goai/
├── *.go # Core SDK (GenerateText, StreamText, etc.)
├── provider/
│ ├── provider.go # LanguageModel, EmbeddingModel, ImageModel interfaces
│ ├── types.go # Shared types (Message, Part, Usage, etc.)
│ ├── token.go # TokenSource, CachedTokenSource
│ ├── openai/ # OpenAI provider
│ ├── anthropic/ # Anthropic provider
│ ├── google/ # Google Gemini provider
│ └── ... # Other providers
├── internal/
│ ├── openaicompat/ # Shared codec for OpenAI-compatible providers
│ ├── sse/ # SSE parser
│ └── httpc/ # HTTP utilities
└── examples/ # Usage examples
git checkout -b feat/your-feature- Write code and tests
- Run tests:
go test ./... - Run linter:
golangci-lint run - Build:
go build ./...
- Keep PRs focused - one feature or fix per PR
- Include tests for new functionality
- Update examples if the public API changes
- Standard
gofmt/goimportsformatting - Follow existing patterns in the codebase
- Prefer Go idioms: small interfaces, composition, functional options
- Use
internal/for implementation details that shouldn't be public API
Most providers are OpenAI-compatible. To add one:
- Create
provider/<name>/<name>.go - Use
internal/openaicompatfor request/response handling - Implement
Chat()constructor returningprovider.LanguageModel - Add tests with mock HTTP server (see existing providers for patterns)
- Add an entry to the Provider Table in
README.md
For non-OpenAI-compatible providers (like Anthropic, Google, Cohere), implement the full request/response mapping.
-
Chat(modelID, ...Option) provider.LanguageModel -
WithAPIKey(key)option -
WithHTTPClient(c)option -
WithTokenSource(ts)option - Streaming support (
DoStream) - Error handling (
ParseHTTPError) - Per-request headers (
_headersextraction indoHTTP) -
var _ provider.LanguageModel = (*chatModel)(nil)compile-time check - Tests with mock HTTP server (90% coverage target)
# All tests
go test ./...
# Specific package
go test ./provider/openai/
# With verbose output
go test -v ./provider/anthropic/
# With coverage
go test -cover ./...- Use
net/http/httptestfor mock HTTP servers - Test both streaming and non-streaming paths
- Test error handling (4xx, 5xx, malformed responses)
- Test tool call parsing and finish reason mapping
- Use GitHub Issues
- Include: Go version, provider, minimal reproduction code
- For API errors, include the HTTP status code and error message (redact API keys)
By contributing, you agree that your contributions will be licensed under the MIT License.