request

package
v0.260430.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MPL-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnthropicParamOpt

func AnthropicParamOpt[T comparable](value T) param.Opt[T]

func CleanupOpenaiFields

func CleanupOpenaiFields(req *openai.ChatCompletionNewParams)

CleanupOpenaiFields removes temporary fields used during transformation Note: This should be called AFTER vendor transforms have processed x_thinking

func ConvertAnthropicBetaToGoogleRequest

func ConvertAnthropicBetaToGoogleRequest(anthropicReq *anthropic.BetaMessageNewParams, defaultMaxTokens int64) (string, []*genai.Content, *genai.GenerateContentConfig)

ConvertAnthropicBetaToGoogleRequest converts Anthropic request to Google format

func ConvertAnthropicBetaToGoogleToolChoice

func ConvertAnthropicBetaToGoogleToolChoice(tc *anthropic.BetaToolChoiceUnionParam) *genai.ToolConfig

func ConvertAnthropicBetaToGoogleTools

func ConvertAnthropicBetaToGoogleTools(tools []anthropic.BetaToolUnionParam) []*genai.FunctionDeclaration

func ConvertAnthropicBetaToOpenAIRequest

func ConvertAnthropicBetaToOpenAIRequest(anthropicReq *anthropic.BetaMessageNewParams, compatible bool, isStreaming bool, disableStreamUsage bool) (*openai.ChatCompletionNewParams, *protocol.OpenAIConfig)

ConvertAnthropicBetaToOpenAIRequest converts Anthropic beta request to OpenAI format Returns the OpenAI request and a config object with metadata for provider transforms

func ConvertAnthropicBetaToResponsesRequest

func ConvertAnthropicBetaToResponsesRequest(anthropicReq *anthropic.BetaMessageNewParams) responses.ResponseNewParams

ConvertAnthropicBetaToResponsesRequest converts Anthropic beta request to OpenAI Responses API format The Responses API has a different structure than Chat Completions

func ConvertAnthropicBetaToolChoiceToOpenAI

func ConvertAnthropicBetaToolChoiceToOpenAI(tc *anthropic.BetaToolChoiceUnionParam) openai.ChatCompletionToolChoiceOptionUnionParam

ConvertAnthropicBetaToolChoiceToOpenAI converts Anthropic beta tool_choice to OpenAI format

func ConvertAnthropicBetaToolChoiceToResponses

func ConvertAnthropicBetaToolChoiceToResponses(tc *anthropic.BetaToolChoiceUnionParam) responses.ResponseNewParamsToolChoiceUnion

ConvertAnthropicBetaToolChoiceToResponses converts Anthropic beta tool_choice to Responses API format

func ConvertAnthropicBetaToolsToOpenAI

func ConvertAnthropicBetaToolsToOpenAI(tools []anthropic.BetaToolUnionParam) []openai.ChatCompletionToolUnionParam

ConvertAnthropicBetaToolsToOpenAI converts Anthropic beta tools to OpenAI format

func ConvertAnthropicBetaToolsToOpenAIWithTransformedSchema

func ConvertAnthropicBetaToolsToOpenAIWithTransformedSchema(tools []anthropic.BetaToolUnionParam) []openai.ChatCompletionToolUnionParam

ConvertAnthropicBetaToolsToOpenAIWithTransformedSchema is an alias for ConvertAnthropicBetaToolsToOpenAI Schema transformation is handled by provider-specific transforms

func ConvertAnthropicBetaToolsToResponses

func ConvertAnthropicBetaToolsToResponses(tools []anthropic.BetaToolUnionParam) []responses.ToolUnionParam

ConvertAnthropicBetaToolsToResponses converts Anthropic beta tools to Responses API format

func ConvertAnthropicToGoogleRequest

func ConvertAnthropicToGoogleRequest(anthropicReq *anthropic.MessageNewParams, defaultMaxTokens int64) (string, []*genai.Content, *genai.GenerateContentConfig)

ConvertAnthropicToGoogleRequest converts Anthropic request to Google format

func ConvertAnthropicToGoogleToolChoice

func ConvertAnthropicToGoogleToolChoice(tc *anthropic.ToolChoiceUnionParam) *genai.ToolConfig

func ConvertAnthropicToGoogleTools

func ConvertAnthropicToGoogleTools(tools []anthropic.ToolUnionParam) []*genai.FunctionDeclaration

func ConvertAnthropicToOpenAIRequest

func ConvertAnthropicToOpenAIRequest(anthropicReq *anthropic.MessageNewParams, compatible bool, isStreaming bool, disableStreamUsage bool) (*openai.ChatCompletionNewParams, *protocol.OpenAIConfig)

ConvertAnthropicToOpenAIRequest converts Anthropic request to OpenAI format Returns the OpenAI request and a config object with metadata for provider transforms

func ConvertAnthropicToolChoiceToOpenAI

func ConvertAnthropicToolChoiceToOpenAI(tc *anthropic.ToolChoiceUnionParam) openai.ChatCompletionToolChoiceOptionUnionParam

ConvertAnthropicToolChoiceToOpenAI converts Anthropic tool_choice to OpenAI format

func ConvertAnthropicToolsToOpenAI

func ConvertAnthropicToolsToOpenAI(tools []anthropic.ToolUnionParam) []openai.ChatCompletionToolUnionParam

ConvertAnthropicToolsToOpenAI converts Anthropic tools to OpenAI format

func ConvertAnthropicToolsToOpenAIWithTransformedSchema

func ConvertAnthropicToolsToOpenAIWithTransformedSchema(tools []anthropic.ToolUnionParam) []openai.ChatCompletionToolUnionParam

ConvertAnthropicToolsToOpenAIWithTransformedSchema is an alias for ConvertAnthropicToolsToOpenAI Schema transformation is handled by provider-specific transforms

func ConvertAnthropicV1ToResponsesRequest

func ConvertAnthropicV1ToResponsesRequest(anthropicReq *anthropic.MessageNewParams) responses.ResponseNewParams

ConvertAnthropicV1ToResponsesRequest converts Anthropic v1 request to OpenAI Responses API format The Responses API has a different structure than Chat Completions

func ConvertAnthropicV1ToolChoiceToResponses

func ConvertAnthropicV1ToolChoiceToResponses(tc *anthropic.ToolChoiceUnionParam) responses.ResponseNewParamsToolChoiceUnion

ConvertAnthropicV1ToolChoiceToResponses converts Anthropic v1 tool_choice to Responses API format

func ConvertAnthropicV1ToolsToResponses

func ConvertAnthropicV1ToolsToResponses(tools []anthropic.ToolUnionParam) []responses.ToolUnionParam

ConvertAnthropicV1ToolsToResponses converts Anthropic v1 tools to Responses API format

func ConvertBetaContentBlocksToString

func ConvertBetaContentBlocksToString(blocks []anthropic.BetaContentBlockParamUnion) string

ConvertBetaContentBlocksToString converts Anthropic beta content blocks to string

func ConvertBetaTextBlocksToString

func ConvertBetaTextBlocksToString(blocks []anthropic.BetaTextBlockParam) string

ConvertBetaTextBlocksToString converts Anthropic beta TextBlockParam array to string

func ConvertContentBlocksToString

func ConvertContentBlocksToString(blocks []anthropic.ContentBlockParamUnion) string

ConvertContentBlocksToString converts Anthropic content blocks to string

func ConvertFunctionCallOutputToChatGPTFormat

func ConvertFunctionCallOutputToChatGPTFormat(output *responses.ResponseInputItemFunctionCallOutputParam) map[string]interface{}

ConvertFunctionCallOutputToChatGPTFormat converts function_call_output items to ChatGPT backend format.

func ConvertFunctionCallToChatGPTFormat

func ConvertFunctionCallToChatGPTFormat(call *responses.ResponseFunctionToolCallParam) map[string]interface{}

ConvertFunctionCallToChatGPTFormat converts function_call items to ChatGPT backend format.

func ConvertGooglePartsToString

func ConvertGooglePartsToString(parts []*genai.Part) string

ConvertGooglePartsToString converts Google parts to a single string

func ConvertGoogleToAnthropicRequest

func ConvertGoogleToAnthropicRequest(model string, contents []*genai.Content, config *genai.GenerateContentConfig) anthropic.MessageNewParams

ConvertGoogleToAnthropicRequest converts Google Content and config to Anthropic format

func ConvertGoogleToOpenAIRequest

func ConvertGoogleToOpenAIRequest(model string, contents []*genai.Content, config *genai.GenerateContentConfig) *openai.ChatCompletionNewParams

ConvertGoogleToOpenAIRequest converts Google Content and config to OpenAI format

func ConvertGoogleToolChoiceToAnthropic

func ConvertGoogleToolChoiceToAnthropic(config *genai.FunctionCallingConfig) anthropic.ToolChoiceUnionParam

func ConvertGoogleToolsToAnthropic

func ConvertGoogleToolsToAnthropic(funcs []*genai.FunctionDeclaration) []anthropic.ToolUnionParam

func ConvertOpenAIResponsesToAnthropicBetaRequest

func ConvertOpenAIResponsesToAnthropicBetaRequest(
	params responses.ResponseNewParams,
	defaultMaxTokens int64,
) *anthropic.BetaMessageNewParams

ConvertOpenAIResponsesToAnthropicBetaRequest converts OpenAI Responses API params to Anthropic Beta Message API format

func ConvertOpenAIResponsesToAnthropicRequest

func ConvertOpenAIResponsesToAnthropicRequest(
	params responses.ResponseNewParams,
	defaultMaxTokens int64,
) *anthropic.MessageNewParams

ConvertOpenAIResponsesToAnthropicRequest converts OpenAI Responses API params to Anthropic v1 Message API format

Note: The following Responses API fields are not supported in Anthropic's Message API:

  • MaxToolCalls: Anthropic doesn't have an equivalent limit
  • ParallelToolCalls: Anthropic supports parallel tool calls by default
  • Include (web_search sources, code interpreter outputs, etc.): Not supported
  • PreviousResponseID: Requires conversation state management
  • TopLogprobs: Anthropic Message API doesn't support logprobs
  • Reasoning tokens: Special handling required for o1/o3 models

func ConvertOpenAIResponsesToChat

func ConvertOpenAIResponsesToChat(params responses.ResponseNewParams, defaultMaxTokens int64) *openai.ChatCompletionNewParams

ConvertOpenAIResponsesToChat converts OpenAI Responses API params to Chat Completions format. This is useful when translating between the two API formats.

func ConvertOpenAIToAnthropicRequest

func ConvertOpenAIToAnthropicRequest(req *openai.ChatCompletionNewParams, defaultMaxTokens int64) *anthropic.BetaMessageNewParams

ConvertOpenAIToAnthropicRequest converts OpenAI ChatCompletionNewParams to Anthropic SDK format

func ConvertOpenAIToGoogleRequest

func ConvertOpenAIToGoogleRequest(req *openai.ChatCompletionNewParams, defaultMaxTokens int64) (string, []*genai.Content, *genai.GenerateContentConfig)

ConvertOpenAIToGoogleRequest converts OpenAI ChatCompletionNewParams to Google SDK format

func ConvertRawInputToChatGPTFormat

func ConvertRawInputToChatGPTFormat(raw map[string]interface{}) []interface{}

ConvertRawInputToChatGPTFormat converts raw input items to ChatGPT backend API format.

func ConvertResponseInputToChatGPTFormat

func ConvertResponseInputToChatGPTFormat(inputItems responses.ResponseInputParam) []interface{}

ConvertResponseInputToChatGPTFormat converts ResponseInputParam to ChatGPT backend API format.

func ConvertResponseToolChoiceToChatGPTFormat

func ConvertResponseToolChoiceToChatGPTFormat(toolChoice responses.ResponseNewParamsToolChoiceUnion) interface{}

ConvertResponseToolChoiceToChatGPTFormat converts ToolChoice from Responses API format to ChatGPT backend API format.

func ConvertResponseToolsToChatGPTFormat

func ConvertResponseToolsToChatGPTFormat(tools []responses.ToolUnionParam) []interface{}

ConvertResponseToolsToChatGPTFormat converts Tools from Responses API format to ChatGPT backend API format.

func ConvertResponsesInputToMessages

func ConvertResponsesInputToMessages(items responses.ResponseInputParam) []openai.ChatCompletionMessageParamUnion

ConvertResponsesInputToMessages converts Responses API input items to Chat Completion messages.

func ConvertResponsesToolChoiceToAnthropic

func ConvertResponsesToolChoiceToAnthropic(tc responses.ResponseNewParamsToolChoiceUnion) anthropic.ToolChoiceUnionParam

ConvertResponsesToolChoiceToAnthropic converts Responses API tool_choice to Anthropic v1 format

func ConvertResponsesToolChoiceToAnthropicBeta

func ConvertResponsesToolChoiceToAnthropicBeta(tc responses.ResponseNewParamsToolChoiceUnion) anthropic.BetaToolChoiceUnionParam

ConvertResponsesToolChoiceToAnthropicBeta converts Responses API tool_choice to Anthropic Beta format

func ConvertResponsesToolChoiceToChat

ConvertResponsesToolChoiceToChat converts Responses API tool choice to Chat Completions format.

func ConvertResponsesToolsToAnthropic

func ConvertResponsesToolsToAnthropic(tools []responses.ToolUnionParam) []anthropic.ToolUnionParam

ConvertResponsesToolsToAnthropic converts Responses API tools to Anthropic v1 tools

func ConvertResponsesToolsToAnthropicBeta

func ConvertResponsesToolsToAnthropicBeta(tools []responses.ToolUnionParam) []anthropic.BetaToolUnionParam

ConvertResponsesToolsToAnthropicBeta converts Responses API tools to Anthropic Beta tools

func ConvertResponsesToolsToChatTools

func ConvertResponsesToolsToChatTools(tools []responses.ToolUnionParam) []openai.ChatCompletionToolUnionParam

ConvertResponsesToolsToChatTools converts Responses API tools to Chat Completions tools.

func ConvertTextBlocksToString

func ConvertTextBlocksToString(blocks []anthropic.TextBlockParam) string

ConvertTextBlocksToString converts Anthropic TextBlockParam array to string

func ExtractInstructions

func ExtractInstructions(raw map[string]interface{}) string

ExtractInstructions extracts system message content as instructions.

func IsThinkingEnabled

func IsThinkingEnabled(anthropicReq *anthropic.MessageNewParams) bool

IsThinkingEnabled checks if thinking mode is enabled in the Anthropic request

func IsThinkingEnabledBeta

func IsThinkingEnabledBeta(anthropicReq *anthropic.BetaMessageNewParams) bool

IsThinkingEnabledBeta checks if thinking mode is enabled in the Anthropic beta request

func ParamOpt

func ParamOpt[T comparable](value T) param.Opt[T]

func RequiresMaxCompletionTokens

func RequiresMaxCompletionTokens(model string) bool

RequiresMaxCompletionTokens checks if the model requires max_completion_tokens instead of max_tokens. Newer OpenAI models (gpt-4o, o1 series, gpt-4.1) use max_completion_tokens.

Types

type ChatGPTBackendRequest

type ChatGPTBackendRequest struct {
	Model         string        `json:"model"`
	Stream        bool          `json:"stream"`
	Instructions  string        `json:"instructions"`
	Input         []interface{} `json:"input,omitempty"`
	Tools         []interface{} `json:"tools,omitempty"`
	ToolChoice    interface{}   `json:"tool_choice,omitempty"`
	Store         bool          `json:"store"`
	Include       []string      `json:"include"`
	MaxTokens     int           `json:"max_tokens,omitempty"`
	MaxCompletion int           `json:"max_completion_tokens,omitempty"`
	Temperature   float64       `json:"temperature,omitempty"`
	TopP          float64       `json:"top_p,omitempty"`
}

ChatGPTBackendRequest represents a request to the ChatGPT backend API.

Jump to

Keyboard shortcuts

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