Production Readyv0.2.0SDK • Go

Zaguán SDK for Go

Official Go SDK for Zaguán CoreX - The enterprise AI gateway that unifies access to 15+ AI providers through a single, elegant API. With Zaguán, you can seamlessly switch between OpenAI, Anthropic, Google, DeepSeek, Groq, Perplexity, xAI, and more without changing your code.

✅ Production Ready (v0.2.0): Major quality improvements with 63% test coverage (221 tests), zero security vulnerabilities, zero code quality issues, comprehensive input validation, and race-free concurrent code. Quality Grade: A-

Why Zaguán?

One API, Every AI Provider - Stop managing multiple SDKs and API keys. Zaguán provides a unified interface to all major AI providers.

Zaguán CoreX eliminates vendor lock-in and optimizes costs while unlocking advanced capabilities:

  • Multi-Provider Abstraction: Access OpenAI, Anthropic, Google, Alibaba, DeepSeek, Groq, Perplexity, xAI, Mistral, Cohere, and more through one API
  • Cost Optimization: Reduce costs through intelligent provider routing and flexible credit-based billing
  • Advanced Features: Reasoning control, multimodal AI, real-time data, long context windows
  • Enterprise Scale: Supports 5,000+ concurrent connections with multi-tier access control
  • Zero Vendor Lock-in: Switch providers by changing model name only

Key Features

OpenAI-Compatible

Drop-in replacement for the OpenAI SDK with familiar interfaces and minimal code changes.

Anthropic Native

First-class support for Claude's Messages API with extended thinking and prompt caching.

Multi-Provider

Access 15+ providers: OpenAI, Anthropic, Google, DeepSeek, Groq, Perplexity, xAI, and more.

Type-Safe

Full type safety with comprehensive Go structs and compile-time checks.

Streaming

Efficient SSE streaming for real-time responses with idiomatic Go channels.

Credits Tracking

Built-in usage monitoring and billing insights with credit-based billing.

Provider Extensions

Native support for reasoning tokens, prompt caching, and provider-specific features.

Context-Aware

Idiomatic use of context.Context for cancellation and timeouts.

Production-Ready

Structured errors, logging interface, request IDs, and observability built-in.

Quality Metrics (v0.2.0)

63% Test Coverage

221 comprehensive tests covering all major functionality with mock servers and edge cases.

Zero Security Issues

All 7 gosec security warnings fixed. Production-ready security posture.

Zero Code Quality Issues

All 3 staticcheck warnings resolved. Clean, maintainable codebase.

Race-Free Concurrent Code

Verified with Go's race detector. Safe for production concurrent workloads.

Development Status

✅ Completed (v0.2.0 - Production Ready)

  • Complete type definitions for all major APIs
  • HTTP request/response handling with comprehensive validation
  • Chat completions implementation (OpenAI & Anthropic)
  • Streaming support (SSE) with idiomatic Go channels
  • 221 unit tests with mock servers (63% coverage)
  • Zero security vulnerabilities (gosec verified)
  • Zero code quality issues (staticcheck verified)
  • Race-free concurrent code (race detector verified)
  • Structured error types with specialized handling
  • Request options with per-request overrides
  • Logger interface for observability
  • Comprehensive documentation and examples

📋 Planned (Future Releases)

  • Models and capabilities endpoints
  • Credits tracking and history
  • Extended OpenAI features (embeddings, audio, images)
  • Increased test coverage (80%+ target)
  • Additional provider-specific features

Quick Start

Installation

go get github.com/ZaguanLabs/zaguan-sdk-go/sdk

Basic Usage

package main

import (
    "context"
    "fmt"
    "log"
    
    zaguansdk "github.com/ZaguanLabs/zaguan-sdk-go/sdk"
)

func main() {
    // Create a client
    client := zaguansdk.NewClient(zaguansdk.Config{
        BaseURL: "https://api.zaguanai.com",
        APIKey:  "your-api-key",
    })
    
    // Chat completion (OpenAI style)
    resp, err := client.Chat(context.Background(), zaguansdk.ChatRequest{
        Model: "openai/gpt-4o",
        Messages: []zaguansdk.Message{
            {Role: "user", Content: "Hello, world!"},
        },
    }, nil)
    
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Println(resp.Choices[0].Message.Content)
}

Streaming

// Streaming chat completion
stream, err := client.ChatStream(context.Background(), zaguansdk.ChatRequest{
    Model: "openai/gpt-4o",
    Messages: []zaguansdk.Message{
        {Role: "user", Content: "Tell me a story"},
    },
}, nil)

if err != nil {
    log.Fatal(err)
}
defer stream.Close()

// Process streaming chunks
for {
    chunk, err := stream.Recv()
    if err == io.EOF {
        break
    }
    if err != nil {
        log.Fatal(err)
    }
    fmt.Print(chunk.Choices[0].Delta.Content)
}

Multi-Provider Access

Access any of the 15+ supported AI providers with a simple model name change:

// OpenAI
openaiResp, _ := client.Chat(ctx, zaguansdk.ChatRequest{
    Model: "openai/gpt-4o",
    Messages: []zaguansdk.Message{{Role: "user", Content: "Hello!"}},
}, nil)

// Anthropic
anthropicResp, _ := client.Chat(ctx, zaguansdk.ChatRequest{
    Model: "anthropic/claude-3-5-sonnet",
    Messages: []zaguansdk.Message{{Role: "user", Content: "Hello!"}},
}, nil)

// Google Gemini
googleResp, _ := client.Chat(ctx, zaguansdk.ChatRequest{
    Model: "google/gemini-2.0-flash",
    Messages: []zaguansdk.Message{{Role: "user", Content: "Hello!"}},
}, nil)

Supported Providers

Zaguán CoreX supports 18+ AI providers with 500+ models:

Alibaba
Anthropic
Cohere
Deepseek
Fireworks
Google
Groq
Inception
Mistral
Moonshot
Novita
OpenAI
OpenRouter
Perplexity
Synthetic
Together
xAI
ZaguanAI

Contributing

Contributions are welcome! Whether it's bug reports, feature requests, or pull requests, we appreciate all forms of contribution.

Apache 2.0 Licensed - The Zaguán SDK for Go is free and open source software. You're welcome to use, modify, and distribute it for any purpose.

Get Started Today

Production-ready v0.2.0 is available now. Star the repository on GitHub to follow updates and new features.