model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package model provides model constants for all supported AI providers.

This package exposes typed model constants with pricing information without requiring users to import provider-specific packages. Use this package in conjunction with the client package for a complete solution.

Chat Models

Use chat models with gains.WithModel():

import (
    "github.com/spetersoncode/gains"
    "github.com/spetersoncode/gains/client"
    "github.com/spetersoncode/gains/model"
)

c, _ := client.New(ctx, client.Config{
    Provider:  client.ProviderOpenAI,
    APIKey:    os.Getenv("OPENAI_API_KEY"),
    ChatModel: model.GPT52,
})
resp, err := c.Chat(ctx, messages, gains.WithModel(model.ClaudeSonnet45))

Image Models

Use image models for generation:

c, _ := client.New(ctx, client.Config{
    Provider:   client.ProviderOpenAI,
    APIKey:     os.Getenv("OPENAI_API_KEY"),
    ImageModel: model.GPTImage1,
})

Embedding Models

Use embedding models for vector embeddings:

c, _ := client.New(ctx, client.Config{
    Provider:       client.ProviderOpenAI,
    APIKey:         os.Getenv("OPENAI_API_KEY"),
    EmbeddingModel: model.TextEmbedding3Small,
})

Pricing Information

All models include pricing methods for cost estimation:

pricing := model.GPT52.Pricing()
inputCost := float64(inputTokens) / 1_000_000 * pricing.InputPerMillion
outputCost := float64(outputTokens) / 1_000_000 * pricing.OutputPerMillion

Provider-Specific Pricing Features

Some pricing fields are provider-specific. Use helper methods to check availability:

pricing := model.GPT52.Pricing()
if pricing.HasCachedPricing() {
    // OpenAI models support cached input pricing
    cachedCost := float64(cachedTokens) / 1_000_000 * pricing.CachedInputPerMillion
}

pricing := model.Gemini3Pro.Pricing()
if pricing.HasLongContextPricing() {
    // Google models have tiered pricing for >200K token contexts
    longInputCost := float64(tokens) / 1_000_000 * pricing.InputPerMillionLong
}

Available Providers

Models are available for three providers:

  • Anthropic: Claude models (chat only)
  • OpenAI: GPT and O-series models (chat, image, embedding)
  • Google: Gemini and Imagen models (chat, image, embedding)

Index

Constants

This section is empty.

Variables

View Source
var (
	// Claude 4.5 Family (Current) - auto-updating aliases
	ClaudeOpus45   = ChatModel{/* contains filtered or unexported fields */}
	ClaudeSonnet45 = ChatModel{/* contains filtered or unexported fields */}
	ClaudeHaiku45  = ChatModel{/* contains filtered or unexported fields */}

	// Pinned versions (use for production stability)
	ClaudeOpus45_20251101   = ChatModel{/* contains filtered or unexported fields */}
	ClaudeSonnet45_20250929 = ChatModel{/* contains filtered or unexported fields */}
	ClaudeHaiku45_20251001  = ChatModel{/* contains filtered or unexported fields */}

	// DefaultClaudeModel is the recommended default Anthropic model.
	DefaultClaudeModel = ClaudeSonnet45
)

Anthropic Claude Models Model pricing last verified: December 14, 2025

View Source
var (
	// GPT-5.2 Series (Latest - December 2025)
	GPT52    = ChatModel{/* contains filtered or unexported fields */}
	GPT52Pro = ChatModel{/* contains filtered or unexported fields */}

	// GPT-5.1 Series
	GPT51      = ChatModel{/* contains filtered or unexported fields */}
	GPT51Mini  = ChatModel{/* contains filtered or unexported fields */}
	GPT51Codex = ChatModel{/* contains filtered or unexported fields */}

	// GPT-5 Series
	GPT5     = ChatModel{/* contains filtered or unexported fields */}
	GPT5Mini = ChatModel{/* contains filtered or unexported fields */}
	GPT5Nano = ChatModel{/* contains filtered or unexported fields */}
	GPT5Pro  = ChatModel{/* contains filtered or unexported fields */}

	// O-Series Reasoning Models
	O3     = ChatModel{/* contains filtered or unexported fields */}
	O3Mini = ChatModel{/* contains filtered or unexported fields */}
	O4Mini = ChatModel{/* contains filtered or unexported fields */}

	// DefaultGPTModel is the recommended default OpenAI model.
	DefaultGPTModel = GPT52
)

OpenAI GPT and O-Series Models Model pricing last verified: December 14, 2025

View Source
var (
	// Gemini 3.0 (Latest - November 2025)
	Gemini3Pro       = ChatModel{/* contains filtered or unexported fields */}
	Gemini3DeepThink = ChatModel{/* contains filtered or unexported fields */}

	// Gemini 2.5 Series
	Gemini25Pro       = ChatModel{/* contains filtered or unexported fields */}
	Gemini25Flash     = ChatModel{/* contains filtered or unexported fields */}
	Gemini25FlashLite = ChatModel{/* contains filtered or unexported fields */}

	// DefaultGeminiModel is the recommended default Google model.
	DefaultGeminiModel = Gemini25Flash
)

Google Gemini Models Model pricing last verified: December 14, 2025

View Source
var (
	// Text Embedding 3 Series
	TextEmbedding3Large = EmbeddingModel{/* contains filtered or unexported fields */}
	TextEmbedding3Small = EmbeddingModel{/* contains filtered or unexported fields */}

	// DefaultOpenAIEmbeddingModel is the recommended default OpenAI embedding model.
	DefaultOpenAIEmbeddingModel = TextEmbedding3Small
)

OpenAI Embedding Models Model pricing last verified: December 14, 2025

View Source
var (
	// Gemini Embedding
	GeminiEmbedding001 = EmbeddingModel{/* contains filtered or unexported fields */}

	// DefaultGoogleEmbeddingModel is the recommended default Google embedding model.
	DefaultGoogleEmbeddingModel = GeminiEmbedding001
)

Google Embedding Models Model pricing last verified: December 14, 2025

View Source
var (
	// GPT Image 1 Series
	GPTImage1     = ImageModel{/* contains filtered or unexported fields */}
	GPTImage1Mini = ImageModel{/* contains filtered or unexported fields */}

	// DefaultGPTImageModel is the recommended default OpenAI image model.
	DefaultGPTImageModel = GPTImage1
)

OpenAI Image Models Model pricing last verified: December 14, 2025

View Source
var (
	// Imagen 4 Series
	Imagen4      = ImageModel{/* contains filtered or unexported fields */}
	Imagen4Fast  = ImageModel{/* contains filtered or unexported fields */}
	Imagen4Ultra = ImageModel{/* contains filtered or unexported fields */}

	// DefaultImagenModel is the recommended default Google image model.
	DefaultImagenModel = Imagen4
)

Google Imagen Models Model pricing last verified: December 14, 2025

Functions

This section is empty.

Types

type ChatModel

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

ChatModel represents a chat/completion model from any provider.

func (ChatModel) Pricing

func (m ChatModel) Pricing() ChatPricing

Pricing returns the pricing for this model.

func (ChatModel) Provider

func (m ChatModel) Provider() ai.Provider

Provider returns which provider this model belongs to.

func (ChatModel) String

func (m ChatModel) String() string

String returns the API identifier for this model.

type ChatPricing

type ChatPricing struct {
	// InputPerMillion is the standard input token pricing (all providers).
	InputPerMillion float64
	// OutputPerMillion is the standard output token pricing (all providers).
	OutputPerMillion float64
	// CachedInputPerMillion is for cached/prompt-cached input tokens (OpenAI only).
	// Check HasCachedPricing() before using.
	CachedInputPerMillion float64
	// InputPerMillionLong is for long context >200K tokens (Google only).
	// Check HasLongContextPricing() before using.
	InputPerMillionLong float64
	// OutputPerMillionLong is for long context >200K tokens (Google only).
	// Check HasLongContextPricing() before using.
	OutputPerMillionLong float64
}

ChatPricing contains pricing per million tokens (USD) for chat models. Fields are zero if not applicable to a specific provider's model.

func (ChatPricing) HasCachedPricing

func (p ChatPricing) HasCachedPricing() bool

HasCachedPricing returns true if the model supports cached input pricing.

func (ChatPricing) HasLongContextPricing

func (p ChatPricing) HasLongContextPricing() bool

HasLongContextPricing returns true if the model has tiered pricing for long context.

type EmbeddingModel

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

EmbeddingModel represents an embedding model from any provider.

func (EmbeddingModel) Dimensions

func (m EmbeddingModel) Dimensions() int

Dimensions returns the output vector dimensions for this model.

func (EmbeddingModel) Pricing

func (m EmbeddingModel) Pricing() EmbeddingPricing

Pricing returns the pricing for this model.

func (EmbeddingModel) Provider

func (m EmbeddingModel) Provider() ai.Provider

Provider returns which provider this model belongs to.

func (EmbeddingModel) String

func (m EmbeddingModel) String() string

String returns the API identifier for this model.

type EmbeddingPricing

type EmbeddingPricing struct {
	// PerMillion is the price per million tokens.
	PerMillion float64
}

EmbeddingPricing contains embedding pricing per million tokens (USD).

type ImageModel

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

ImageModel represents an image generation model from any provider.

func (ImageModel) Pricing

func (m ImageModel) Pricing() ImagePricing

Pricing returns the pricing for this model.

func (ImageModel) Provider

func (m ImageModel) Provider() ai.Provider

Provider returns which provider this model belongs to.

func (ImageModel) String

func (m ImageModel) String() string

String returns the API identifier for this model.

type ImagePricing

type ImagePricing struct {
	// PerImage is a flat per-image price (Google Imagen).
	PerImage float64
	// LowQuality is the price for low quality images (OpenAI).
	LowQuality float64
	// MediumQuality is the price for medium quality images (OpenAI).
	MediumQuality float64
	// HighQuality is the price for high quality images (OpenAI).
	HighQuality float64
}

ImagePricing contains image generation pricing (USD). Different providers use different pricing models.

func (ImagePricing) HasFlatPricing

func (p ImagePricing) HasFlatPricing() bool

HasFlatPricing returns true if the model uses flat per-image pricing.

func (ImagePricing) HasQualityTiers

func (p ImagePricing) HasQualityTiers() bool

HasQualityTiers returns true if the model has quality-based pricing tiers.

Jump to

Keyboard shortcuts

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