gillmprovider

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudflareWorkersAIBaseURL          = "https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1"
	CloudflareAIGatewayCompatBaseURL    = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat"
	CloudflareAIGatewayOpenAIBaseURL    = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai"
	CloudflareAIGatewayAnthropicBaseURL = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic"
)
View Source
const (
	ImagesStopReasonStop    = "stop"
	ImagesStopReasonError   = "error"
	ImagesStopReasonAborted = "aborted"
)
View Source
const (
	NonVisionUserImagePlaceholder = "(image omitted: model does not support images)"
	NonVisionToolImagePlaceholder = "(tool image omitted: model does not support images)"
)
View Source
const (
	AnthropicOAuthTokenURL = "https://platform.claude.com/v1/oauth/token"
	AnthropicOAuthClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e"
)
View Source
const (
	RoleUser       = "user"
	RoleAssistant  = "assistant"
	RoleToolResult = "toolResult"

	ContentText     = "text"
	ContentThinking = "thinking"
	ContentImage    = "image"
	ContentToolCall = "toolCall"

	StopReasonStop    = "stop"
	StopReasonLength  = "length"
	StopReasonError   = "error"
	StopReasonAborted = "aborted"
)
View Source
const BuiltInAPIProviderSourceID = "builtin"
View Source
const DefaultAzureOpenAIAPIVersion = "v1"
View Source
const GCPVertexCredentialsMarker = "gcp-vertex-credentials"
View Source
const StopReasonToolUse = "toolUse"
View Source
const UnsupportedProxyProtocolMessage = httpproxy.UnsupportedProxyProtocolMessage

Variables

This section is empty.

Functions

func AppendAssistantMessageDiagnostic

func AppendAssistantMessageDiagnostic(message *Message, diagnostic AssistantMessageDiagnostic)

func ApplyOpenAIAnthropicCacheControl

func ApplyOpenAIAnthropicCacheControl(messages []OpenAIChatMessage, tools []OpenAIChatTool, cacheControl *OpenAICompatCacheControl)

func ApplyOpenAICodexServiceTierPricing

func ApplyOpenAICodexServiceTierPricing(usage *Usage, serviceTier string, model Model)

func ApplyOpenAIResponsesServiceTierPricing

func ApplyOpenAIResponsesServiceTierPricing(usage *Usage, serviceTier string, model Model)

func BuildAnthropicHeaders

func BuildAnthropicHeaders(model Model, context Context, options AnthropicPayloadOptions) map[string]string

func BuildAnthropicRequestHeaders

func BuildAnthropicRequestHeaders(model Model, context Context, options AnthropicPayloadOptions) map[string]string

func BuildBedrockAdditionalModelRequestFields

func BuildBedrockAdditionalModelRequestFields(model Model, options BedrockPayloadOptions) map[string]any

func BuildCopilotDynamicHeaders

func BuildCopilotDynamicHeaders(messages []Message) map[string]string

func BuildDefaultAzureOpenAIBaseURL

func BuildDefaultAzureOpenAIBaseURL(resourceName string) string

func BuildOpenAICodexSSEHeaders

func BuildOpenAICodexSSEHeaders(modelHeaders, optionHeaders map[string]string, token, sessionID string) (map[string]string, error)

func BuildOpenAICodexWebSocketHeaders

func BuildOpenAICodexWebSocketHeaders(modelHeaders, optionHeaders map[string]string, token, requestID string) (map[string]string, error)

func BuildOpenAICompletionsHeaders

func BuildOpenAICompletionsHeaders(model Model, options OpenAICompletionsPayloadOptions) map[string]string

func BuildOpenAIResponsesHeaders

func BuildOpenAIResponsesHeaders(model Model, options OpenAIResponsesPayloadOptions) map[string]string

func ClampThinkingLevel

func ClampThinkingLevel(model Model, level string) string

func CleanupSessionResources

func CleanupSessionResources(sessionID string) error

func ClearAPIProviders

func ClearAPIProviders()

func CloseOpenAICodexWebSocketSessions

func CloseOpenAICodexWebSocketSessions(sessionIDs ...string)

func ExtractOpenAICodexAccountID

func ExtractOpenAICodexAccountID(token string) (string, error)

func FindEnvKeys

func FindEnvKeys(provider string) []string

func FormatThrownValue

func FormatThrownValue(value any) string

func FromClaudeCodeToolName

func FromClaudeCodeToolName(name string, tools []Tool) string

func GetConfiguredBedrockRegion

func GetConfiguredBedrockRegion(options BedrockClientOptions) string

func GetEnvAPIKey

func GetEnvAPIKey(provider string) string

func GetImageProviders

func GetImageProviders() []string

func GetOverflowPatterns

func GetOverflowPatterns() []*regexp.Regexp

func GetProviders

func GetProviders() []string

func GetSupportedThinkingLevels

func GetSupportedThinkingLevels(model Model) []string

func GitHubCopilotBaseURL

func GitHubCopilotBaseURL(token, enterpriseDomain string) string

func GitHubCopilotPollSchedule

func GitHubCopilotPollSchedule(startMillis int64, intervalSeconds, expiresSeconds int, responses []GitHubCopilotDevicePollResponse) ([]int64, error)

func GoogleThinkingBudget

func GoogleThinkingBudget(model Model, effort string, custom map[string]int) int

func GoogleThinkingLevel

func GoogleThinkingLevel(effort string, model Model) string

func GoogleVertexBaseURLIncludesAPIVersion

func GoogleVertexBaseURLIncludesAPIVersion(baseURL string) bool

func HasConfiguredBedrockProfile

func HasConfiguredBedrockProfile(options BedrockClientOptions) bool

func HasCopilotVisionInput

func HasCopilotVisionInput(messages []Message) bool

func InferCopilotInitiator

func InferCopilotInitiator(messages []Message) string

func IsAnthropicClaudeBedrockModel

func IsAnthropicClaudeBedrockModel(model Model) bool

func IsCloudflareProvider

func IsCloudflareProvider(provider string) bool

func IsContextOverflow

func IsContextOverflow(message Message, contextWindow int) bool

func IsGoogleThinkingPart

func IsGoogleThinkingPart(part GooglePart) bool

func IsGovCloudBedrockTarget

func IsGovCloudBedrockTarget(model Model, options BedrockPayloadOptions) bool

func IsMalformedJSONError

func IsMalformedJSONError(err error) bool

func IsOpenAICodexRetryable

func IsOpenAICodexRetryable(status int, body string) bool

func IsPlaceholderAPIKey

func IsPlaceholderAPIKey(apiKey string) bool

func IsSessionResourceCleanupError

func IsSessionResourceCleanupError(err error) bool

func MapAnthropicThinkingEffort

func MapAnthropicThinkingEffort(model Model, level string) string

func MapBedrockThinkingEffort

func MapBedrockThinkingEffort(model Model, level string) string

func MapGoogleFinishReason

func MapGoogleFinishReason(reason string) string

func MapMistralReasoningEffort

func MapMistralReasoningEffort(model Model, level string) string

func MapOpenAIChatFinishReason

func MapOpenAIChatFinishReason(reason string) (string, string)

func ModelsAreEqual

func ModelsAreEqual(a, b *Model) bool

func NormalizeAzureOpenAIBaseURL

func NormalizeAzureOpenAIBaseURL(baseURL string) (string, error)

func NormalizeToolCallIDForAnthropic

func NormalizeToolCallIDForAnthropic(id string) string

func NormalizeToolCallIDForOpenAICompletions

func NormalizeToolCallIDForOpenAICompletions(id string, model Model) string

func NormalizeToolCallIDForOpenAIResponses

func NormalizeToolCallIDForOpenAIResponses(id string, target Model, source Message, allowedToolCallProviders map[string]bool) string

func NowMillis

func NowMillis() int64

func OAuthErrorHTML

func OAuthErrorHTML(message, details string) string

func OAuthPageHTML

func OAuthPageHTML(options OAuthPageOptions) string

func OAuthSuccessHTML

func OAuthSuccessHTML(message string) string

func OpenAICodexRefreshError

func OpenAICodexRefreshError(status int, statusText, body string) error

func OpenAICodexRetryDelay

func OpenAICodexRetryDelay(status int, headers map[string]string, attempt int, now time.Time) time.Duration

func OpenAICodexServiceTierCostMultiplier

func OpenAICodexServiceTierCostMultiplier(model Model, serviceTier string) float64

func OpenAIResponsesServiceTierCostMultiplier

func OpenAIResponsesServiceTierCostMultiplier(model Model, serviceTier string) float64

func RegisterAPIProvider

func RegisterAPIProvider(api string, provider APIProvider)

func RegisterAPIProviderWithSource

func RegisterAPIProviderWithSource(api string, provider APIProvider, sourceID string)

func RegisterBuiltInAPIProvider

func RegisterBuiltInAPIProvider(api string, provider APIProvider)

func RegisterBuiltInAPIProviders

func RegisterBuiltInAPIProviders()

func RegisterImageModel

func RegisterImageModel(model ImagesModel)

func RegisterImagesAPIProvider

func RegisterImagesAPIProvider(api string, provider ImagesAPIProvider)

func RegisterModel

func RegisterModel(model Model)

func RegisterSessionResourceCleanup

func RegisterSessionResourceCleanup(cleanup SessionResourceCleanup) func()

func RepairJSON

func RepairJSON(data string) string

func RequiresGoogleToolCallID

func RequiresGoogleToolCallID(modelID string) bool

func ResetAPIProviders

func ResetAPIProviders()

func ResetOpenAICodexWebSocketDebugStats

func ResetOpenAICodexWebSocketDebugStats(sessionIDs ...string)

func ResolveAzureDeploymentName

func ResolveAzureDeploymentName(model Model, explicit string) string

func ResolveCloudflareBaseURL

func ResolveCloudflareBaseURL(model Model) (string, error)

func ResolveGoogleVertexAPIKey

func ResolveGoogleVertexAPIKey(options GoogleVertexOptions) string

func ResolveGoogleVertexCustomBaseURL

func ResolveGoogleVertexCustomBaseURL(baseURL string) string

func ResolveHTTPProxyURLForTarget

func ResolveHTTPProxyURLForTarget(targetURL string) (*url.URL, error)

func ResolveOpenAICodexServiceTier

func ResolveOpenAICodexServiceTier(responseServiceTier, requestServiceTier string) string

func ResolveOpenAICodexURL

func ResolveOpenAICodexURL(baseURL string) string

func ResolveOpenAICodexWebSocketURL

func ResolveOpenAICodexWebSocketURL(baseURL string) string

func RetainGoogleThoughtSignature

func RetainGoogleThoughtSignature(existing, incoming string) string

func SanitizeSchemaForOpenAPI

func SanitizeSchemaForOpenAPI(schema any) any

func SanitizeSurrogates

func SanitizeSurrogates(text string) string

func SchemaToMap

func SchemaToMap(schema Schema) map[string]any

func ShouldSendOpenAICompletionsTools

func ShouldSendOpenAICompletionsTools(context Context) bool

func ShouldUseExplicitBedrockEndpoint

func ShouldUseExplicitBedrockEndpoint(baseURL, configuredRegion string, hasConfiguredProfile bool) bool

func StandardBedrockEndpointRegion

func StandardBedrockEndpointRegion(baseURL string) string

func SupportsAnthropicAdaptiveThinking

func SupportsAnthropicAdaptiveThinking(model Model) bool

func SupportsBedrockAdaptiveThinking

func SupportsBedrockAdaptiveThinking(model Model) bool

func SupportsBedrockPromptCaching

func SupportsBedrockPromptCaching(model Model, force bool) bool

func SupportsGoogleMultimodalFunctionResponse

func SupportsGoogleMultimodalFunctionResponse(modelID string) bool

func ToClaudeCodeToolName

func ToClaudeCodeToolName(name string) string

func UUIDLikeID

func UUIDLikeID() string

func UnmarshalJSONWithRepair

func UnmarshalJSONWithRepair(data []byte, target any) error

func UnregisterAPIProvider

func UnregisterAPIProvider(api string)

func UnregisterAPIProviders

func UnregisterAPIProviders(sourceID string)

func UnregisterImagesAPIProvider

func UnregisterImagesAPIProvider(api string)

func UsesMistralReasoningEffort

func UsesMistralReasoningEffort(model Model) bool

func ValidateOpenRouterImagesPayload

func ValidateOpenRouterImagesPayload(payload OpenRouterImagesPayload) error

func ValidateThinkingLevelSupported

func ValidateThinkingLevelSupported(model Model, level string) error

func ValidateToolArguments

func ValidateToolArguments(tool Tool, toolCall ContentPart) (map[string]any, error)

func ValidateToolCall

func ValidateToolCall(tools []Tool, toolCall ContentPart) (map[string]any, error)

Types

type APIProvider

type APIProvider interface {
	Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
	StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
}

func GetAPIProvider

func GetAPIProvider(api string) APIProvider

type APIProviderFuncs

type APIProviderFuncs struct {
	StreamFunc       func(Model, Context, StreamOptions) (*AssistantMessageEventStream, error)
	StreamSimpleFunc func(Model, Context, SimpleStreamOptions) (*AssistantMessageEventStream, error)
}

func (APIProviderFuncs) Stream

func (p APIProviderFuncs) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func (APIProviderFuncs) StreamSimple

func (p APIProviderFuncs) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type APIProviderRegistration

type APIProviderRegistration struct {
	API      string
	Provider APIProvider
	SourceID string
}

func GetAPIProviders

func GetAPIProviders() []APIProviderRegistration

type AbortUsageExpectation

type AbortUsageExpectation string
const (
	AbortUsageFinalOnly   AbortUsageExpectation = "final-only"
	AbortUsageInputOnly   AbortUsageExpectation = "input-only"
	AbortUsageIncremental AbortUsageExpectation = "incremental"
)

func ExpectedAbortUsage

func ExpectedAbortUsage(model Model) AbortUsageExpectation

type AnthropicCompat

type AnthropicCompat struct {
	SupportsEagerToolInputStreaming bool
	SupportsCacheControlOnTools     bool
	SupportsLongCacheRetention      bool
	SendSessionAffinityHeaders      bool
}

func ResolveAnthropicCompat

func ResolveAnthropicCompat(model Model) AnthropicCompat

type AnthropicContentBlock

type AnthropicContentBlock struct {
	Type         string                    `json:"type"`
	Text         string                    `json:"text,omitempty"`
	Source       *AnthropicImageSource     `json:"source,omitempty"`
	ID           string                    `json:"id,omitempty"`
	Name         string                    `json:"name,omitempty"`
	Input        map[string]any            `json:"input,omitempty"`
	ToolUseID    string                    `json:"tool_use_id,omitempty"`
	Content      any                       `json:"content,omitempty"`
	IsError      bool                      `json:"is_error,omitempty"`
	Thinking     string                    `json:"thinking,omitempty"`
	Signature    string                    `json:"signature,omitempty"`
	Data         string                    `json:"data,omitempty"`
	CacheControl *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}

type AnthropicImageSource

type AnthropicImageSource struct {
	Type      string `json:"type"`
	MediaType string `json:"media_type"`
	Data      string `json:"data"`
}

type AnthropicMessage

type AnthropicMessage struct {
	Role    string `json:"role"`
	Content any    `json:"content"`
}

func ConvertAnthropicMessages

func ConvertAnthropicMessages(model Model, context Context, isOAuthToken bool, cacheControl *OpenAICompatCacheControl) []AnthropicMessage

type AnthropicMessagesProvider

type AnthropicMessagesProvider struct {
	Client HTTPDoer
}

func NewAnthropicMessagesProvider

func NewAnthropicMessagesProvider(client HTTPDoer) AnthropicMessagesProvider

func (AnthropicMessagesProvider) Stream

func (p AnthropicMessagesProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func (AnthropicMessagesProvider) StreamSimple

func (p AnthropicMessagesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type AnthropicPayload

type AnthropicPayload struct {
	Model        string                  `json:"model"`
	Messages     []AnthropicMessage      `json:"messages"`
	System       []AnthropicContentBlock `json:"system,omitempty"`
	MaxTokens    int                     `json:"max_tokens"`
	Stream       bool                    `json:"stream"`
	Temperature  *float64                `json:"temperature,omitempty"`
	Tools        []AnthropicTool         `json:"tools,omitempty"`
	Thinking     map[string]any          `json:"thinking,omitempty"`
	OutputConfig map[string]any          `json:"output_config,omitempty"`
	Metadata     map[string]any          `json:"metadata,omitempty"`
}

func BuildAnthropicPayload

func BuildAnthropicPayload(model Model, context Context, options AnthropicPayloadOptions) AnthropicPayload

type AnthropicPayloadOptions

type AnthropicPayloadOptions struct {
	MaxTokens        int
	Temperature      *float64
	CacheRetention   string
	SessionID        string
	Reasoning        string
	ThinkingBudgets  map[string]int
	ThinkingDisplay  string
	Metadata         map[string]any
	Headers          map[string]string
	IsOAuthToken     bool
	InterleavedThink *bool
}

type AnthropicRawUsage

type AnthropicRawUsage struct {
	InputTokens              int `json:"input_tokens"`
	OutputTokens             int `json:"output_tokens"`
	CacheReadInputTokens     int `json:"cache_read_input_tokens"`
	CacheCreationInputTokens int `json:"cache_creation_input_tokens"`
}

type AnthropicSSEEvent

type AnthropicSSEEvent struct {
	Event string
	Data  string
}

type AnthropicTool

type AnthropicTool struct {
	Name                string                    `json:"name"`
	Description         string                    `json:"description,omitempty"`
	EagerInputStreaming *bool                     `json:"eager_input_streaming,omitempty"`
	InputSchema         map[string]any            `json:"input_schema"`
	CacheControl        *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}

func ConvertAnthropicTools

func ConvertAnthropicTools(tools []Tool, isOAuthToken bool, supportsEagerToolInputStreaming bool, cacheControl *OpenAICompatCacheControl) []AnthropicTool

type AssistantImages

type AssistantImages struct {
	API          string
	Provider     string
	Model        string
	Output       []ImagesContent
	ResponseID   string
	Usage        Usage
	StopReason   string
	ErrorMessage string
	Timestamp    int64
}

func AbortedImages

func AbortedImages(model ImagesModel, err error) AssistantImages

func ErrorImages

func ErrorImages(model ImagesModel, err error) AssistantImages

func GenerateImages

func GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)

func ParseOpenRouterImagesResponse

func ParseOpenRouterImagesResponse(model ImagesModel, response OpenRouterImagesResponse) AssistantImages

type AssistantMessageDiagnostic

type AssistantMessageDiagnostic struct {
	Type      string               `json:"type"`
	Timestamp int64                `json:"timestamp"`
	Error     *DiagnosticErrorInfo `json:"error,omitempty"`
	Details   map[string]any       `json:"details,omitempty"`
}

func NewAssistantMessageDiagnostic

func NewAssistantMessageDiagnostic(diagnosticType string, err error, details map[string]any) AssistantMessageDiagnostic

type AssistantMessageEvent

type AssistantMessageEvent struct {
	Type         string      `json:"type"`
	Partial      Message     `json:"partial,omitempty"`
	Message      Message     `json:"message,omitempty"`
	Error        Message     `json:"error,omitempty"`
	Reason       string      `json:"reason,omitempty"`
	ContentIndex int         `json:"contentIndex,omitempty"`
	Delta        string      `json:"delta,omitempty"`
	Content      string      `json:"content,omitempty"`
	ToolCall     ContentPart `json:"toolCall,omitempty"`
}

func ProcessBedrockConverseStreamEvents

func ProcessBedrockConverseStreamEvents(model Model, output *Message, events []BedrockConverseStreamEvent) []AssistantMessageEvent

func ProcessOpenAICodexStreamEvents

func ProcessOpenAICodexStreamEvents(model Model, output *Message, events []OpenAIResponsesStreamEvent, options OpenAICodexProcessOptions) []AssistantMessageEvent

func ProcessOpenAIResponsesStreamEvents

func ProcessOpenAIResponsesStreamEvents(model Model, output *Message, events []OpenAIResponsesStreamEvent) []AssistantMessageEvent

type AssistantMessageEventStream

type AssistantMessageEventStream = EventStream[AssistantMessageEvent, Message]

func CompletedAssistantStream

func CompletedAssistantStream(message Message) *AssistantMessageEventStream

func ErrorAssistantStream

func ErrorAssistantStream(message Message) *AssistantMessageEventStream

func NewAssistantMessageEventStream

func NewAssistantMessageEventStream() *AssistantMessageEventStream

func Stream

func Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func StreamSimple

func StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type AzureOpenAIConfig

type AzureOpenAIConfig struct {
	BaseURL    string
	APIVersion string
}

func ResolveAzureOpenAIConfig

func ResolveAzureOpenAIConfig(model Model, options AzureOpenAIResponsesOptions) (AzureOpenAIConfig, error)

type AzureOpenAIResponsesOptions

type AzureOpenAIResponsesOptions struct {
	AzureAPIVersion     string
	AzureResourceName   string
	AzureBaseURL        string
	AzureDeploymentName string
}

type AzureOpenAIResponsesPayload

type AzureOpenAIResponsesPayload struct {
	Model           string                     `json:"model"`
	Input           []OpenAIResponsesInputItem `json:"input"`
	Stream          bool                       `json:"stream"`
	PromptCacheKey  string                     `json:"prompt_cache_key,omitempty"`
	MaxOutputTokens int                        `json:"max_output_tokens,omitempty"`
	Temperature     *float64                   `json:"temperature,omitempty"`
	Tools           []OpenAIResponsesTool      `json:"tools,omitempty"`
	Reasoning       map[string]string          `json:"reasoning,omitempty"`
	Include         []string                   `json:"include,omitempty"`
}

func BuildAzureOpenAIResponsesPayload

func BuildAzureOpenAIResponsesPayload(model Model, context Context, options AzureOpenAIResponsesPayloadOptions) AzureOpenAIResponsesPayload

type AzureOpenAIResponsesPayloadOptions

type AzureOpenAIResponsesPayloadOptions struct {
	DeploymentName   string
	MaxTokens        int
	Temperature      *float64
	SessionID        string
	ReasoningEffort  string
	ReasoningSummary string
}

type AzureOpenAIResponsesProvider

type AzureOpenAIResponsesProvider struct {
	Client HTTPDoer
}

func NewAzureOpenAIResponsesProvider

func NewAzureOpenAIResponsesProvider(client HTTPDoer) AzureOpenAIResponsesProvider

func (AzureOpenAIResponsesProvider) Stream

func (AzureOpenAIResponsesProvider) StreamSimple

func (p AzureOpenAIResponsesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type BedrockCachePoint

type BedrockCachePoint struct {
	Type string
	TTL  string
}

type BedrockClientConfig

type BedrockClientConfig struct {
	Endpoint string
	Region   string
	Profile  string
}

func ResolveBedrockClientConfig

func ResolveBedrockClientConfig(model Model, options BedrockClientOptions) BedrockClientConfig

type BedrockClientOptions

type BedrockClientOptions struct {
	Region  string
	Profile string
}

type BedrockContentBlock

type BedrockContentBlock struct {
	Text             string
	Image            *BedrockImageBlock
	ToolUse          *BedrockToolUseBlock
	ToolResult       *BedrockToolResultBlock
	ReasoningContent *BedrockReasoningContent
	CachePoint       *BedrockCachePoint
}

type BedrockContentBlockDeltaEvent

type BedrockContentBlockDeltaEvent struct {
	ContentBlockIndex int
	Text              string
	ToolUseInput      string
	ReasoningContent  *BedrockReasoningContent
}

type BedrockContentBlockStartEvent

type BedrockContentBlockStartEvent struct {
	ContentBlockIndex int
	ToolUse           *BedrockToolUseBlock
}

type BedrockContentBlockStopEvent

type BedrockContentBlockStopEvent struct {
	ContentBlockIndex int
}

type BedrockConverseStreamEvent

type BedrockConverseStreamEvent struct {
	MessageStart      *BedrockMessageStartEvent
	ContentBlockStart *BedrockContentBlockStartEvent
	ContentBlockDelta *BedrockContentBlockDeltaEvent
	ContentBlockStop  *BedrockContentBlockStopEvent
	MessageStop       *BedrockMessageStopEvent
	Metadata          *BedrockMetadataEvent
	Error             error
}

type BedrockConverseStreamProcessor

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

func NewBedrockConverseStreamProcessor

func NewBedrockConverseStreamProcessor(model Model, output *Message) *BedrockConverseStreamProcessor

func (*BedrockConverseStreamProcessor) Process

type BedrockConverseStreamProvider

type BedrockConverseStreamProvider struct {
	Transport BedrockConverseStreamTransport
}

func (BedrockConverseStreamProvider) Stream

func (BedrockConverseStreamProvider) StreamSimple

type BedrockConverseStreamRequest

type BedrockConverseStreamRequest struct {
	Model           Model
	Payload         BedrockPayload
	ClientConfig    BedrockClientConfig
	MaxTokens       int
	Temperature     *float64
	CacheRetention  string
	RequestMetadata map[string]string
}

type BedrockImageBlock

type BedrockImageBlock struct {
	Format string
	Data   string
}

type BedrockMessage

type BedrockMessage struct {
	Role    string
	Content []BedrockContentBlock
}

func ConvertBedrockMessages

func ConvertBedrockMessages(model Model, context Context, cacheRetention string, forcePromptCache bool) []BedrockMessage

type BedrockMessageStartEvent

type BedrockMessageStartEvent struct {
	Role string
}

type BedrockMessageStopEvent

type BedrockMessageStopEvent struct {
	StopReason string
}

type BedrockMetadataEvent

type BedrockMetadataEvent struct {
	Usage BedrockUsage
}

type BedrockNamedToolChoice

type BedrockNamedToolChoice struct {
	Type string
	Name string
}

type BedrockPayload

type BedrockPayload struct {
	System                       []BedrockContentBlock
	Messages                     []BedrockMessage
	ToolConfig                   *BedrockToolConfig
	AdditionalModelRequestFields map[string]any
}

func BuildBedrockPayload

func BuildBedrockPayload(model Model, context Context, options BedrockPayloadOptions) BedrockPayload

type BedrockPayloadOptions

type BedrockPayloadOptions struct {
	Reasoning           string
	Region              string
	ThinkingBudgets     map[string]int
	ThinkingDisplay     string
	InterleavedThinking *bool
	CacheRetention      string
	ForcePromptCache    bool
	ToolChoice          any
}

type BedrockReasoningContent

type BedrockReasoningContent struct {
	Text      string
	Signature string
}

type BedrockTool

type BedrockTool struct {
	ToolSpec BedrockToolSpec
}

type BedrockToolConfig

type BedrockToolConfig struct {
	Tools      []BedrockTool
	ToolChoice any
}

func ConvertBedrockToolConfig

func ConvertBedrockToolConfig(tools []Tool, toolChoice any) *BedrockToolConfig

type BedrockToolInputSchema

type BedrockToolInputSchema struct {
	JSON map[string]any
}

type BedrockToolResultBlock

type BedrockToolResultBlock struct {
	ToolUseID string
	Content   []BedrockContentBlock
	Status    string
}

type BedrockToolSpec

type BedrockToolSpec struct {
	Name        string
	Description string
	InputSchema BedrockToolInputSchema
}

type BedrockToolUseBlock

type BedrockToolUseBlock struct {
	ToolUseID string
	Name      string
	Input     map[string]any
}

type BedrockUsage

type BedrockUsage struct {
	InputTokens          int
	OutputTokens         int
	CacheReadInputTokens int
	CacheWriteTokens     int
	TotalTokens          int
}

type ContentPart

type ContentPart struct {
	Type              string         `json:"type"`
	Text              string         `json:"text,omitempty"`
	TextSignature     string         `json:"textSignature,omitempty"`
	Thinking          string         `json:"thinking,omitempty"`
	ThinkingSignature string         `json:"thinkingSignature,omitempty"`
	Redacted          bool           `json:"redacted,omitempty"`
	Data              string         `json:"data,omitempty"`
	MIMEType          string         `json:"mimeType,omitempty"`
	ID                string         `json:"id,omitempty"`
	Name              string         `json:"name,omitempty"`
	Arguments         map[string]any `json:"arguments,omitempty"`
	ThoughtSignature  string         `json:"thoughtSignature,omitempty"`
}

func FauxText

func FauxText(text string) ContentPart

func FauxThinking

func FauxThinking(thinking string) ContentPart

func FauxToolCall

func FauxToolCall(name string, arguments map[string]any, id string) ContentPart

func Image

func Image(data, mimeType string) ContentPart

func Text

func Text(text string) ContentPart

func Thinking

func Thinking(thinking string) ContentPart

func ToolCall

func ToolCall(id, name string, args map[string]any) ContentPart

type Context

type Context struct {
	SystemPrompt string    `json:"systemPrompt,omitempty"`
	Messages     []Message `json:"messages,omitempty"`
	Tools        []Tool    `json:"tools,omitempty"`
}

type ConvertOpenAIResponsesOptions

type ConvertOpenAIResponsesOptions struct {
	AllowedToolCallProviders map[string]bool
	IncludeSystemPrompt      *bool
}

type DiagnosticErrorInfo

type DiagnosticErrorInfo struct {
	Name    string `json:"name,omitempty"`
	Message string `json:"message"`
	Stack   string `json:"stack,omitempty"`
	Code    any    `json:"code,omitempty"`
}

func ExtractDiagnosticError

func ExtractDiagnosticError(value any) DiagnosticErrorInfo

type EventStream

type EventStream[T any, R any] struct {
	*eventstream.EventStream[T, R]
}

func NewEventStream

func NewEventStream[T any, R any](isComplete func(T) bool, extract func(T) R) *EventStream[T, R]

type FauxModelDefinition

type FauxModelDefinition struct {
	ID            string
	Name          string
	Reasoning     bool
	Input         []string
	Cost          ModelCost
	ContextWindow int
	MaxTokens     int
}

type FauxOption

type FauxOption func(*FauxOptions)

func WithFauxAPI

func WithFauxAPI(api string) FauxOption

func WithFauxModels

func WithFauxModels(models ...FauxModelDefinition) FauxOption

func WithFauxProvider

func WithFauxProvider(provider string) FauxOption

func WithFauxTokenSize

func WithFauxTokenSize(min, max int) FauxOption

func WithFauxTokensPerSecond

func WithFauxTokensPerSecond(tokensPerSecond float64) FauxOption

type FauxOptions

type FauxOptions struct {
	API             string
	Provider        string
	Models          []FauxModelDefinition
	TokensPerSecond float64
	TokenSize       FauxTokenSize
}

type FauxProviderRegistration

type FauxProviderRegistration struct {
	API      string
	Provider string
	Models   []Model
	State    FauxState
	// contains filtered or unexported fields
}

func RegisterFauxProvider

func RegisterFauxProvider(options ...FauxOption) *FauxProviderRegistration

func (*FauxProviderRegistration) AppendResponses

func (r *FauxProviderRegistration) AppendResponses(responses []FauxResponseStep)

func (*FauxProviderRegistration) GetModel

func (r *FauxProviderRegistration) GetModel(modelID ...string) (Model, bool)

func (*FauxProviderRegistration) MustModel

func (r *FauxProviderRegistration) MustModel(modelID ...string) Model

func (*FauxProviderRegistration) PendingResponseCount

func (r *FauxProviderRegistration) PendingResponseCount() int

func (*FauxProviderRegistration) SetResponses

func (r *FauxProviderRegistration) SetResponses(responses []FauxResponseStep)

func (*FauxProviderRegistration) Stream

func (r *FauxProviderRegistration) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func (*FauxProviderRegistration) StreamSimple

func (r *FauxProviderRegistration) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

func (*FauxProviderRegistration) Unregister

func (r *FauxProviderRegistration) Unregister()

type FauxResponseFactory

type FauxResponseFactory func(context Context, options StreamOptions, state FauxState, model Model) (Message, error)

type FauxResponseStep

type FauxResponseStep struct {
	Message Message
	Factory FauxResponseFactory
}

type FauxState

type FauxState struct {
	CallCount int
}

type FauxTokenSize

type FauxTokenSize struct {
	Min int
	Max int
}

type GitHubCopilotDevicePollResponse

type GitHubCopilotDevicePollResponse struct {
	AccessToken string
	Error       string
	Interval    int
}

type GoogleCandidate

type GoogleCandidate struct {
	Content      GoogleContent `json:"content"`
	FinishReason string        `json:"finishReason"`
}

type GoogleContent

type GoogleContent struct {
	Role  string       `json:"role"`
	Parts []GooglePart `json:"parts"`
}

func ConvertGoogleMessages

func ConvertGoogleMessages(model Model, context Context) []GoogleContent

type GoogleFunctionCall

type GoogleFunctionCall struct {
	Name string         `json:"name"`
	Args map[string]any `json:"args"`
	ID   string         `json:"id,omitempty"`
}

type GoogleFunctionDeclaration

type GoogleFunctionDeclaration struct {
	Name                 string `json:"name"`
	Description          string `json:"description,omitempty"`
	Parameters           any    `json:"parameters,omitempty"`
	ParametersJSONSchema any    `json:"parametersJsonSchema,omitempty"`
}

type GoogleFunctionResponse

type GoogleFunctionResponse struct {
	Name     string         `json:"name"`
	Response map[string]any `json:"response"`
	Parts    []GooglePart   `json:"parts,omitempty"`
	ID       string         `json:"id,omitempty"`
}

type GoogleGenerateConfig

type GoogleGenerateConfig struct {
	Temperature       *float64              `json:"temperature,omitempty"`
	MaxOutputTokens   int                   `json:"maxOutputTokens,omitempty"`
	SystemInstruction *GoogleSystemContent  `json:"systemInstruction,omitempty"`
	ThinkingConfig    *GoogleThinkingConfig `json:"thinkingConfig,omitempty"`
}

type GoogleInlineData

type GoogleInlineData struct {
	MIMEType string `json:"mimeType"`
	Data     string `json:"data"`
}

type GooglePart

type GooglePart struct {
	Text             string                  `json:"text,omitempty"`
	Thought          bool                    `json:"thought,omitempty"`
	ThoughtSignature string                  `json:"thoughtSignature,omitempty"`
	InlineData       *GoogleInlineData       `json:"inlineData,omitempty"`
	FunctionCall     *GoogleFunctionCall     `json:"functionCall,omitempty"`
	FunctionResponse *GoogleFunctionResponse `json:"functionResponse,omitempty"`
}

type GooglePayload

type GooglePayload struct {
	Model    string               `json:"-"`
	Contents []GoogleContent      `json:"contents"`
	Tools    []GoogleToolGroup    `json:"tools,omitempty"`
	Config   GoogleGenerateConfig `json:"generationConfig,omitempty"`
}

func BuildGooglePayload

func BuildGooglePayload(model Model, llmContext Context, options GooglePayloadOptions) GooglePayload

type GooglePayloadOptions

type GooglePayloadOptions struct {
	MaxTokens       int
	Temperature     *float64
	Reasoning       string
	ThinkingBudgets map[string]int
}

type GoogleProvider

type GoogleProvider struct {
	Client HTTPDoer
}

func NewGoogleProvider

func NewGoogleProvider(client HTTPDoer) GoogleProvider

func (GoogleProvider) Stream

func (p GoogleProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func (GoogleProvider) StreamSimple

func (p GoogleProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type GoogleStreamChunk

type GoogleStreamChunk struct {
	ResponseID    string               `json:"responseId"`
	Candidates    []GoogleCandidate    `json:"candidates"`
	UsageMetadata *GoogleUsageMetadata `json:"usageMetadata,omitempty"`
}

func DecodeGoogleStreamChunk

func DecodeGoogleStreamChunk(data []byte) (GoogleStreamChunk, error)

type GoogleSystemContent

type GoogleSystemContent struct {
	Parts []GooglePart `json:"parts"`
}

type GoogleThinkingConfig

type GoogleThinkingConfig struct {
	IncludeThoughts *bool  `json:"includeThoughts,omitempty"`
	ThinkingLevel   string `json:"thinkingLevel,omitempty"`
	ThinkingBudget  *int   `json:"thinkingBudget,omitempty"`
}

func BuildGoogleThinkingConfig

func BuildGoogleThinkingConfig(model Model, options GoogleThinkingOptions) *GoogleThinkingConfig

func DisabledGoogleThinkingConfig

func DisabledGoogleThinkingConfig(model Model) *GoogleThinkingConfig

type GoogleThinkingOptions

type GoogleThinkingOptions struct {
	Enabled       *bool
	Level         string
	BudgetTokens  *int
	Reasoning     string
	CustomBudgets map[string]int
}

type GoogleToolGroup

type GoogleToolGroup struct {
	FunctionDeclarations []GoogleFunctionDeclaration `json:"functionDeclarations"`
}

func ConvertGoogleTools

func ConvertGoogleTools(tools []Tool, useParameters bool) []GoogleToolGroup

type GoogleUsageMetadata

type GoogleUsageMetadata struct {
	PromptTokenCount        int `json:"promptTokenCount"`
	CandidatesTokenCount    int `json:"candidatesTokenCount"`
	ThoughtsTokenCount      int `json:"thoughtsTokenCount"`
	CachedContentTokenCount int `json:"cachedContentTokenCount"`
	TotalTokenCount         int `json:"totalTokenCount"`
}

type GoogleVertexClientConfig

type GoogleVertexClientConfig struct {
	VertexAI    bool
	APIKey      string
	Project     string
	Location    string
	APIVersion  string
	HTTPOptions *GoogleVertexHTTPOptions
}

func ResolveGoogleVertexClientConfig

func ResolveGoogleVertexClientConfig(model Model, options GoogleVertexOptions) GoogleVertexClientConfig

type GoogleVertexHTTPOptions

type GoogleVertexHTTPOptions struct {
	BaseURL              string
	BaseURLResourceScope string
	APIVersion           string
}

type GoogleVertexOptions

type GoogleVertexOptions struct {
	APIKey   string
	Project  string
	Location string
}

type HTTPDoer

type HTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

type ImagesAPIProvider

type ImagesAPIProvider interface {
	GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)
}

func GetImagesAPIProvider

func GetImagesAPIProvider(api string) ImagesAPIProvider

type ImagesAPIProviderFuncs

type ImagesAPIProviderFuncs struct {
	GenerateImagesFunc func(ImagesModel, ImagesContext, ImagesOptions) (AssistantImages, error)
}

func (ImagesAPIProviderFuncs) GenerateImages

func (p ImagesAPIProviderFuncs) GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)

type ImagesContent

type ImagesContent struct {
	Type     string
	Text     string
	Data     string
	MIMEType string
}

func ImageData

func ImageData(data, mimeType string) ImagesContent

func ImageText

func ImageText(text string) ImagesContent

type ImagesContext

type ImagesContext struct {
	Input []ImagesContent
}

type ImagesModel

type ImagesModel struct {
	ID       string
	Name     string
	API      string
	Provider string
	BaseURL  string
	Input    []string
	Output   []string
	Cost     ModelCost
	Headers  map[string]string
}

func GetImageModel

func GetImageModel(provider, id string) (ImagesModel, bool)

func GetImageModels

func GetImageModels(provider string) []ImagesModel

func MustGetImageModel

func MustGetImageModel(provider, id string) ImagesModel

type ImagesOptions

type ImagesOptions struct {
	Context         context.Context
	APIKey          string
	Headers         map[string]string
	TimeoutMillis   int
	MaxRetries      int
	MaxRetryDelayMs int
	OnPayload       func(payload any, model ImagesModel) (any, bool, error)
	OnResponse      func(status int, headers map[string]string, model ImagesModel) error
}

type Message

type Message struct {
	Role         string                       `json:"role"`
	Content      []ContentPart                `json:"content,omitempty"`
	Timestamp    int64                        `json:"timestamp,omitempty"`
	API          string                       `json:"api,omitempty"`
	Provider     string                       `json:"provider,omitempty"`
	Model        string                       `json:"model,omitempty"`
	Diagnostics  []AssistantMessageDiagnostic `json:"diagnostics,omitempty"`
	Usage        Usage                        `json:"usage,omitempty"`
	StopReason   string                       `json:"stopReason,omitempty"`
	ErrorMessage string                       `json:"errorMessage,omitempty"`
	ResponseID   string                       `json:"responseId,omitempty"`
	ToolCallID   string                       `json:"toolCallID,omitempty"`
	ToolName     string                       `json:"toolName,omitempty"`
	CustomType   string                       `json:"customType,omitempty"`
	Display      *bool                        `json:"display,omitempty"`
	Details      any                          `json:"details,omitempty"`
	IsError      bool                         `json:"isError,omitempty"`
}

func AssistantErrorMessage

func AssistantErrorMessage(message string, model Model, aborted bool) Message

func AssistantMessage

func AssistantMessage(content []ContentPart, stopReason string, model Model) Message

func Complete

func Complete(ctx context.Context, model Model, llmContext Context, options StreamOptions) (Message, error)

func CompleteSimple

func CompleteSimple(ctx context.Context, model Model, llmContext Context, options SimpleStreamOptions) (Message, error)

func FauxAssistantMessage

func FauxAssistantMessage(content []ContentPart, stopReason string) Message

func FauxAssistantText

func FauxAssistantText(text string) Message

func ProcessAnthropicSSEEvents

func ProcessAnthropicSSEEvents(model Model, events []AnthropicSSEEvent) (Message, error)

func ProcessOpenAICompletionsChunks

func ProcessOpenAICompletionsChunks(model Model, chunks []*OpenAIChatCompletionChunk) Message

func TransformMessages

func TransformMessages(messages []Message, model Model, normalizeToolCallID NormalizeToolCallIDFunc) []Message

func UserMessageText

func UserMessageText(text string) Message

type MistralCompletionChoice

type MistralCompletionChoice struct {
	Delta        MistralDelta `json:"delta"`
	FinishReason string       `json:"finish_reason"`
}

type MistralCompletionChunk

type MistralCompletionChunk struct {
	ID      string                    `json:"id"`
	Choices []MistralCompletionChoice `json:"choices"`
	Usage   *MistralUsage             `json:"usage,omitempty"`
}

func DecodeMistralCompletionChunk

func DecodeMistralCompletionChunk(data []byte) (MistralCompletionChunk, error)

type MistralContentPart

type MistralContentPart struct {
	Type     string        `json:"type"`
	Text     string        `json:"text,omitempty"`
	ImageURL string        `json:"image_url,omitempty"`
	Thinking []MistralText `json:"thinking,omitempty"`
}

type MistralDelta

type MistralDelta struct {
	Content   json.RawMessage         `json:"content,omitempty"`
	ToolCalls []MistralStreamToolCall `json:"tool_calls,omitempty"`
}

type MistralMessage

type MistralMessage struct {
	Role       string            `json:"role"`
	Content    any               `json:"content,omitempty"`
	ToolCalls  []MistralToolCall `json:"tool_calls,omitempty"`
	ToolCallID string            `json:"tool_call_id,omitempty"`
	Name       string            `json:"name,omitempty"`
}

func ConvertMistralMessages

func ConvertMistralMessages(model Model, context Context) []MistralMessage

type MistralPayload

type MistralPayload struct {
	Model           string           `json:"model"`
	Messages        []MistralMessage `json:"messages"`
	Tools           []MistralTool    `json:"tools,omitempty"`
	Stream          bool             `json:"stream"`
	MaxTokens       int              `json:"max_tokens,omitempty"`
	Temperature     *float64         `json:"temperature,omitempty"`
	ToolChoice      any              `json:"tool_choice,omitempty"`
	PromptMode      string           `json:"prompt_mode,omitempty"`
	ReasoningEffort string           `json:"reasoning_effort,omitempty"`
}

func BuildMistralPayload

func BuildMistralPayload(model Model, context Context, options MistralPayloadOptions) MistralPayload

type MistralPayloadOptions

type MistralPayloadOptions struct {
	MaxTokens   int
	Temperature *float64
	Reasoning   string
	ToolChoice  any
}

type MistralProvider

type MistralProvider struct {
	Client HTTPDoer
}

func NewMistralProvider

func NewMistralProvider(client HTTPDoer) MistralProvider

func (MistralProvider) Stream

func (p MistralProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func (MistralProvider) StreamSimple

func (p MistralProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type MistralStreamEvent

type MistralStreamEvent struct {
	Data MistralCompletionChunk `json:"data"`
}

type MistralStreamToolCall

type MistralStreamToolCall struct {
	Index    *int                    `json:"index,omitempty"`
	ID       string                  `json:"id,omitempty"`
	Type     string                  `json:"type,omitempty"`
	Function MistralToolCallFunction `json:"function"`
}

type MistralText

type MistralText struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type MistralTool

type MistralTool struct {
	Type     string              `json:"type"`
	Function MistralToolFunction `json:"function"`
}

func ConvertMistralTools

func ConvertMistralTools(tools []Tool) []MistralTool

type MistralToolCall

type MistralToolCall struct {
	ID       string                  `json:"id"`
	Type     string                  `json:"type"`
	Function MistralToolCallFunction `json:"function"`
}

type MistralToolCallFunction

type MistralToolCallFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type MistralToolFunction

type MistralToolFunction struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Parameters  any    `json:"parameters,omitempty"`
	Strict      bool   `json:"strict"`
}

type MistralUsage

type MistralUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

type Model

type Model struct {
	ID               string             `json:"id"`
	Name             string             `json:"name"`
	API              string             `json:"api"`
	Provider         string             `json:"provider"`
	BaseURL          string             `json:"baseUrl,omitempty"`
	Headers          map[string]string  `json:"headers,omitempty"`
	Compat           ModelCompat        `json:"compat,omitempty"`
	Reasoning        bool               `json:"reasoning"`
	Input            []string           `json:"input,omitempty"`
	Cost             ModelCost          `json:"cost"`
	ContextWindow    int                `json:"contextWindow"`
	MaxTokens        int                `json:"maxTokens"`
	ThinkingLevelMap map[string]*string `json:"thinkingLevelMap,omitempty"`
}

func GetModel

func GetModel(provider, modelID string) (Model, bool)

func GetModels

func GetModels(provider string) []Model

func MustGetModel

func MustGetModel(provider, modelID string) Model

type ModelCompat

type ModelCompat struct {
	SupportsStore                             *bool          `json:"supportsStore,omitempty"`
	SupportsDeveloperRole                     *bool          `json:"supportsDeveloperRole,omitempty"`
	SupportsReasoningEffort                   *bool          `json:"supportsReasoningEffort,omitempty"`
	SupportsUsageInStreaming                  *bool          `json:"supportsUsageInStreaming,omitempty"`
	SupportsStrictMode                        *bool          `json:"supportsStrictMode,omitempty"`
	SupportsLongCacheRetention                *bool          `json:"supportsLongCacheRetention,omitempty"`
	SupportsEagerToolInputStreaming           *bool          `json:"supportsEagerToolInputStreaming,omitempty"`
	SupportsCacheControlOnTools               *bool          `json:"supportsCacheControlOnTools,omitempty"`
	ForceAdaptiveThinking                     *bool          `json:"forceAdaptiveThinking,omitempty"`
	SendSessionAffinityHeaders                *bool          `json:"sendSessionAffinityHeaders,omitempty"`
	SendSessionIDHeader                       *bool          `json:"sendSessionIdHeader,omitempty"`
	RequiresToolResultName                    *bool          `json:"requiresToolResultName,omitempty"`
	RequiresAssistantAfterToolResult          *bool          `json:"requiresAssistantAfterToolResult,omitempty"`
	RequiresThinkingAsText                    *bool          `json:"requiresThinkingAsText,omitempty"`
	RequiresReasoningContentOnAssistantTurns  *bool          `json:"requiresReasoningContentOnAssistantTurns,omitempty"`
	RequiresReasoningContentOnAssistantEvents *bool          `json:"requiresReasoningContentOnAssistantEvents,omitempty"`
	ZAIToolStream                             *bool          `json:"zaiToolStream,omitempty"`
	OpenRouterRouting                         map[string]any `json:"openRouterRouting,omitempty"`
	VercelGatewayRouting                      map[string]any `json:"vercelGatewayRouting,omitempty"`
	MaxTokensField                            string         `json:"maxTokensField,omitempty"`
	ThinkingFormat                            string         `json:"thinkingFormat,omitempty"`
	CacheControlFormat                        string         `json:"cacheControlFormat,omitempty"`
}

type ModelCost

type ModelCost struct {
	Input      float64 `json:"input"`
	Output     float64 `json:"output"`
	CacheRead  float64 `json:"cacheRead"`
	CacheWrite float64 `json:"cacheWrite"`
}

type NormalizeToolCallIDFunc

type NormalizeToolCallIDFunc func(id string, model Model, source Message) string

type OAuthCredentials

type OAuthCredentials struct {
	Access  string
	Refresh string
	Expires int64
}

type OAuthPageOptions

type OAuthPageOptions = oauthpage.OAuthPageOptions

type OAuthTokenRequest

type OAuthTokenRequest struct {
	URL  string
	Body map[string]string
}

func BuildAnthropicAuthorizationCodeTokenRequest

func BuildAnthropicAuthorizationCodeTokenRequest(code, redirectURI string) OAuthTokenRequest

func BuildAnthropicRefreshTokenRequest

func BuildAnthropicRefreshTokenRequest(refreshToken string) OAuthTokenRequest

type OpenAIChatCompletionChoice

type OpenAIChatCompletionChoice struct {
	Delta        OpenAIChatDelta  `json:"delta"`
	FinishReason *string          `json:"finish_reason"`
	Usage        *OpenAIChatUsage `json:"usage,omitempty"`
}

type OpenAIChatCompletionChunk

type OpenAIChatCompletionChunk struct {
	ID      string                       `json:"id"`
	Choices []OpenAIChatCompletionChoice `json:"choices"`
	Usage   *OpenAIChatUsage             `json:"usage,omitempty"`
}

func DecodeOpenAIChatCompletionChunk

func DecodeOpenAIChatCompletionChunk(data []byte) (OpenAIChatCompletionChunk, error)

type OpenAIChatCompletionTokenDetails

type OpenAIChatCompletionTokenDetails struct {
	ReasoningTokens int `json:"reasoning_tokens"`
}

type OpenAIChatContentPart

type OpenAIChatContentPart struct {
	Type         string                    `json:"type"`
	Text         string                    `json:"text,omitempty"`
	ImageURL     *OpenAIChatImageURL       `json:"image_url,omitempty"`
	CacheControl *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}

type OpenAIChatDelta

type OpenAIChatDelta struct {
	Content          string                    `json:"content,omitempty"`
	ReasoningContent string                    `json:"reasoning_content,omitempty"`
	Reasoning        string                    `json:"reasoning,omitempty"`
	ReasoningText    string                    `json:"reasoning_text,omitempty"`
	ToolCalls        []OpenAIChatToolCallDelta `json:"tool_calls,omitempty"`
}

type OpenAIChatImageURL

type OpenAIChatImageURL struct {
	URL string `json:"url"`
}

type OpenAIChatMessage

type OpenAIChatMessage struct {
	Role             string               `json:"role"`
	Content          any                  `json:"content,omitempty"`
	ToolCalls        []OpenAIChatToolCall `json:"tool_calls,omitempty"`
	ToolCallID       string               `json:"tool_call_id,omitempty"`
	Name             string               `json:"name,omitempty"`
	ReasoningContent string               `json:"reasoning_content,omitempty"`
	Reasoning        string               `json:"reasoning,omitempty"`
	ReasoningText    string               `json:"reasoning_text,omitempty"`
	ReasoningDetails []map[string]any     `json:"reasoning_details,omitempty"`
	Extra            map[string]any       `json:"-"`
	// contains filtered or unexported fields
}

func ConvertOpenAICompletionsMessages

func ConvertOpenAICompletionsMessages(model Model, context Context, compat OpenAICompletionsCompat) []OpenAIChatMessage

func (OpenAIChatMessage) MarshalJSON

func (m OpenAIChatMessage) MarshalJSON() ([]byte, error)

type OpenAIChatPromptTokenDetails

type OpenAIChatPromptTokenDetails struct {
	CachedTokens     int `json:"cached_tokens"`
	CacheWriteTokens int `json:"cache_write_tokens"`
}

type OpenAIChatTool

type OpenAIChatTool struct {
	Type         string                    `json:"type"`
	Function     OpenAIChatToolFunction    `json:"function"`
	CacheControl *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}

func ConvertOpenAICompletionsTools

func ConvertOpenAICompletionsTools(tools []Tool, compat OpenAICompletionsCompat) []OpenAIChatTool

type OpenAIChatToolCall

type OpenAIChatToolCall struct {
	ID       string                     `json:"id"`
	Type     string                     `json:"type"`
	Function OpenAIChatToolCallFunction `json:"function"`
}

type OpenAIChatToolCallDelta

type OpenAIChatToolCallDelta struct {
	Index    *int                            `json:"index,omitempty"`
	ID       string                          `json:"id,omitempty"`
	Type     string                          `json:"type,omitempty"`
	Function OpenAIChatToolCallFunctionDelta `json:"function"`
}

type OpenAIChatToolCallFunction

type OpenAIChatToolCallFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type OpenAIChatToolCallFunctionDelta

type OpenAIChatToolCallFunctionDelta struct {
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
}

type OpenAIChatToolFunction

type OpenAIChatToolFunction struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Parameters  any    `json:"parameters,omitempty"`
	Strict      *bool  `json:"strict,omitempty"`
}

type OpenAIChatUsage

type OpenAIChatUsage struct {
	PromptTokens           int                              `json:"prompt_tokens"`
	CompletionTokens       int                              `json:"completion_tokens"`
	PromptCacheHitTokens   int                              `json:"prompt_cache_hit_tokens"`
	PromptTokensDetails    OpenAIChatPromptTokenDetails     `json:"prompt_tokens_details"`
	CompletionTokenDetails OpenAIChatCompletionTokenDetails `json:"completion_tokens_details"`
}

type OpenAICodexProcessOptions

type OpenAICodexProcessOptions struct {
	ServiceTier string
}

type OpenAICodexResponsesPayload

type OpenAICodexResponsesPayload struct {
	Model              string                     `json:"model"`
	Store              bool                       `json:"store"`
	Stream             bool                       `json:"stream"`
	Instructions       string                     `json:"instructions"`
	PreviousResponseID string                     `json:"previous_response_id,omitempty"`
	Input              []OpenAIResponsesInputItem `json:"input,omitempty"`
	Tools              []OpenAIResponsesTool      `json:"tools,omitempty"`
	Temperature        *float64                   `json:"temperature,omitempty"`
	Reasoning          map[string]string          `json:"reasoning,omitempty"`
	ServiceTier        string                     `json:"service_tier,omitempty"`
	Text               map[string]string          `json:"text,omitempty"`
	Include            []string                   `json:"include,omitempty"`
	PromptCacheKey     string                     `json:"prompt_cache_key,omitempty"`
	ToolChoice         string                     `json:"tool_choice,omitempty"`
	ParallelToolCalls  bool                       `json:"parallel_tool_calls"`
}

func BuildOpenAICodexResponsesPayload

func BuildOpenAICodexResponsesPayload(model Model, context Context, options OpenAICodexResponsesPayloadOptions) OpenAICodexResponsesPayload

type OpenAICodexResponsesPayloadOptions

type OpenAICodexResponsesPayloadOptions struct {
	Temperature      *float64
	SessionID        string
	ReasoningEffort  string
	ReasoningSummary string
	ServiceTier      string
	TextVerbosity    string
}

type OpenAICodexResponsesProvider

type OpenAICodexResponsesProvider struct {
	Client HTTPDoer
	Now    func() time.Time
	Sleep  func(context.Context, time.Duration) error
}

func NewOpenAICodexResponsesProvider

func NewOpenAICodexResponsesProvider(client HTTPDoer) OpenAICodexResponsesProvider

func (OpenAICodexResponsesProvider) Stream

func (OpenAICodexResponsesProvider) StreamSimple

func (p OpenAICodexResponsesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type OpenAICodexWebSocketDebugStats

type OpenAICodexWebSocketDebugStats struct {
	Requests                int    `json:"requests"`
	ConnectionsCreated      int    `json:"connectionsCreated"`
	ConnectionsReused       int    `json:"connectionsReused"`
	CachedContextRequests   int    `json:"cachedContextRequests"`
	StoreTrueRequests       int    `json:"storeTrueRequests"`
	FullContextRequests     int    `json:"fullContextRequests"`
	DeltaRequests           int    `json:"deltaRequests"`
	LastInputItems          int    `json:"lastInputItems"`
	LastDeltaInputItems     *int   `json:"lastDeltaInputItems,omitempty"`
	LastPreviousResponseID  string `json:"lastPreviousResponseId,omitempty"`
	WebSocketFailures       int    `json:"websocketFailures"`
	SSEFallbacks            int    `json:"sseFallbacks"`
	WebSocketFallbackActive bool   `json:"websocketFallbackActive,omitempty"`
	LastWebSocketError      string `json:"lastWebSocketError,omitempty"`
}

func GetOpenAICodexWebSocketDebugStats

func GetOpenAICodexWebSocketDebugStats(sessionID string) (OpenAICodexWebSocketDebugStats, bool)

type OpenAICompatCacheControl

type OpenAICompatCacheControl struct {
	Type string `json:"type"`
	TTL  string `json:"ttl,omitempty"`
}

type OpenAICompletionsCompat

type OpenAICompletionsCompat struct {
	SupportsDeveloperRole                    bool
	SupportsStore                            bool
	SupportsReasoningEffort                  bool
	SupportsUsageInStreaming                 bool
	SupportsStrictMode                       bool
	SupportsLongCacheRetention               bool
	MaxTokensField                           string
	ThinkingFormat                           string
	CacheControlFormat                       string
	ZAIToolStream                            bool
	RequiresToolResultName                   bool
	RequiresAssistantAfterToolResult         bool
	RequiresThinkingAsText                   bool
	RequiresReasoningContentOnAssistant      bool
	RequiresReasoningContentOnAssistantTurns bool
}

func ResolveOpenAICompletionsCompat

func ResolveOpenAICompletionsCompat(model Model) OpenAICompletionsCompat

type OpenAICompletionsPayload

type OpenAICompletionsPayload struct {
	Model                string              `json:"model"`
	Messages             []OpenAIChatMessage `json:"messages"`
	Stream               bool                `json:"stream"`
	PromptCacheKey       string              `json:"prompt_cache_key,omitempty"`
	PromptCacheRetention string              `json:"prompt_cache_retention,omitempty"`
	StreamOptions        map[string]any      `json:"stream_options,omitempty"`
	Store                *bool               `json:"store,omitempty"`
	MaxTokens            int                 `json:"max_tokens,omitempty"`
	MaxCompletionTokens  int                 `json:"max_completion_tokens,omitempty"`
	Temperature          *float64            `json:"temperature,omitempty"`
	Tools                []OpenAIChatTool    `json:"tools,omitempty"`
	ToolChoice           any                 `json:"tool_choice,omitempty"`
	ToolStream           *bool               `json:"tool_stream,omitempty"`
	EnableThinking       *bool               `json:"enable_thinking,omitempty"`
	ChatTemplateKwargs   map[string]any      `json:"chat_template_kwargs,omitempty"`
	Thinking             map[string]any      `json:"thinking,omitempty"`
	Reasoning            map[string]any      `json:"reasoning,omitempty"`
	ReasoningEffort      string              `json:"reasoning_effort,omitempty"`
}

func BuildOpenAICompletionsPayload

func BuildOpenAICompletionsPayload(model Model, context Context, options OpenAICompletionsPayloadOptions) OpenAICompletionsPayload

func BuildOpenAICompletionsPayloadChecked

func BuildOpenAICompletionsPayloadChecked(model Model, context Context, options OpenAICompletionsPayloadOptions) (OpenAICompletionsPayload, error)

type OpenAICompletionsPayloadOptions

type OpenAICompletionsPayloadOptions struct {
	MaxTokens      int
	Temperature    *float64
	CacheRetention string
	SessionID      string
	Reasoning      string
	ToolChoice     any
	Headers        map[string]string
}

type OpenAICompletionsProvider

type OpenAICompletionsProvider struct {
	Client HTTPDoer
}

func NewOpenAICompletionsProvider

func NewOpenAICompletionsProvider(client HTTPDoer) OpenAICompletionsProvider

func (OpenAICompletionsProvider) Stream

func (p OpenAICompletionsProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func (OpenAICompletionsProvider) StreamSimple

func (p OpenAICompletionsProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type OpenAICompletionsStreamProcessor

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

func NewOpenAICompletionsStreamProcessor

func NewOpenAICompletionsStreamProcessor(model Model, output *Message) *OpenAICompletionsStreamProcessor

func (*OpenAICompletionsStreamProcessor) Process

func (*OpenAICompletionsStreamProcessor) Result

type OpenAIResponsesCompat

type OpenAIResponsesCompat struct {
	SendSessionIDHeader        bool
	SupportsLongCacheRetention bool
}

func ResolveOpenAIResponsesCompat

func ResolveOpenAIResponsesCompat(model Model) OpenAIResponsesCompat

type OpenAIResponsesContentPart

type OpenAIResponsesContentPart struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	Refusal  string `json:"refusal,omitempty"`
	Detail   string `json:"detail,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
}

type OpenAIResponsesIncompleteDetails

type OpenAIResponsesIncompleteDetails struct {
	Reason string
}

type OpenAIResponsesInputItem

type OpenAIResponsesInputItem struct {
	Type             string                       `json:"type,omitempty"`
	Role             string                       `json:"role,omitempty"`
	Content          any                          `json:"content,omitempty"`
	Summary          []OpenAIResponsesContentPart `json:"summary,omitempty"`
	ID               string                       `json:"id,omitempty"`
	CallID           string                       `json:"call_id,omitempty"`
	Name             string                       `json:"name,omitempty"`
	Arguments        string                       `json:"arguments,omitempty"`
	Output           any                          `json:"output,omitempty"`
	Status           string                       `json:"status,omitempty"`
	Phase            string                       `json:"phase,omitempty"`
	EncryptedContent string                       `json:"encrypted_content,omitempty"`
}

func ConvertOpenAIResponsesMessages

func ConvertOpenAIResponsesMessages(model Model, context Context, options ConvertOpenAIResponsesOptions) []OpenAIResponsesInputItem

type OpenAIResponsesInputTokenDetails

type OpenAIResponsesInputTokenDetails struct {
	CachedTokens     int
	CacheWriteTokens int
}

type OpenAIResponsesOutputContentPart

type OpenAIResponsesOutputContentPart struct {
	Type    string `json:"type,omitempty"`
	Text    string `json:"text,omitempty"`
	Refusal string `json:"refusal,omitempty"`
}

type OpenAIResponsesOutputItem

type OpenAIResponsesOutputItem struct {
	Type             string                             `json:"type,omitempty"`
	ID               string                             `json:"id,omitempty"`
	CallID           string                             `json:"call_id,omitempty"`
	Name             string                             `json:"name,omitempty"`
	Arguments        string                             `json:"arguments,omitempty"`
	Status           string                             `json:"status,omitempty"`
	Content          []OpenAIResponsesOutputContentPart `json:"content,omitempty"`
	Summary          []OpenAIResponsesOutputContentPart `json:"summary,omitempty"`
	Phase            string                             `json:"phase,omitempty"`
	EncryptedContent string                             `json:"encrypted_content,omitempty"`
}

type OpenAIResponsesPayload

type OpenAIResponsesPayload struct {
	Model                string                     `json:"model"`
	Input                []OpenAIResponsesInputItem `json:"input"`
	Stream               bool                       `json:"stream"`
	PromptCacheKey       string                     `json:"prompt_cache_key,omitempty"`
	PromptCacheRetention string                     `json:"prompt_cache_retention,omitempty"`
	Store                bool                       `json:"store"`
	MaxOutputTokens      int                        `json:"max_output_tokens,omitempty"`
	Temperature          *float64                   `json:"temperature,omitempty"`
	ServiceTier          string                     `json:"service_tier,omitempty"`
	Tools                []OpenAIResponsesTool      `json:"tools,omitempty"`
	Reasoning            map[string]string          `json:"reasoning,omitempty"`
	Include              []string                   `json:"include,omitempty"`
}

func BuildOpenAIResponsesPayload

func BuildOpenAIResponsesPayload(model Model, context Context, options OpenAIResponsesPayloadOptions) OpenAIResponsesPayload

func BuildOpenAIResponsesPayloadChecked

func BuildOpenAIResponsesPayloadChecked(model Model, context Context, options OpenAIResponsesPayloadOptions) (OpenAIResponsesPayload, error)

type OpenAIResponsesPayloadOptions

type OpenAIResponsesPayloadOptions struct {
	MaxTokens        int
	Temperature      *float64
	CacheRetention   string
	SessionID        string
	ReasoningEffort  string
	ReasoningSummary string
	ServiceTier      string
	Headers          map[string]string
}

type OpenAIResponsesProvider

type OpenAIResponsesProvider struct {
	Client HTTPDoer
}

func NewOpenAIResponsesProvider

func NewOpenAIResponsesProvider(client HTTPDoer) OpenAIResponsesProvider

func (OpenAIResponsesProvider) Stream

func (p OpenAIResponsesProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)

func (OpenAIResponsesProvider) StreamSimple

func (p OpenAIResponsesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)

type OpenAIResponsesResponseEvent

type OpenAIResponsesResponseEvent struct {
	ID                string
	Status            string
	ServiceTier       string
	Usage             *OpenAIResponsesUsage
	IncompleteDetails *OpenAIResponsesIncompleteDetails
}

type OpenAIResponsesStreamEvent

type OpenAIResponsesStreamEvent struct {
	Type      string
	Response  *OpenAIResponsesResponseEvent
	Item      *OpenAIResponsesOutputItem
	Part      *OpenAIResponsesOutputContentPart
	Delta     string
	Arguments string
	Error     string
}

func DecodeOpenAIResponsesSSEEvent

func DecodeOpenAIResponsesSSEEvent(data []byte) (OpenAIResponsesStreamEvent, error)

type OpenAIResponsesStreamProcessor

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

func NewOpenAIResponsesStreamProcessor

func NewOpenAIResponsesStreamProcessor(model Model, output *Message) *OpenAIResponsesStreamProcessor

func (*OpenAIResponsesStreamProcessor) Process

type OpenAIResponsesTool

type OpenAIResponsesTool struct {
	Type        string         `json:"type"`
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Parameters  map[string]any `json:"parameters,omitempty"`
	Strict      *bool          `json:"strict,omitempty"`
}

func ConvertOpenAIResponsesTools

func ConvertOpenAIResponsesTools(tools []Tool, strict bool) []OpenAIResponsesTool

type OpenAIResponsesUsage

type OpenAIResponsesUsage struct {
	InputTokens        int
	OutputTokens       int
	TotalTokens        int
	InputTokensDetails OpenAIResponsesInputTokenDetails
}

type OpenRouterGeneratedImage

type OpenRouterGeneratedImage struct {
	ImageURL any `json:"image_url"`
}

type OpenRouterImagesChoice

type OpenRouterImagesChoice struct {
	Message OpenRouterImagesChoiceMessage `json:"message"`
}

type OpenRouterImagesChoiceMessage

type OpenRouterImagesChoiceMessage struct {
	Content string                     `json:"content,omitempty"`
	Images  []OpenRouterGeneratedImage `json:"images,omitempty"`
}

type OpenRouterImagesContentPart

type OpenRouterImagesContentPart struct {
	Type     string                    `json:"type"`
	Text     string                    `json:"text,omitempty"`
	ImageURL *OpenRouterImagesImageURL `json:"image_url,omitempty"`
}

type OpenRouterImagesImageURL

type OpenRouterImagesImageURL struct {
	URL string `json:"url"`
}

type OpenRouterImagesMessage

type OpenRouterImagesMessage struct {
	Role    string                        `json:"role"`
	Content []OpenRouterImagesContentPart `json:"content"`
}

type OpenRouterImagesPayload

type OpenRouterImagesPayload struct {
	Model      string                    `json:"model"`
	Messages   []OpenRouterImagesMessage `json:"messages"`
	Stream     bool                      `json:"stream"`
	Modalities []string                  `json:"modalities"`
}

func BuildOpenRouterImagesPayload

func BuildOpenRouterImagesPayload(model ImagesModel, imagesContext ImagesContext) OpenRouterImagesPayload

type OpenRouterImagesProvider

type OpenRouterImagesProvider struct {
	Client HTTPDoer
}

func NewOpenRouterImagesProvider

func NewOpenRouterImagesProvider(client HTTPDoer) OpenRouterImagesProvider

func (OpenRouterImagesProvider) GenerateImages

func (p OpenRouterImagesProvider) GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)

type OpenRouterImagesResponse

type OpenRouterImagesResponse struct {
	ID      string                   `json:"id"`
	Usage   *OpenRouterImagesUsage   `json:"usage,omitempty"`
	Choices []OpenRouterImagesChoice `json:"choices"`
}

type OpenRouterImagesUsage

type OpenRouterImagesUsage struct {
	PromptTokens        int                           `json:"prompt_tokens"`
	CompletionTokens    int                           `json:"completion_tokens"`
	PromptTokensDetails OpenRouterPromptTokensDetails `json:"prompt_tokens_details"`
}

type OpenRouterPromptTokensDetails

type OpenRouterPromptTokensDetails struct {
	CachedTokens     int `json:"cached_tokens"`
	CacheWriteTokens int `json:"cache_write_tokens"`
}

type Schema

type Schema struct {
	Type        any               `json:"type,omitempty"`
	Description string            `json:"description,omitempty"`
	Default     any               `json:"default,omitempty"`
	Properties  map[string]Schema `json:"properties,omitempty"`
	Required    []string          `json:"required,omitempty"`
	Items       *Schema           `json:"items,omitempty"`
	Enum        []any             `json:"enum,omitempty"`
}

func Boolean

func Boolean() Schema

func Integer

func Integer() Schema

func Null

func Null() Schema

func Number

func Number() Schema

func Object

func Object(properties map[string]Schema, required ...string) Schema

func String

func String() Schema

func StringEnum

func StringEnum(values ...string) Schema

func StringEnumWithOptions

func StringEnumWithOptions(values []string, options StringEnumOptions) Schema

func TypeUnion

func TypeUnion(types ...string) Schema

type SessionResourceCleanup

type SessionResourceCleanup func(sessionID string) error

type SessionResourceCleanupError

type SessionResourceCleanupError struct {
	Errors []error
}

func (SessionResourceCleanupError) Error

func (SessionResourceCleanupError) Unwrap

func (e SessionResourceCleanupError) Unwrap() []error

type SimpleStreamOptions

type SimpleStreamOptions = StreamOptions

type StreamOptions

type StreamOptions struct {
	Context          context.Context
	Temperature      *float64
	MaxTokens        int
	APIKey           string
	Transport        string
	CacheRetention   string
	SessionID        string
	Reasoning        string
	ThinkingBudgets  map[string]int
	Headers          map[string]string
	TimeoutMillis    int
	MaxRetries       int
	MaxRetryDelayMs  int
	Metadata         map[string]any
	OnPayload        func(payload any, model Model) (any, bool, error)
	OnResponseStatus func(status int, headers map[string]string, model Model) error
}

type StringEnumOptions

type StringEnumOptions struct {
	Description string
	Default     string
}

type Tool

type Tool struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Parameters  Schema `json:"parameters,omitempty"`
}

type Usage

type Usage struct {
	Input       int       `json:"input"`
	Output      int       `json:"output"`
	CacheRead   int       `json:"cacheRead"`
	CacheWrite  int       `json:"cacheWrite"`
	TotalTokens int       `json:"totalTokens"`
	Cost        UsageCost `json:"cost"`
}

func EmptyUsage

func EmptyUsage() Usage

func ParseGoogleUsage

func ParseGoogleUsage(raw GoogleUsageMetadata, model Model) Usage

func ParseMistralUsage

func ParseMistralUsage(raw MistralUsage, model Model) Usage

func ParseOpenAIChatUsage

func ParseOpenAIChatUsage(raw OpenAIChatUsage, model Model) Usage

func ParseOpenAIResponsesUsage

func ParseOpenAIResponsesUsage(raw OpenAIResponsesUsage, model Model) Usage

func ParseOpenRouterImagesUsage

func ParseOpenRouterImagesUsage(raw OpenRouterImagesUsage, model ImagesModel) Usage

type UsageCost

type UsageCost struct {
	Input      float64 `json:"input"`
	Output     float64 `json:"output"`
	CacheRead  float64 `json:"cacheRead"`
	CacheWrite float64 `json:"cacheWrite"`
	Total      float64 `json:"total"`
}

func CalculateCost

func CalculateCost(model Model, usage Usage) UsageCost

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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