providers

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package providers handles LLM provider model listing and management.

Package providers handles LLM provider capabilities and model management.

Index

Constants

This section is empty.

Variables

View Source
var Registry = map[string]ProviderCapabilities{

	"openai": {
		Name:                    "OpenAI",
		BaseURL:                 "https://api.openai.com/v1",
		SupportsFunctionCalling: true,
		SupportsModelListing:    true,
		SupportsTokenTracking:   true,
		DefaultModel:            "gpt-4.1-nano",
		PreferredToolModel:      "gpt-4.1-nano",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      true,
		Notes:                   "Native function calling support. Gold standard implementation.",
	},

	"grok": {
		Name:                    "xAI Grok",
		BaseURL:                 "https://api.x.ai/v1",
		SupportsFunctionCalling: true,
		SupportsModelListing:    true,
		SupportsTokenTracking:   true,
		DefaultModel:            "grok-4-1-fast",
		PreferredToolModel:      "grok-4-1-fast",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      true,
		Notes:                   "Use grok-4-1-fast for best tool calling performance. 2M context window.",
	},

	"venice": {
		Name:                    "Venice.ai",
		BaseURL:                 "https://api.venice.ai/api/v1",
		SupportsFunctionCalling: false,
		SupportsModelListing:    true,
		SupportsTokenTracking:   true,
		DefaultModel:            "venice-uncensored",
		PreferredToolModel:      "",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      true,
		Notes:                   "NSFW mode uses Venice. No function calling in uncensored mode. Image generation available.",
	},

	"anthropic": {
		Name:                    "Anthropic Claude",
		BaseURL:                 "https://api.anthropic.com/v1",
		SupportsFunctionCalling: true,
		SupportsModelListing:    false,
		SupportsTokenTracking:   false,
		DefaultModel:            "claude-sonnet-4-5-20250929",
		PreferredToolModel:      "claude-sonnet-4-5-20250929",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      false,
		Notes:                   "Advanced tool use features. OpenAI SDK compatibility is for testing only. Native API recommended.",
	},

	"gemini": {
		Name:                    "Google Gemini AI (AI Studio)",
		BaseURL:                 "https://generativelanguage.googleapis.com/v1beta",
		SupportsFunctionCalling: true,
		SupportsModelListing:    false,
		SupportsTokenTracking:   true,
		DefaultModel:            "gemini-2.0-flash",
		PreferredToolModel:      "gemini-2.0-flash",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      false,
		Notes:                   "RECOMMENDED: Native Google GenAI SDK with automatic authentication. Simple API keys (AIza...), free tier available. Full function calling support with streaming. Get key: https://aistudio.google.com/apikey",
	},

	"vertex": {
		Name:                    "Google Vertex AI (Cloud)",
		BaseURL:                 "https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION",
		SupportsFunctionCalling: true,
		SupportsModelListing:    false,
		SupportsTokenTracking:   true,
		DefaultModel:            "gemini-2.0-flash",
		PreferredToolModel:      "gemini-2.0-flash",
		RequiresAPIKey:          false,
		IsOpenAICompatible:      false,
		Notes:                   "ENTERPRISE: Native Google GenAI SDK with automatic authentication. No manual token refresh! Use: (1) gcloud auth application-default login OR (2) Service account JSON. Tokens auto-refresh indefinitely. Requires GCP project + billing.",
	},

	"openrouter": {
		Name:                    "OpenRouter",
		BaseURL:                 "https://openrouter.ai/api/v1",
		SupportsFunctionCalling: true,
		SupportsModelListing:    true,
		SupportsTokenTracking:   true,
		DefaultModel:            "openai/gpt-4.1-nano",
		PreferredToolModel:      "openai/gpt-4.1-nano",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      true,
		Notes:                   "Aggregator for multiple providers. Full OpenAI compatibility. Parallel function calling supported.",
	},

	"digitalocean": {
		Name:                    "DigitalOcean Gradient",
		BaseURL:                 "",
		SupportsFunctionCalling: false,
		SupportsModelListing:    false,
		SupportsTokenTracking:   true,
		DefaultModel:            "gpt-4.1-nano",
		PreferredToolModel:      "",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      true,
		Notes:                   "Agent API with RAG capabilities. Token tracking supported via stream_options. Function calling requires cloud-hosted functions.",
	},

	"elevenlabs": {
		Name:                    "ElevenLabs",
		BaseURL:                 "https://api.elevenlabs.io/v1",
		SupportsFunctionCalling: false,
		SupportsModelListing:    false,
		SupportsTokenTracking:   false,
		DefaultModel:            "",
		PreferredToolModel:      "",
		RequiresAPIKey:          true,
		IsOpenAICompatible:      false,
		Notes:                   "Voice AI provider. Function calling support unknown.",
	},
}

Registry holds all supported provider configurations. Ordered by priority: Popular/Tested → OpenAI-Compatible → Untested

Functions

func DetectProvider

func DetectProvider(baseURL string) string

DetectProvider attempts to detect provider from base URL.

func FormatModelList

func FormatModelList(models []ModelInfo, highlightToolModels bool) string

FormatModelList returns a formatted string for display.

func GetToolCallingProviders

func GetToolCallingProviders() []string

GetToolCallingProviders returns only providers that support function calling.

func ListProviders

func ListProviders() []string

ListProviders returns all provider names.

Types

type ModelDetection

type ModelDetection struct {
	// contains filtered or unexported fields
}

ModelDetection provides heuristics for detecting model capabilities.

func NewModelDetection

func NewModelDetection(provider string) *ModelDetection

NewModelDetection creates a model detection helper.

func (*ModelDetection) GetDefaultToolModel

func (d *ModelDetection) GetDefaultToolModel() string

GetDefaultToolModel returns the best model for tool calling.

func (*ModelDetection) SupportsTools

func (d *ModelDetection) SupportsTools(modelID string) bool

SupportsTools determines if a model supports function calling.

type ModelInfo

type ModelInfo struct {
	ID            string
	Name          string
	SupportsTools bool
	ContextWindow int
	Description   string
	Provider      string
}

ModelInfo represents metadata about a model.

type ModelService

type ModelService struct {
	// contains filtered or unexported fields
}

ModelService handles model listing and metadata.

func NewModelService

func NewModelService(apiKey, baseURL, provider string) *ModelService

NewModelService creates a new model service for a provider.

func (*ModelService) GetBestToolModel

func (s *ModelService) GetBestToolModel() string

GetBestToolModel returns the recommended model for function calling.

func (*ModelService) ListModels

func (s *ModelService) ListModels(ctx context.Context) ([]ModelInfo, error)

ListModels fetches available models from the provider API. Returns error if provider doesn't support listing or API fails.

func (*ModelService) ValidateModel

func (s *ModelService) ValidateModel(ctx context.Context, modelID string) (ModelInfo, error)

ValidateModel checks if a model exists and returns its capabilities.

type ProviderCapabilities

type ProviderCapabilities struct {
	Name                    string
	BaseURL                 string
	SupportsFunctionCalling bool
	SupportsModelListing    bool
	SupportsTokenTracking   bool // Returns usage data with stream_options
	DefaultModel            string
	PreferredToolModel      string // Best model for function calling
	RequiresAPIKey          bool
	IsOpenAICompatible      bool
	Notes                   string
}

ProviderCapabilities defines what a provider supports.

func GetProvider

func GetProvider(name string) (ProviderCapabilities, bool)

GetProvider returns provider capabilities by name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL