Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v0.19.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseOpenAICodexWebSocketSessions

func CloseOpenAICodexWebSocketSessions(sessionID ...string)

func StreamAnthropicMessagesWithOptions

func StreamAnthropicMessagesWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *AnthropicMessagesOptions,
) (ai.AssistantMessageEventStream, error)

func StreamAzureOpenAIResponsesWithOptions

func StreamAzureOpenAIResponsesWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *AzureOpenAIResponsesOptions,
) (ai.AssistantMessageEventStream, error)

func StreamBedrockConverseWithOptions

func StreamBedrockConverseWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *BedrockConverseStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamGoogleGenerativeAIWithOptions

func StreamGoogleGenerativeAIWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *GoogleOptions,
) (ai.AssistantMessageEventStream, error)

func StreamGoogleVertexWithOptions

func StreamGoogleVertexWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *GoogleVertexOptions,
) (ai.AssistantMessageEventStream, error)

func StreamMistralConversationsWithOptions

func StreamMistralConversationsWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *MistralConversationsOptions,
) (ai.AssistantMessageEventStream, error)

func StreamOpenAICodexResponsesWithOptions

func StreamOpenAICodexResponsesWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *OpenAICodexResponsesOptions,
) (ai.AssistantMessageEventStream, error)

func StreamOpenAICompletionsWithOptions

func StreamOpenAICompletionsWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *OpenAICompletionsOptions,
) (ai.AssistantMessageEventStream, error)

StreamOpenAICompletionsWithOptions exposes Chat Completions-specific tool choice and reasoning-effort controls.

func StreamOpenAIResponsesWithOptions

func StreamOpenAIResponsesWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *OpenAIResponsesOptions,
) (ai.AssistantMessageEventStream, error)

func StreamPiMessagesWithOptions

func StreamPiMessagesWithOptions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *PiMessagesOptions,
) (ai.AssistantMessageEventStream, error)

StreamPiMessagesWithOptions streams serialized assistant-message events from a conforming gateway.

func StreamSimpleAnthropicMessages

func StreamSimpleAnthropicMessages(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamSimpleAzureOpenAIResponses

func StreamSimpleAzureOpenAIResponses(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamSimpleGoogleGenerativeAI

func StreamSimpleGoogleGenerativeAI(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamSimpleGoogleVertex

func StreamSimpleGoogleVertex(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamSimpleMistralConversations

func StreamSimpleMistralConversations(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamSimpleOpenAICodexResponses

func StreamSimpleOpenAICodexResponses(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamSimpleOpenAICompletions

func StreamSimpleOpenAICompletions(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

StreamSimpleOpenAICompletions applies the provider-neutral context and options before entering the specialized Chat Completions path.

func StreamSimpleOpenAIResponses

func StreamSimpleOpenAIResponses(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

func StreamSimplePiMessages

func StreamSimplePiMessages(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

StreamSimplePiMessages forwards the unified reasoning option without inventing provider defaults that upstream does not send.

Types

type AnthropicEffort

type AnthropicEffort string
const (
	AnthropicEffortLow    AnthropicEffort = "low"
	AnthropicEffortMedium AnthropicEffort = "medium"
	AnthropicEffortHigh   AnthropicEffort = "high"
	AnthropicEffortXHigh  AnthropicEffort = "xhigh"
	AnthropicEffortMax    AnthropicEffort = "max"
)

type AnthropicMessageParam

type AnthropicMessageParam struct {
	Role         string                 `json:"role"`
	Content      any                    `json:"content"`
	OutputConfig *anthropicOutputConfig `json:"output_config,omitempty"`
}

type AnthropicMessagesOptions

type AnthropicMessagesOptions struct {
	ai.StreamOptions
	ThinkingEnabled      *bool                     `json:"thinkingEnabled,omitempty"`
	ThinkingBudgetTokens *float64                  `json:"thinkingBudgetTokens,omitempty"`
	Effort               *AnthropicEffort          `json:"effort,omitempty"`
	ThinkingDisplay      *AnthropicThinkingDisplay `json:"thinkingDisplay,omitempty"`
	InterleavedThinking  *bool                     `json:"interleavedThinking,omitempty"`
	ToolChoice           *AnthropicToolChoice      `json:"toolChoice,omitempty"`
}

type AnthropicMessagesPayload

type AnthropicMessagesPayload struct {
	Model        string                  `json:"model"`
	Messages     []AnthropicMessageParam `json:"messages"`
	MaxTokens    float64                 `json:"max_tokens"`
	Stream       bool                    `json:"stream"`
	Betas        []string                `json:"betas,omitempty"`
	System       []anthropicTextBlock    `json:"system,omitempty"`
	Temperature  *float64                `json:"temperature,omitempty"`
	Tools        []anthropicToolParam    `json:"tools,omitempty"`
	Thinking     any                     `json:"thinking,omitempty"`
	OutputConfig *anthropicOutputConfig  `json:"output_config,omitempty"`
	Metadata     *anthropicMetadata      `json:"metadata,omitempty"`
	ToolChoice   *AnthropicToolChoice    `json:"tool_choice,omitempty"`
	Fallbacks    []anthropicFallback     `json:"fallbacks,omitempty"`
}

type AnthropicThinkingDisplay

type AnthropicThinkingDisplay string
const (
	AnthropicThinkingSummarized AnthropicThinkingDisplay = "summarized"
	AnthropicThinkingOmitted    AnthropicThinkingDisplay = "omitted"
)

type AnthropicToolChoice

type AnthropicToolChoice struct {
	Type string  `json:"type"`
	Name *string `json:"name,omitempty"`
}

func (*AnthropicToolChoice) UnmarshalJSON

func (choice *AnthropicToolChoice) UnmarshalJSON(data []byte) error

type AzureOpenAIResponsesOptions

type AzureOpenAIResponsesOptions struct {
	ai.StreamOptions
	ReasoningEffort     *string `json:"reasoningEffort,omitempty"`
	ReasoningSummary    *string `json:"reasoningSummary,omitempty"`
	ToolChoice          any     `json:"toolChoice,omitempty"`
	AzureAPIVersion     *string `json:"azureApiVersion,omitempty"`
	AzureResourceName   *string `json:"azureResourceName,omitempty"`
	AzureBaseURL        *string `json:"azureBaseUrl,omitempty"`
	AzureDeploymentName *string `json:"azureDeploymentName,omitempty"`
}

type BedrockBackend added in v0.10.0

type BedrockBackend struct {
	NewTransport func(context.Context, BedrockTransportConfig) (BedrockTransport, error)
	// HTTPErrorBodies returns the HTTP error responses the SDK attached to err,
	// most specific first; the adapter reads at most maxProviderErrorBodyChars+1 bytes of each.
	HTTPErrorBodies func(error) []BedrockHTTPErrorBody
	// HTTPErrorMetadata returns the HTTP status and service request id the SDK attached to err.
	HTTPErrorMetadata func(error) (status int, requestID string, ok bool)
}

BedrockBackend is the SDK side of Bedrock ConverseStream. Keeping it behind this value lets an assembly that never selects Bedrock skip the AWS SDK.

type BedrockCachePoint

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

type BedrockContentBlock

type BedrockContentBlock struct {
	Text             *string                  `json:"text,omitempty"`
	Image            *BedrockImageBlock       `json:"image,omitempty"`
	ToolUse          *BedrockToolUseBlock     `json:"toolUse,omitempty"`
	ToolResult       *BedrockToolResultBlock  `json:"toolResult,omitempty"`
	ReasoningContent *BedrockReasoningContent `json:"reasoningContent,omitempty"`
	CachePoint       *BedrockCachePoint       `json:"cachePoint,omitempty"`
}

type BedrockConverseStreamOptions

type BedrockConverseStreamOptions struct {
	ai.StreamOptions
	Region              string                  `json:"region,omitempty"`
	Profile             string                  `json:"profile,omitempty"`
	ToolChoice          *BedrockToolChoice      `json:"toolChoice,omitempty"`
	Reasoning           *ai.ThinkingLevel       `json:"reasoning,omitempty"`
	ThinkingBudgets     *ai.ThinkingBudgets     `json:"thinkingBudgets,omitempty"`
	InterleavedThinking *bool                   `json:"interleavedThinking,omitempty"`
	ThinkingDisplay     *BedrockThinkingDisplay `json:"thinkingDisplay,omitempty"`
	RequestMetadata     map[string]string       `json:"requestMetadata,omitempty"`
	BearerToken         string                  `json:"bearerToken,omitempty"`

	// Backend opens the SDK transport; ai/api/bedrock supplies the AWS one.
	Backend *BedrockBackend `json:"-"`
}

type BedrockConverseStreamPayload

type BedrockConverseStreamPayload struct {
	ModelID                      string                      `json:"modelId"`
	Messages                     []BedrockMessage            `json:"messages"`
	System                       []BedrockSystemContentBlock `json:"system,omitempty"`
	InferenceConfig              BedrockInferenceConfig      `json:"inferenceConfig"`
	ToolConfig                   *BedrockToolConfiguration   `json:"toolConfig,omitempty"`
	AdditionalModelRequestFields map[string]any              `json:"additionalModelRequestFields,omitempty"`
	RequestMetadata              map[string]string           `json:"requestMetadata,omitempty"`

	// Extra retains hook-injected top-level members without a typed field
	// (guardrailConfig, performanceConfig, ...) so they reach the SDK input,
	// mirroring upstream's verbatim ConverseStreamCommand pass-through. (OT-M7)
	Extra map[string]json.RawMessage `json:"-"`
	// contains filtered or unexported fields
}

BedrockConverseStreamPayload mirrors the public ConverseStream command input. The AWS SDK stays behind BedrockBackend while payload hooks retain a provider-shaped value that callers can inspect and replace.

func (*BedrockConverseStreamPayload) InferenceConfigOmitted added in v0.10.0

func (payload *BedrockConverseStreamPayload) InferenceConfigOmitted() bool

InferenceConfigOmitted reports that a payload hook deleted inferenceConfig, which the SDK input must then omit rather than send empty.

type BedrockCredentials added in v0.10.0

type BedrockCredentials struct {
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
}

type BedrockHTTPErrorBody added in v0.10.0

type BedrockHTTPErrorBody struct {
	Status int
	Body   io.Reader
}

type BedrockImageBlock

type BedrockImageBlock struct {
	Format string             `json:"format"`
	Source BedrockImageSource `json:"source"`
}

type BedrockImageSource

type BedrockImageSource struct {
	Bytes string `json:"bytes"`
}

type BedrockInferenceConfig

type BedrockInferenceConfig struct {
	MaxTokens     *float64 `json:"maxTokens,omitempty"`
	Temperature   *float64 `json:"temperature,omitempty"`
	StopSequences []string `json:"stopSequences,omitempty"`
	TopP          *float64 `json:"topP,omitempty"`
}

type BedrockMessage

type BedrockMessage struct {
	Role    string                `json:"role"`
	Content []BedrockContentBlock `json:"content"`
}

type BedrockReasoningContent

type BedrockReasoningContent struct {
	ReasoningText   *BedrockReasoningText `json:"reasoningText,omitempty"`
	RedactedContent []byte                `json:"redactedContent,omitempty"`
}

type BedrockReasoningText

type BedrockReasoningText struct {
	Text      string  `json:"text"`
	Signature *string `json:"signature,omitempty"`
}

type BedrockResponse added in v0.10.0

type BedrockResponse interface {
	Status() int
	RequestID() string
	Next(context.Context) (BedrockStreamItem, bool)
	Close() error
	Err() error
}

type BedrockStreamItem added in v0.10.0

type BedrockStreamItem struct {
	Kind                BedrockStreamItemKind
	Role                string
	ContentBlockIndex   int
	ToolUseID           string
	ToolName            string
	Text                *string
	ToolInput           *string
	ReasoningText       *string
	ReasoningSignature  *string
	RedactedContent     []byte
	StopReason          string
	InputTokens         int64
	OutputTokens        int64
	CacheReadTokens     int64
	CacheWriteTokens    int64
	CacheWrite1hTokens  int64
	CacheDetailsPresent bool
	TotalTokens         int64
}

type BedrockStreamItemKind added in v0.10.0

type BedrockStreamItemKind uint8
const (
	BedrockItemMessageStart BedrockStreamItemKind = iota + 1
	BedrockItemContentStart
	BedrockItemContentDelta
	BedrockItemContentStop
	BedrockItemMessageStop
	BedrockItemMetadata
)

type BedrockSystemContentBlock

type BedrockSystemContentBlock struct {
	Text       *string            `json:"text,omitempty"`
	CachePoint *BedrockCachePoint `json:"cachePoint,omitempty"`
}

type BedrockThinkingDisplay

type BedrockThinkingDisplay string
const (
	BedrockThinkingSummarized BedrockThinkingDisplay = "summarized"
	BedrockThinkingOmitted    BedrockThinkingDisplay = "omitted"
)

type BedrockTool

type BedrockTool struct {
	ToolSpec BedrockToolSpecification `json:"toolSpec"`
}

type BedrockToolChoice

type BedrockToolChoice struct {
	Type string `json:"type"`
	Name string `json:"name,omitempty"`
}

func (*BedrockToolChoice) UnmarshalJSON

func (choice *BedrockToolChoice) UnmarshalJSON(data []byte) error

type BedrockToolConfiguration

type BedrockToolConfiguration struct {
	Tools      []BedrockTool `json:"tools"`
	ToolChoice any           `json:"toolChoice,omitempty"`
}

type BedrockToolInputSchema

type BedrockToolInputSchema struct {
	JSON jsonschema.Schema `json:"json"`
}

type BedrockToolResultBlock

type BedrockToolResultBlock struct {
	ToolUseID string                          `json:"toolUseId"`
	Content   []BedrockToolResultContentBlock `json:"content"`
	Status    string                          `json:"status"`
}

type BedrockToolResultContentBlock

type BedrockToolResultContentBlock struct {
	Text  *string            `json:"text,omitempty"`
	Image *BedrockImageBlock `json:"image,omitempty"`
}

type BedrockToolSpecification

type BedrockToolSpecification struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	InputSchema BedrockToolInputSchema `json:"inputSchema"`
	Strict      *bool                  `json:"strict,omitempty"`
}

type BedrockToolUseBlock

type BedrockToolUseBlock struct {
	ToolUseID string `json:"toolUseId"`
	Name      string `json:"name"`
	Input     any    `json:"input"`
}

type BedrockTransport added in v0.10.0

type BedrockTransport interface {
	Send(context.Context, *BedrockConverseStreamPayload) (BedrockResponse, error)
}

type BedrockTransportConfig added in v0.10.0

type BedrockTransportConfig struct {
	// Endpoint pins the service endpoint; nil lets the SDK resolve it from Region.
	Endpoint *string
	// Region is empty when the SDK's shared-config chain decides.
	Region  string
	Profile string
	// SkipAuth signs with Credentials (dummy values) and disables bearer auth.
	SkipAuth    bool
	Credentials *BedrockCredentials
	BearerToken string
	Proxy       *url.URL
	ForceHTTP1  bool
	// UseFIPS and UseDualStack pick those endpoints, as AWS_USE_FIPS_ENDPOINT
	// and AWS_USE_DUALSTACK_ENDPOINT ask.
	UseFIPS, UseDualStack bool
	// Headers are the caller headers to send; reserved AWS names are already removed.
	Headers map[string]string
}

BedrockTransportConfig is the SDK-independent client configuration resolved for one ConverseStream request.

type GoogleContent

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

type GoogleFunctionCall

type GoogleFunctionCall struct {
	Name string          `json:"name"`
	Args json.RawMessage `json:"args"`
	ID   string          `json:"id,omitempty"`
}

type GoogleFunctionCallingConfig

type GoogleFunctionCallingConfig struct {
	AllowedFunctionNames []string        `json:"allowedFunctionNames,omitempty"`
	Mode                 string          `json:"mode,omitempty"`
	StreamArguments      json.RawMessage `json:"streamFunctionCallArguments,omitempty"`
}

type GoogleFunctionDeclaration

type GoogleFunctionDeclaration struct {
	Name                 string            `json:"name"`
	Description          string            `json:"description"`
	ParametersJSONSchema jsonschema.Schema `json:"parametersJsonSchema"`
}

type GoogleFunctionResponse

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

type GoogleFunctionResponseInlineData

type GoogleFunctionResponseInlineData struct {
	MimeType string `json:"mimeType"`
	Data     string `json:"data"`
}

type GoogleFunctionResponsePart

type GoogleFunctionResponsePart struct {
	InlineData *GoogleFunctionResponseInlineData `json:"inlineData,omitempty"`
}

type GoogleFunctionResponseValue

type GoogleFunctionResponseValue struct {
	Output *string `json:"output,omitempty"`
	Error  *string `json:"error,omitempty"`
}

type GoogleGenerateContentConfig

type GoogleGenerateContentConfig struct {
	Temperature                *float64              `json:"temperature,omitempty"`
	TopP                       *float64              `json:"topP,omitempty"`
	TopK                       *float64              `json:"topK,omitempty"`
	CandidateCount             *int64                `json:"candidateCount,omitempty"`
	MaxOutputTokens            *float64              `json:"maxOutputTokens,omitempty"`
	StopSequences              []string              `json:"stopSequences,omitempty"`
	ResponseLogprobs           *bool                 `json:"responseLogprobs,omitempty"`
	Logprobs                   *int64                `json:"logprobs,omitempty"`
	PresencePenalty            *float64              `json:"presencePenalty,omitempty"`
	FrequencyPenalty           *float64              `json:"frequencyPenalty,omitempty"`
	Seed                       *int64                `json:"seed,omitempty"`
	ResponseMimeType           *string               `json:"responseMimeType,omitempty"`
	ResponseSchema             json.RawMessage       `json:"responseSchema,omitempty"`
	ResponseJSONSchema         json.RawMessage       `json:"responseJsonSchema,omitempty"`
	SafetySettings             []GoogleSafetySetting `json:"safetySettings,omitempty"`
	SystemInstruction          json.RawMessage       `json:"systemInstruction,omitempty"`
	Tools                      []GoogleTool          `json:"tools,omitempty"`
	ToolConfig                 *GoogleToolConfig     `json:"toolConfig,omitempty"`
	CachedContent              *string               `json:"cachedContent,omitempty"`
	ResponseModalities         []string              `json:"responseModalities,omitempty"`
	MediaResolution            *string               `json:"mediaResolution,omitempty"`
	SpeechConfig               json.RawMessage       `json:"speechConfig,omitempty"`
	ThinkingConfig             *GoogleThinkingConfig `json:"thinkingConfig,omitempty"`
	ImageConfig                json.RawMessage       `json:"imageConfig,omitempty"`
	EnableEnhancedCivicAnswers *bool                 `json:"enableEnhancedCivicAnswers,omitempty"`
	ServiceTier                *string               `json:"serviceTier,omitempty"`
}

type GoogleGenerateContentParameters

type GoogleGenerateContentParameters struct {
	Model    string                      `json:"model"`
	Contents []GoogleContent             `json:"contents"`
	Config   GoogleGenerateContentConfig `json:"config"`
}

type GoogleInlineData

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

type GoogleOptions

type GoogleOptions struct {
	ai.StreamOptions
	ToolChoice GoogleToolChoice       `json:"toolChoice,omitempty"`
	Thinking   *GoogleThinkingOptions `json:"thinking,omitempty"`
}

type GooglePart

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

type GoogleSafetySetting

type GoogleSafetySetting struct {
	Category  string `json:"category"`
	Threshold string `json:"threshold"`
}

type GoogleThinkingConfig

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

type GoogleThinkingLevel

type GoogleThinkingLevel string
const (
	GoogleThinkingUnspecified GoogleThinkingLevel = "THINKING_LEVEL_UNSPECIFIED"
	GoogleThinkingMinimal     GoogleThinkingLevel = "MINIMAL"
	GoogleThinkingLow         GoogleThinkingLevel = "LOW"
	GoogleThinkingMedium      GoogleThinkingLevel = "MEDIUM"
	GoogleThinkingHigh        GoogleThinkingLevel = "HIGH"
)

type GoogleThinkingOptions

type GoogleThinkingOptions struct {
	Enabled      bool                 `json:"enabled"`
	BudgetTokens *int64               `json:"budgetTokens,omitempty"`
	Level        *GoogleThinkingLevel `json:"level,omitempty"`
}

type GoogleTool

type GoogleTool struct {
	ComputerUse           json.RawMessage             `json:"computerUse,omitempty"`
	FileSearch            json.RawMessage             `json:"fileSearch,omitempty"`
	GoogleSearch          json.RawMessage             `json:"googleSearch,omitempty"`
	GoogleMaps            json.RawMessage             `json:"googleMaps,omitempty"`
	CodeExecution         json.RawMessage             `json:"codeExecution,omitempty"`
	FunctionDeclarations  []GoogleFunctionDeclaration `json:"functionDeclarations,omitempty"`
	GoogleSearchRetrieval json.RawMessage             `json:"googleSearchRetrieval,omitempty"`
	URLContext            json.RawMessage             `json:"urlContext,omitempty"`
	MCPServers            json.RawMessage             `json:"mcpServers,omitempty"`
}

type GoogleToolChoice

type GoogleToolChoice string
const (
	GoogleToolChoiceAuto GoogleToolChoice = "auto"
	GoogleToolChoiceNone GoogleToolChoice = "none"
	GoogleToolChoiceAny  GoogleToolChoice = "any"
)

type GoogleToolConfig

type GoogleToolConfig struct {
	RetrievalConfig                  json.RawMessage              `json:"retrievalConfig,omitempty"`
	FunctionCallingConfig            *GoogleFunctionCallingConfig `json:"functionCallingConfig,omitempty"`
	IncludeServerSideToolInvocations *bool                        `json:"includeServerSideToolInvocations,omitempty"`
}

type GoogleVertexOptions

type GoogleVertexOptions struct {
	ai.StreamOptions
	ToolChoice GoogleToolChoice       `json:"toolChoice,omitempty"`
	Thinking   *GoogleThinkingOptions `json:"thinking,omitempty"`
	Project    string                 `json:"project,omitempty"`
	Location   string                 `json:"location,omitempty"`
}

type MistralChatPayload

type MistralChatPayload = MistralConversationsPayload

type MistralConversationFunction

type MistralConversationFunction struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Parameters  jsonschema.Schema `json:"parameters"`
	Strict      bool              `json:"strict"`
}

type MistralConversationTool

type MistralConversationTool struct {
	Type     string                      `json:"type"`
	Function MistralConversationFunction `json:"function"`
}

type MistralConversationsOptions

type MistralConversationsOptions struct {
	ai.StreamOptions
	ToolChoice      any     `json:"toolChoice,omitempty"`
	PromptMode      *string `json:"promptMode,omitempty"`
	ReasoningEffort *string `json:"reasoningEffort,omitempty"`
}

type MistralConversationsPayload

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

MistralConversationsPayload is the mutable request value passed to PayloadHook. Member order matches upstream's native wire payload: the literal keys first, then the camelCase-to-snake_case remaps in their remap-table order.

type OpenAICodexResponsesOptions

type OpenAICodexResponsesOptions struct {
	ai.StreamOptions
	ReasoningEffort  *string `json:"reasoningEffort,omitempty"`
	ReasoningSummary *string `json:"reasoningSummary,omitempty"`
	ServiceTier      *string `json:"serviceTier,omitempty"`
	TextVerbosity    *string `json:"textVerbosity,omitempty"`
	ToolChoice       *string `json:"toolChoice,omitempty"`
}

type OpenAICodexResponsesPayload

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

type OpenAICompletionsOptions

type OpenAICompletionsOptions struct {
	ai.StreamOptions
	ToolChoice      any
	ReasoningEffort *ai.ThinkingLevel
	ThinkingBudgets *ai.ThinkingBudgets
}

OpenAICompletionsOptions contains the Chat Completions-only request options.

type OpenAIPromptCacheOptions

type OpenAIPromptCacheOptions struct {
	Mode string `json:"mode,omitempty"`
	TTL  string `json:"ttl,omitempty"`
}

type OpenAIReasoningParams

type OpenAIReasoningParams struct {
	Effort  string  `json:"effort"`
	Summary *string `json:"summary,omitempty"`
}

type OpenAIResponsesGrammarFormat

type OpenAIResponsesGrammarFormat struct {
	Type       string `json:"type"`
	Syntax     string `json:"syntax"`
	Definition string `json:"definition"`
}

type OpenAIResponsesOptions

type OpenAIResponsesOptions struct {
	ai.StreamOptions
	ReasoningEffort  *string `json:"reasoningEffort,omitempty"`
	ReasoningSummary *string `json:"reasoningSummary,omitempty"`
	ServiceTier      *string `json:"serviceTier,omitempty"`
	ToolChoice       any     `json:"toolChoice,omitempty"`
}

type OpenAIResponsesPayload

type OpenAIResponsesPayload struct {
	Model                string                    `json:"model"`
	Input                []any                     `json:"input"`
	Stream               bool                      `json:"stream"`
	PromptCacheKey       *string                   `json:"prompt_cache_key,omitempty"`
	PromptCacheRetention *string                   `json:"prompt_cache_retention,omitempty"`
	PromptCacheOptions   *OpenAIPromptCacheOptions `json:"prompt_cache_options,omitempty"`
	Store                bool                      `json:"store"`
	MaxOutputTokens      *float64                  `json:"max_output_tokens,omitempty"`
	Temperature          *float64                  `json:"temperature,omitempty"`
	ServiceTier          *string                   `json:"service_tier,omitempty"`
	Tools                []OpenAIResponsesTool     `json:"tools,omitempty"`
	ToolChoice           any                       `json:"tool_choice,omitempty"`
	Reasoning            *OpenAIReasoningParams    `json:"reasoning,omitempty"`
	Include              []string                  `json:"include,omitempty"`
	// Extra keys (samplingParams) are assigned last, overriding named fields.
	Extra map[string]any `json:"-"`
}

OpenAIResponsesPayload is the mutable request value passed to PayloadHook.

func (OpenAIResponsesPayload) MarshalJSON added in v0.14.0

func (payload OpenAIResponsesPayload) MarshalJSON() ([]byte, error)

type OpenAIResponsesTool

type OpenAIResponsesTool struct {
	Type         string                        `json:"type"`
	Name         string                        `json:"name"`
	Description  string                        `json:"description"`
	Parameters   jsonschema.Schema             `json:"parameters,omitempty"`
	Strict       *bool                         `json:"-"`
	StrictNull   bool                          `json:"-"`
	Format       *OpenAIResponsesGrammarFormat `json:"format,omitempty"`
	DeferLoading *bool                         `json:"defer_loading,omitempty"`
}

func (OpenAIResponsesTool) MarshalJSON

func (tool OpenAIResponsesTool) MarshalJSON() ([]byte, error)

type PiMessagesOptions

type PiMessagesOptions struct {
	ai.StreamOptions
	Reasoning  *ai.ThinkingLevel    `json:"reasoning,omitempty"`
	ToolChoice PiMessagesToolChoice `json:"toolChoice,omitempty"`
	Debug      bool                 `json:"debug,omitempty"`
}

PiMessagesOptions contains the gateway-specific options sent through the pi-messages wire shape.

func (*PiMessagesOptions) UnmarshalJSON

func (options *PiMessagesOptions) UnmarshalJSON(data []byte) error

type PiMessagesPayload

type PiMessagesPayload struct {
	Model   string                   `json:"model"`
	Context ai.Context               `json:"context"`
	Options PiMessagesPayloadOptions `json:"options"`
}

PiMessagesPayload is the request body accepted by a pi-messages backend.

type PiMessagesPayloadOptions

type PiMessagesPayloadOptions struct {
	Temperature    *float64             `json:"temperature,omitempty"`
	MaxTokens      *float64             `json:"maxTokens,omitempty"`
	Reasoning      *ai.ThinkingLevel    `json:"reasoning,omitempty"`
	CacheRetention *ai.CacheRetention   `json:"cacheRetention,omitempty"`
	SessionID      *string              `json:"sessionId,omitempty"`
	ToolChoice     PiMessagesToolChoice `json:"toolChoice,omitempty"`
}

PiMessagesPayloadOptions is ordered to match upstream JSON serialization.

type PiMessagesResponseError

type PiMessagesResponseError struct {
	Message           string
	Code              *string
	DiagnosticDetails json.RawMessage
}

PiMessagesResponseError retains the structured diagnostics returned for a non-successful gateway response.

func (*PiMessagesResponseError) Error

func (err *PiMessagesResponseError) Error() string

type PiMessagesRewriteImpact

type PiMessagesRewriteImpact struct {
	PolicyID            string `json:"policyId"`
	PolicyVersion       int64  `json:"policyVersion"`
	Changed             bool   `json:"changed"`
	TokenCountChange    int64  `json:"tokenCountChange"`
	MessageCountChange  int64  `json:"messageCountChange"`
	SystemPromptChanged bool   `json:"systemPromptChanged"`
}

PiMessagesRewriteImpact records a server-side context rewrite reported by the gateway.

type PiMessagesToolChoice

type PiMessagesToolChoice any

PiMessagesToolChoice is either auto/none/required or the upstream function selector object.

type Provider added in v0.10.0

type Provider struct {
	API          ai.API
	StreamSimple StreamSimpleFunc
}

Provider binds one API family to its wire adapter. A family's adapter code links into a binary only when an assembly selects its Provider.

func AnthropicMessages added in v0.10.0

func AnthropicMessages() Provider

func AzureOpenAIResponses added in v0.10.0

func AzureOpenAIResponses() Provider

func BedrockConverse added in v0.10.0

func BedrockConverse(backend BedrockBackend) Provider

BedrockConverse registers the Bedrock ConverseStream API on backend.

func GoogleGenerativeAI added in v0.10.0

func GoogleGenerativeAI() Provider

func GoogleVertex added in v0.10.0

func GoogleVertex() Provider

func MistralConversations added in v0.10.0

func MistralConversations() Provider

func OpenAICodexResponses added in v0.10.0

func OpenAICodexResponses() Provider

func OpenAICompletions added in v0.10.0

func OpenAICompletions() Provider

func OpenAIResponses added in v0.10.0

func OpenAIResponses() Provider

func PiMessages added in v0.10.0

func PiMessages() Provider

type Registry added in v0.10.0

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

Registry dispatches models to the API families an assembly selected. ai/api/all holds the registry with every family.

func NewRegistry added in v0.10.0

func NewRegistry(providers ...Provider) *Registry

NewRegistry registers providers in order; a later Provider for the same API replaces an earlier one.

func (*Registry) CompleteSimple added in v0.10.0

func (registry *Registry) CompleteSimple(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (*ai.AssistantMessage, error)

CompleteSimple collects StreamSimple into its terminal assistant message.

func (*Registry) StreamSimple added in v0.10.0

func (registry *Registry) StreamSimple(
	ctx context.Context,
	model *ai.Model,
	requestContext ai.Context,
	options *ai.SimpleStreamOptions,
) (ai.AssistantMessageEventStream, error)

StreamSimple dispatches a model to its registered wire-shape adapter.

type StreamSimpleFunc added in v0.10.0

StreamSimpleFunc streams one request through a provider wire shape.

Directories

Path Synopsis
Package all is the default provider registry: the CLI and SDK sessions that pass no stream function dispatch through it.
Package all is the default provider registry: the CLI and SDK sessions that pass no stream function dispatch through it.
Package bedrock is Orb's Bedrock ConverseStream transport: the request, signed with SigV4 or a bearer token, goes over net/http, and the response is read from the AWS event stream framing.
Package bedrock is Orb's Bedrock ConverseStream transport: the request, signed with SigV4 or a bearer token, goes over net/http, and the response is read from the AWS event stream framing.

Jump to

Keyboard shortcuts

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