# Providers

The Go-AI SDK supports 49 AI providers (`pkg/providers/*`), giving you access to the latest language models, embedding models, image generation, video generation, speech synthesis, and transcription services. Five providers — **LMNT**, **Ollama**, **Stability AI**, **Vercel**, and **You.com** — are Go-only additions with no upstream TypeScript AI SDK equivalent.

## Provider Categories

### Top Providers

The most popular and widely-used AI providers:

- [OpenAI](https://goaisdk.com/docs/providers/openai.md) - GPT-4, GPT-5, o1, o3 models
- [Anthropic](https://goaisdk.com/docs/providers/anthropic.md) - Claude Sonnet, Opus, Haiku
- [Google](https://goaisdk.com/docs/providers/google.md) - Gemini models
- [Azure OpenAI](https://goaisdk.com/docs/providers/azure.md) - Enterprise OpenAI deployment
- [AWS Bedrock](https://goaisdk.com/docs/providers/bedrock.md) - Multi-model AWS platform
- AWS Bedrock Anthropic (`pkg/providers/anthropicaws`, "anthropic-aws") - Claude on Bedrock, rebuilt on the shared Anthropic language model

### Popular Providers

High-performance providers with specialized capabilities:

- [Cohere](https://goaisdk.com/docs/providers/cohere.md) - Command and Embed models, reranking
- [Mistral AI](https://goaisdk.com/docs/providers/mistral.md) - Open-source language models
- [Groq](https://goaisdk.com/docs/providers/groq.md) - Ultra-fast inference
- [xAI](https://goaisdk.com/docs/providers/xai.md) - Grok models (Responses API, image, video, speech)
- [DeepSeek](https://goaisdk.com/docs/providers/deepseek.md) - Advanced reasoning models
- [Perplexity](https://goaisdk.com/docs/providers/perplexity.md) - Search-augmented Agent API

### Open Source & Serving

Platforms for running open-source models:

- [Together AI](https://goaisdk.com/docs/providers/together.md) - Open-source model hosting, reranking
- [Fireworks AI](https://goaisdk.com/docs/providers/fireworks.md) - Fast open-source inference
- [Replicate](https://goaisdk.com/docs/providers/replicate.md) - Run any open-source model
- [HuggingFace](https://goaisdk.com/docs/providers/huggingface.md) - Router Responses API for HF models
- [Ollama](https://goaisdk.com/docs/providers/ollama.md) - Local model deployment (**Go-only**)
- [Google Vertex AI](https://goaisdk.com/docs/providers/google-vertex.md) - Enterprise AI platform
- [GMI Cloud](https://goaisdk.com/docs/providers/gmicloud.md) - OpenAI-compatible chat hosting
- [Z.AI](https://goaisdk.com/docs/providers/zai.md) - OpenAI-compatible chat hosting
- [MiniMax](https://goaisdk.com/docs/providers/minimax.md) - Chat language models
- [Moonshot AI](https://goaisdk.com/docs/providers/moonshot.md) - Kimi language models
- [DeepInfra](https://goaisdk.com/docs/providers/deepinfra.md) - Serverless GPU inference
- [Baseten](https://goaisdk.com/docs/providers/baseten.md) - ML model deployment
- [Cerebras](https://goaisdk.com/docs/providers/cerebras.md) - Ultra-fast inference

### Specialized Providers

Providers for specific use cases:

- [Alibaba Cloud](https://goaisdk.com/docs/providers/alibaba.md) - Qwen language models & Wan video generation
- [KlingAI](https://goaisdk.com/docs/providers/klingai.md) - Professional video generation with motion control
- [Stability AI](https://goaisdk.com/docs/providers/stability.md) - Image generation (Stable Diffusion) (**Go-only**)
- [Black Forest Labs](https://goaisdk.com/docs/providers/bfl.md) - FLUX image and video models
- [FAL](https://goaisdk.com/docs/providers/fal.md) - Image, video, speech, and transcription
- [QuiverAI](https://goaisdk.com/docs/providers/quiverai.md) - SVG generation and image vectorization
- [Prodia](https://goaisdk.com/docs/providers/prodia.md) - Fast FLUX and Stable Diffusion image generation
- [ByteDance](https://github.com/digitallysavvy/go-ai/tree/main/pkg/providers/bytedance) - Seedance/Seedream video and image (Volcengine Ark)
- [Luma](https://goaisdk.com/docs/providers/luma.md) - Async image generation
- Replicate video, xAI video - see their provider pages

### Speech, Transcription & Audio

- [ElevenLabs](https://goaisdk.com/docs/providers/elevenlabs.md) - Speech synthesis and transcription
- [Deepgram](https://goaisdk.com/docs/providers/deepgram.md) - Speech transcription
- [AssemblyAI](https://goaisdk.com/docs/providers/assemblyai.md) - Audio intelligence
- [Cartesia](https://goaisdk.com/docs/providers/cartesia.md) - Speech and transcription
- [Fish Audio](https://goaisdk.com/docs/providers/fishaudio.md) - Speech and transcription
- [Hume](https://goaisdk.com/docs/providers/hume.md) - Speech synthesis
- [Rev.ai](https://goaisdk.com/docs/providers/revai.md) - Transcription with validated job polling
- [Gladia](https://goaisdk.com/docs/providers/gladia.md) - Transcription
- [LMNT](https://goaisdk.com/docs/providers/lmnt.md) - Speech synthesis (**Go-only**)

### Embeddings & Reranking

- [Voyage](https://goaisdk.com/docs/providers/voyage.md) - Embeddings and reranking models

### Infrastructure & Tools

- [AI Gateway](https://goaisdk.com/docs/providers/gateway.md) - Unified multi-provider routing, failover, batch, video, realtime
- [Vercel](https://goaisdk.com/docs/providers/vercel.md) - OpenAI-compatible Vercel AI API (**Go-only**)
- [OpenResponses](https://goaisdk.com/docs/providers/openresponses.md) - Open Responses API protocol (custom tools, QuiverAI's transport)
- [OpenAI-compatible providers](https://goaisdk.com/docs/providers/openai-compatible.md) - shared request/response conventions
- [TypeSafe AI](https://goaisdk.com/docs/providers/typesafeai.md) - Evaluation models for `ai.ExperimentalEvaluate`
- [You.com](https://goaisdk.com/docs/providers/youcom-tools.md) - Search, research, and contents tools (not a model provider) (**Go-only**)

## Quick Start

### 1. Install the SDK

```go
go get github.com/digitallysavvy/go-ai
```

### 2. Choose a Provider

```go
import (
    "github.com/digitallysavvy/go-ai/pkg/ai"
    "github.com/digitallysavvy/go-ai/pkg/providers/openai"
)

provider := openai.New(openai.Config{
    APIKey: os.Getenv("OPENAI_API_KEY"),
})

model, err := provider.LanguageModel("gpt-4")
```

### 3. Generate Text

```go
result, err := ai.GenerateText(ctx, ai.GenerateTextOptions{Model: model, Prompt: "What is the Go-AI SDK?"})
if err != nil {
    log.Fatal(err)
}
fmt.Println(result.Text)
```

## Provider Comparison

### Language Models

| Provider | Best Models | Context Length | Streaming | Tools | Reasoning |
|----------|-------------|----------------|-----------|-------|-----------|
| OpenAI | GPT-4o, o1, o3 | 128K+ | Yes | Yes | Yes (o1/o3) |
| Anthropic | Claude Opus 4.5 | 200K | Yes | Yes | Yes |
| Google | Gemini 2.0 Flash | 1M+ | Yes | Yes | Yes |
| Alibaba | Qwen Max, QwQ | 32K | Yes | Yes | Yes (QwQ) |
| Groq | Llama 3.3 | 8K-128K | Yes | Yes | No |
| DeepSeek | DeepSeek-V3 | 64K | Yes | Yes | Yes |

### Image & Video Generation

| Provider | Best Models | Speed | Quality | Features |
|----------|-------------|-------|---------|----------|
| Alibaba Cloud | Wan 2.6 | Medium | High | Text/Image/Reference-to-video |
| Stability AI | SDXL, SD3 | Fast | High | Flexible |
| Black Forest Labs | FLUX.1 Pro | Medium | Excellent | Photorealistic |
| FAL | FLUX, SD | Very Fast | High | Video support |
| Prodia | FLUX, SD | Very Fast | High | Image + video |

### Speech & Audio

| Provider | Capability | Quality | Speed | Features |
|----------|-----------|---------|-------|----------|
| ElevenLabs | TTS | Excellent | Fast | Voice cloning |
| Deepgram | STT | Excellent | Real-time | Diarization |
| AssemblyAI | STT | Excellent | Fast | Summarization |

## Provider Selection Guide

### For Production Applications

**Best Overall**: OpenAI, Anthropic, Google
- Enterprise-grade reliability
- Excellent documentation
- Strong safety measures

### For Cost-Effective Solutions

**Best Value**: Groq, Together AI, DeepInfra
- Lower pricing
- Good performance
- Open-source model access

### For Specialized Tasks

**Video Generation**: KlingAI, Alibaba Cloud (Wan), FAL
**Image Generation**: Stability AI, Black Forest Labs, FAL, Prodia, QuiverAI
**Speech Synthesis**: ElevenLabs
**Transcription**: Deepgram, AssemblyAI
**Fast Inference**: Groq, Cerebras
**Local Deployment**: Ollama
**Chinese Language**: Alibaba Cloud (Qwen)

### For Enterprise

**Best Choice**: Azure OpenAI, AWS Bedrock, Google Vertex AI
- Private deployment options
- Compliance features
- SLA guarantees

## Configuration Patterns

### Environment Variables

```go
provider := openai.New(openai.Config{
    APIKey: os.Getenv("OPENAI_API_KEY"),
})
```

### Custom Base URL

```go
provider := openai.New(openai.Config{
    APIKey: os.Getenv("API_KEY"),
    BaseURL: "https://custom-endpoint.com/v1",
})
```

### Regional Configuration

```go
provider, err := azure.New(azure.Config{
    ResourceName:           os.Getenv("AZURE_RESOURCE_NAME"),
    APIKey:                 os.Getenv("AZURE_API_KEY"),
    UseDeploymentBasedURLs: true,
})
if err != nil {
    log.Fatal(err)
}
```

## Common Features

### Streaming

All major providers support streaming responses:

```go
stream, err := ai.StreamText(ctx, ai.StreamTextOptions{Model: model, Prompt: "Write a story"})
for chunk := range stream.Chunks() {
    fmt.Print(chunk.Text)
}
```

### Tool Calling

Most providers support function calling:

```go
result, err := ai.GenerateText(ctx, ai.GenerateTextOptions{
    Model:  model,
    Prompt: "What's the weather?",
    Tools:  []types.Tool{weatherTool},
    StopWhen: []ai.StopCondition{ai.IsStepCount(5)},
})
```

### Structured Output

Generate JSON conforming to a schema:

```go
personSchema := schema.NewSimpleJSONSchema(map[string]interface{}{
    "type": "object",
    "properties": map[string]interface{}{
        "name": map[string]string{"type": "string"},
        "age":  map[string]string{"type": "number"},
    },
    "required": []string{"name", "age"},
})

result, err := ai.GenerateObject(ctx, ai.GenerateObjectOptions{
    Model:  model,
    Schema: personSchema,
    Prompt: "Describe a person",
})
```

## Error Handling

### Rate Limits

```go
result, err := ai.GenerateText(ctx, ai.GenerateTextOptions{
    Model:  model,
    Prompt: prompt,
})
if err != nil {
    var providerErr *providererrors.ProviderError
    if errors.As(err, &providerErr) && providerErr.StatusCode == 429 {
        time.Sleep(time.Second * 5)
        // Retry
    }
}
```

### Provider-Specific Errors

Each provider has unique error codes and handling - see individual provider documentation.

## Best Practices

1. **Use Environment Variables**: Never hardcode API keys
2. **Handle Rate Limits**: Implement exponential backoff
3. **Monitor Costs**: Track token usage across providers
4. **Test Locally**: Use Ollama for development
5. **Fallback Providers**: Have backup providers configured
6. **Validate Models**: Check model availability before deployment

## Next Steps

- Explore the [Overview Guide](https://goaisdk.com/docs/providers/overview.md) for detailed provider concepts
- Read individual provider documentation for specific features
- Check [API Reference](https://goaisdk.com/docs/reference/ai/generate-text.md) for complete API details
- Review [Examples](https://github.com/digitallysavvy/go-ai/tree/main/examples) for implementation patterns

## See Also

- [Quick Start Guide](https://goaisdk.com/docs/getting-started.md)
- [Core Concepts](https://goaisdk.com/docs/foundations.md)
- [API Reference](https://goaisdk.com/docs/reference.md)
