Skip to main content

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 - GPT-4, GPT-5, o1, o3 models
  • Anthropic - Claude Sonnet, Opus, Haiku
  • Google - Gemini models
  • Azure OpenAI - Enterprise OpenAI deployment
  • AWS Bedrock - Multi-model AWS platform
  • AWS Bedrock Anthropic (pkg/providers/anthropicaws, "anthropic-aws") - Claude on Bedrock, rebuilt on the shared Anthropic language model

High-performance providers with specialized capabilities:

  • Cohere - Command and Embed models, reranking
  • Mistral AI - Open-source language models
  • Groq - Ultra-fast inference
  • xAI - Grok models (Responses API, image, video, speech)
  • DeepSeek - Advanced reasoning models
  • Perplexity - Search-augmented Agent API

Open Source & Serving​

Platforms for running open-source models:

Specialized Providers​

Providers for specific use cases:

  • Alibaba Cloud - Qwen language models & Wan video generation
  • KlingAI - Professional video generation with motion control
  • Stability AI - Image generation (Stable Diffusion) (Go-only)
  • Black Forest Labs - FLUX image and video models
  • FAL - Image, video, speech, and transcription
  • QuiverAI - SVG generation and image vectorization
  • Prodia - Fast FLUX and Stable Diffusion image generation
  • ByteDance - Seedance/Seedream video and image (Volcengine Ark)
  • Luma - Async image generation
  • Replicate video, xAI video - see their provider pages

Speech, Transcription & Audio​

Embeddings & Reranking​

  • Voyage - Embeddings and reranking models

Infrastructure & Tools​

  • AI Gateway - Unified multi-provider routing, failover, batch, video, realtime
  • Vercel - OpenAI-compatible Vercel AI API (Go-only)
  • OpenResponses - Open Responses API protocol (custom tools, QuiverAI's transport)
  • OpenAI-compatible providers - shared request/response conventions
  • TypeSafe AI - Evaluation models for ai.ExperimentalEvaluate
  • You.com - Search, research, and contents tools (not a model provider) (Go-only)

Quick Start​

1. Install the SDK​

go get github.com/digitallysavvy/go-ai

2. Choose a Provider​

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​

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​

ProviderBest ModelsContext LengthStreamingToolsReasoning
OpenAIGPT-4o, o1, o3128K+YesYesYes (o1/o3)
AnthropicClaude Opus 4.5200KYesYesYes
GoogleGemini 2.0 Flash1M+YesYesYes
AlibabaQwen Max, QwQ32KYesYesYes (QwQ)
GroqLlama 3.38K-128KYesYesNo
DeepSeekDeepSeek-V364KYesYesYes

Image & Video Generation​

ProviderBest ModelsSpeedQualityFeatures
Alibaba CloudWan 2.6MediumHighText/Image/Reference-to-video
Stability AISDXL, SD3FastHighFlexible
Black Forest LabsFLUX.1 ProMediumExcellentPhotorealistic
FALFLUX, SDVery FastHighVideo support
ProdiaFLUX, SDVery FastHighImage + video

Speech & Audio​

ProviderCapabilityQualitySpeedFeatures
ElevenLabsTTSExcellentFastVoice cloning
DeepgramSTTExcellentReal-timeDiarization
AssemblyAISTTExcellentFastSummarization

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​

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

Custom Base URL​

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

Regional Configuration​

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:

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:

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:

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​

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 for detailed provider concepts
  • Read individual provider documentation for specific features
  • Check API Reference for complete API details
  • Review Examples for implementation patterns

See Also​