Production-ready Go SDK for Groq's LPU inference engine. Build blazing fast AI applications with comprehensive support for chat completions, streaming, audio transcription, embeddings, and advanced features like Compound AI, Reasoning Models, and RAG workflows.
v0.3.0 Released - Python SDK 0.37.0 Parity! Production-ready stable release with 73.5%+ test coverage (238 tests), A- audit grade (91%), zero race conditions, and complete Python SDK v0.37.0 parity. New features: MCP Tool Discovery, JSON Schema Output, Enhanced Usage Stats, Audio Enhancements, Cache Statistics.
In Production: This SDK is actively used in production at Zaguán. Successfully tested with OpenWebUI integration and Qwen-Code with full function calling support, handling real-world AI workloads with proven reliability.
238 comprehensive tests covering all major functionality. 100% coverage on all 6 resource packages.
91% audit score with comprehensive code quality analysis. Production-ready quality standards.
Verified with Go's race detector. Safe for production concurrent workloads.
Complete feature parity with Python SDK v0.37.0. All APIs and advanced features supported.
Optimized for Groq's LPU inference engine. Experience single-digit millisecond latency for LLM responses.
Full support for chat completions with popular open models like Llama 3, Mixtral, and Gemma.
Convert audio to text using Whisper models. Fast and accurate transcription and translation.
Multi-model orchestration with custom tool configuration. Web search, code interpreter, and Wolfram integration.
Provide documents as context with citation support. Build powerful RAG workflows with text or JSON documents.
Support for complex content parts including text, images, and structured JSON documents. Full parity with Groq API v0.37.0.
Advanced reasoning with configurable effort levels and output formats. Support for hidden, raw, and parsed reasoning.
Generate vector embeddings and manage file uploads. Complete support for Models, Files, and Batches APIs.
Native Server-Sent Events (SSE) support with easy-to-use iterators. Real-time streaming for better UX.
Strict typing with generic Optional[T] types for precise control. Distinguish zero-values from omitted fields.
All methods accept context.Context for cancellation and timeouts. Proper resource cleanup guaranteed.
Exponential backoff retries, rate limit handling, and safe error types. Production-grade reliability.
Fine-grained web search control with domain filtering and result customization. Enhance AI responses with real-time data.
Clean, extensible API design following Go best practices. Flexible configuration with option functions.
API key support with TLS. Environment variable integration for safe credential management.
238 comprehensive tests with 73.5%+ coverage. All core APIs are 100% tested for production reliability.
Comprehensive examples and API documentation. Clear usage patterns and best practices for all features.
go get github.com/ZaguanLabs/[email protected]package main
import (
"context"
"fmt"
"os"
"github.com/ZaguanLabs/groq-go/groq"
"github.com/ZaguanLabs/groq-go/groq/option"
"github.com/ZaguanLabs/groq-go/groq/types"
)
func main() {
client, err := groq.NewClient(
groq.WithAPIKey(os.Getenv("GROQ_API_KEY")),
)
if err != nil {
panic(err)
}
resp, err := client.Chat.Create(context.Background(), &types.CreateChatCompletionRequest{
Model: "llama3-8b-8192",
Messages: []types.ChatCompletionMessageParam{
{
Role: types.RoleUser,
Content: "Explain quantum computing in one sentence.",
},
},
Temperature: option.Ptr(option.Some(0.7)),
})
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}package main
import (
"context"
"fmt"
"os"
"github.com/ZaguanLabs/groq-go/groq"
"github.com/ZaguanLabs/groq-go/groq/option"
"github.com/ZaguanLabs/groq-go/groq/types"
)
func main() {
client, err := groq.NewClient(
groq.WithAPIKey(os.Getenv("GROQ_API_KEY")),
)
if err != nil {
panic(err)
}
stream, err := client.Chat.CreateStream(context.Background(), &types.CreateChatCompletionRequest{
Model: "llama3-8b-8192",
Messages: []types.ChatCompletionMessageParam{
{
Role: types.RoleUser,
Content: "Tell me a story about AI",
},
},
Stream: option.Ptr(option.Some(true)),
})
if err != nil {
panic(err)
}
defer stream.Close()
// Process streaming chunks
for stream.Next() {
chunk := stream.Current()
if len(chunk.Choices) > 0 {
fmt.Print(chunk.Choices[0].Delta.Content)
}
}
if err := stream.Err(); err != nil {
panic(err)
}
}Set your Groq API key as an environment variable:
export GROQ_API_KEY=your-api-key-heregroq-go/ ├── groq/ │ ├── client.go # Main client implementation │ ├── chat.go # Chat completions API │ ├── audio.go # Audio transcription API │ ├── embeddings.go # Embeddings API │ ├── models.go # Models API │ ├── files.go # Files API │ ├── batches.go # Batches API │ ├── stream.go # Streaming support │ ├── types/ │ │ ├── chat.go # Chat types │ │ ├── audio.go # Audio types │ │ ├── embeddings.go # Embeddings types │ │ └── common.go # Common types │ └── option/ │ └── option.go # Optional[T] types ├── examples/ │ ├── basic/ # Basic usage examples │ ├── streaming/ # Streaming examples │ ├── compound-ai/ # Compound AI examples │ ├── reasoning/ # Reasoning models │ └── rag/ # RAG workflows ├── go.mod └── README.md
Core SDK functionality with chat completions, audio transcription, embeddings, and streaming support. Complete API coverage for all Groq endpoints.
Advanced features including Compound AI (multi-model orchestration with custom tools), Reasoning Models (configurable effort levels), Documents & Citations (RAG workflows), Web Search Integration, 135+ tests with 73.5% coverage, A- audit grade (91%), zero race conditions, and complete Python SDK v0.35.0 parity.
Added support for Multimodal Content Parts (Documents), synchronized with Python SDK v0.36.0, and expanded test coverage to 140+ tests.
Full API parity with official Groq Python SDK v0.37.0. New features: MCP Tool Discovery, JSON Schema Output, Enhanced Usage Stats (queue time, reasoning tokens, cached tokens), Audio Enhancements (sample rate control, URL-based transcription), Cache Statistics (DRAM/SRAM metrics). Expanded test suite to 238 tests.
Community feedback and improvements, additional API features as Groq releases them, performance optimizations, enhanced documentation and examples, continued Python SDK parity, bug fixes and stability improvements.
# Clone the repository
git clone https://github.com/ZaguanLabs/groq-go.git
cd groq-go
# Build
go build ./...
# Run tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run race detector
go test -race ./...# Set your API key
export GROQ_API_KEY=your-api-key-here
# Run basic example
go run examples/basic/main.go
# Run streaming example
go run examples/streaming/main.go
# Run compound AI example
go run examples/compound-ai/main.go
# Run reasoning example
go run examples/reasoning/main.goContributions are welcome! Whether it's bug reports, feature requests, or pull requests, we appreciate all forms of contribution.
Apache 2.0 Licensed - The Groq SDK for Go is free and open source software. You're welcome to use, modify, and distribute it for any purpose.