### Install RelayKit via Go CLI Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit Use the following command to install the RelayKit module in your Go project. ```bash go get github.com/QuantumNous/new-api/relaykit@latest ``` -------------------------------- ### Convert OpenAI Chat Request to Claude Messages Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit This example demonstrates how to initialize a request DTO and use ConvertRequest to transform an OpenAI Chat Completions request into a Claude Messages format. ```go package main import ( "context" "fmt" "github.com/QuantumNous/new-api/relaykit/dto" "github.com/QuantumNous/new-api/relaykit/relayconvert" "github.com/QuantumNous/new-api/relaykit/relayconvert/convmeta" "github.com/QuantumNous/new-api/relaykit/types" ) func main() { maxTokens := uint(1024) request := &dto.GeneralOpenAIRequest{ Model: "claude-sonnet-4-5", Messages: []dto.Message{ {Role: "user", Content: "Hello!"}, }, MaxTokens: &maxTokens, } meta := &convmeta.Values{ OriginModelName: "client-model", UpstreamModelName: request.Model, ChannelMetaAttached: true, } result, err := relayconvert.ConvertRequest( context.Background(), meta, types.RelayFormatClaude, request, ) if err != nil { panic(err) } claudeRequest, ok := result.Value.(*dto.ClaudeRequest) if !ok { panic(fmt.Sprintf("unexpected result type %T", result.Value)) } fmt.Printf("model=%s messages=%d\n", claudeRequest.Model, len(claudeRequest.Messages)) } ``` -------------------------------- ### EquivalentGeminiStrength function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Compares two controls after applying the target model's budget/level mapping. Accepts distinct canonical labels that are identical on the Gemini wire (for example minimal and low on 2.5). ```go func EquivalentGeminiStrength(model string, left Intent, right Intent) (bool, error) ``` -------------------------------- ### ParseOpenAIReasoningEffortFromModelSuffix function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Extracts an OpenAI effort tail such as -high or -none. preserveEffortTail, when non-nil, keeps real model IDs whose names already end in those tokens (for example qwen-max). ```go func ParseOpenAIReasoningEffortFromModelSuffix(modelName string, preserveEffortTail func(string) bool) (string, string) ``` -------------------------------- ### ClaudeRequest GetStringSystem Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Retrieves the system prompt as a string. ```go func (c *ClaudeRequest) GetStringSystem() string ``` -------------------------------- ### OptionsOf Function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/convmeta Returns m's conversion options, or empty defaults when m is nil. ```go func OptionsOf(m Meta) *Options ``` -------------------------------- ### WebSearchOptions struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Configuration options for performing web searches. ```go type WebSearchOptions struct { SearchContextSize string `json:"search_context_size,omitempty"` UserLocation json.RawMessage `json:"user_location,omitempty"` } ``` -------------------------------- ### Run tests and build in the relaykit directory Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit Execute these commands within the relaykit directory to ensure the module remains independently buildable. ```bash GOWORK=off go test ./... GOWORK=off go build ./... ``` -------------------------------- ### ClaudeRequest SetStringSystem Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Sets the system prompt as a string. ```go func (c *ClaudeRequest) SetStringSystem(system string) ``` -------------------------------- ### Source type Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Defines the Source type as a string. ```go type Source string ``` -------------------------------- ### Set media resolver for cross-protocol image conversion Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit Configure media resolution callbacks at startup to handle URL content or data URLs. RelayKit will return an error if media resolution is required but these callbacks are not configured. ```go relayconvert.SetMediaResolver(relayconvert.MediaResolver{ GetBase64Data: getBase64Data, DecodeBase64FileData: decodeBase64FileData, }) ``` -------------------------------- ### Options Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/convmeta The per-request snapshot of host configuration that converters consult. Zero value means every adaptation is disabled. ```go type Options struct { Claude ClaudeOptions Gemini GeminiOptions // ToolLossPolicy controls whether a cross-protocol conversion may omit or // approximate built-in-tool semantics. The zero value uses the allow // policy: conversion succeeds and every loss is returned as a diagnostic. // safe/strict rejection is request-phase opt-in only; response and stream // conversion never reject regardless of this field. ToolLossPolicy types.ConversionLossPolicy // OpenRouterDialect marks the upstream as OpenRouter's OpenAI-compatible // surface, which accepts extra fields (reasoning config, cache_control on // system parts) that converters emit only for that dialect. The host sets // it from the channel type. OpenRouterDialect bool // PreserveThinkingSuffix reports models whose -thinking/-nothinking/effort // suffix must be kept on the outgoing model name (host blacklist lookup). // Nil means "never preserve". PreserveThinkingSuffix func(modelName string) bool // PreserveEffortTail reports real model IDs whose names already end in an // effort-like token (for example qwen-max). Nil means "never preserve". PreserveEffortTail func(modelName string) bool } ``` -------------------------------- ### UserSetting struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines user-specific configuration settings including notification preferences, webhook details, and UI preferences. ```go type UserSetting struct { NotifyType string `json:"notify_type,omitempty"` // QuotaWarningType 额度预警类型 QuotaWarningThreshold float64 `json:"quota_warning_threshold,omitempty"` // QuotaWarningThreshold 额度预警阈值 WebhookUrl string `json:"webhook_url,omitempty"` // WebhookUrl webhook地址 WebhookSecret string `json:"webhook_secret,omitempty"` // WebhookSecret webhook密钥 NotificationEmail string `json:"notification_email,omitempty"` // NotificationEmail 通知邮箱地址 BarkUrl string `json:"bark_url,omitempty"` // BarkUrl Bark推送URL GotifyUrl string `json:"gotify_url,omitempty"` // GotifyUrl Gotify服务器地址 GotifyToken string `json:"gotify_token,omitempty"` // GotifyToken Gotify应用令牌 GotifyPriority int `json:"gotify_priority"` // GotifyPriority Gotify消息优先级 UpstreamModelUpdateNotifyEnabled bool `json:"upstream_model_update_notify_enabled,omitempty"` // 是否接收上游模型更新定时检测通知(仅管理员) AcceptUnsetRatioModel bool `json:"accept_unset_model_ratio_model,omitempty"` // AcceptUnsetRatioModel 是否接受未设置价格的模型 RecordIpLog bool `json:"record_ip_log,omitempty"` // 是否记录请求和错误日志IP SidebarModules string `json:"sidebar_modules,omitempty"` // SidebarModules 左侧边栏模块配置 BillingPreference string `json:"billing_preference,omitempty"` // BillingPreference 扣费策略(订阅/钱包) Language string `json:"language,omitempty"` // Language 用户语言偏好 (zh, en) } ``` -------------------------------- ### Configure conversion context with convmeta.Values Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit Use convmeta.Values to define options for specific models like Claude and Gemini. Ensure Claude.DefaultMaxTokens is set when converting to Claude to avoid errors. ```go meta := &convmeta.Values{ Options: &convmeta.Options{ Claude: convmeta.ClaudeOptions{ DefaultMaxTokens: func(model string) int { return 4096 }, }, Gemini: convmeta.GeminiOptions{ ThinkingAdapterEnabled: true, }, }, } ``` -------------------------------- ### GetBudgetTokens method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Retrieves the budget tokens for the Thinking configuration. ```go func (c *Thinking) GetBudgetTokens() int ``` -------------------------------- ### HTTP Protocol Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants for HTTP protocol configuration and connection management. ```go const ( HTTPProtocolAuto = "auto" HTTPProtocolHTTP1 = "http1" MaxHTTP2ConnectionShards = 8 ) ``` -------------------------------- ### Thinking struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Configuration for thinking process parameters, including budget tokens and display settings. ```go type Thinking struct { Type string `json:"type,omitempty"` BudgetTokens *int `json:"budget_tokens,omitempty"` // Display controls whether thinking content is returned in the response. // Used with adaptive thinking on Claude Opus 4.7+: "summarized" restores // the visible summary that was default on Opus 4.6; "omitted" (default on // 4.7) suppresses it. Pass-through field from upstream Anthropic API. Display string `json:"display,omitempty"` } ``` -------------------------------- ### ConvOptions Method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/convmeta Returns the request-scoped conversion options snapshot. Must never return nil. ```go // ConvOptions returns the request-scoped conversion options snapshot. // Must never return nil. ConvOptions() *Options } ``` -------------------------------- ### EffortFromBudget function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Maps a numeric budget to an Effort level. ```go func EffortFromBudget(budget int) Effort ``` -------------------------------- ### GetStringContent method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Returns the content as a string. Use when the content field is a string or needs conversion. ```go func (c *ClaudeMediaMessage) GetStringContent() string ``` -------------------------------- ### GetContentString method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Returns the content as a string. Use when the content field is a string or needs conversion. ```go func (c *ChatCompletionsStreamResponseChoiceDelta) GetContentString() string ``` -------------------------------- ### Reasoning struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents reasoning metadata including effort, summary, and raw context. ```go type Reasoning struct { Effort string `json:"effort,omitempty"` Summary string `json:"summary,omitempty"` Mode json.RawMessage `json:"mode,omitempty"` Context json.RawMessage `json:"context,omitempty"` } ``` -------------------------------- ### ClaudeRequest ParseSystem Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Parses the system prompt into a slice of ClaudeMediaMessage. ```go func (c *ClaudeRequest) ParseSystem() []ClaudeMediaMessage ``` -------------------------------- ### ToolConfig struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Configuration settings for tool-related features like function calling and retrieval. ```go type ToolConfig struct { FunctionCallingConfig *FunctionCallingConfig `json:"functionCallingConfig,omitempty"` RetrievalConfig *RetrievalConfig `json:"retrievalConfig,omitempty"` IncludeServerSideToolInvocations *bool `json:"includeServerSideToolInvocations,omitempty"` } ``` -------------------------------- ### RenderClaude function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Renders a Claude reasoning configuration from an intent, applying the adapter budget percentage and max tokens. ```go func RenderClaude(model string, intent Intent, maxTokens *uint, adapterBudgetPercentage float64) (ClaudeRender, error) ``` -------------------------------- ### OutputTokenDetails Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Details regarding token usage across different modalities. ```go type OutputTokenDetails struct { TextTokens int `json:"text_tokens"` AudioTokens int `json:"audio_tokens"` ImageTokens int `json:"image_tokens"` ReasoningTokens int `json:"reasoning_tokens"` } ``` -------------------------------- ### Usage struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Detailed token usage statistics for API requests. ```go type Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` PromptCacheHitTokens int `json:"prompt_cache_hit_tokens,omitempty"` UsageSemantic string `json:"usage_semantic,omitempty"` UsageSource string `json:"usage_source,omitempty"` BillingUsage *BillingUsage `json:"billing_usage,omitempty"` PromptTokensDetails InputTokenDetails `json:"prompt_tokens_details"` CompletionTokenDetails OutputTokenDetails `json:"completion_tokens_details"` InputTokens int `json:"input_tokens"` OutputTokens int `json:"output_tokens"` InputTokensDetails *InputTokenDetails `json:"input_tokens_details"` // claude cache 1h ClaudeCacheCreation5mTokens int `json:"claude_cache_creation_5_m_tokens"` ClaudeCacheCreation1hTokens int `json:"claude_cache_creation_1_h_tokens"` ``` -------------------------------- ### OpenAIVideo Struct and Methods Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the video object structure and associated helper methods for metadata and progress management. ```go type OpenAIVideo struct { ID string `json:"id"` TaskID string `json:"task_id,omitempty"` //兼容旧接口 待废弃 Object string `json:"object"` Model string `json:"model"` Status string `json:"status"` // Should use VideoStatus constants: VideoStatusQueued, VideoStatusInProgress, VideoStatusCompleted, VideoStatusFailed Progress int `json:"progress"` CreatedAt int64 `json:"created_at"` CompletedAt int64 `json:"completed_at,omitempty"` ExpiresAt int64 `json:"expires_at,omitempty"` Seconds string `json:"seconds,omitempty"` Size string `json:"size,omitempty"` RemixedFromVideoID string `json:"remixed_from_video_id,omitempty"` Error *OpenAIVideoError `json:"error,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` } func NewOpenAIVideo() *OpenAIVideo func (m *OpenAIVideo) SetMetadata(k string, v any) func (m *OpenAIVideo) SetProgressStr(progress string) ``` -------------------------------- ### Built-in Tool Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants for built-in tools available in the system. ```go const ( BuildInToolWebSearchPreview = "web_search_preview" BuildInToolWebSearch = "web_search" BuildInToolFileSearch = "file_search" BuildInToolGoogleSearch = "google_search" BuildInToolImageGeneration = "image_generation" ) ``` -------------------------------- ### MessageVideoUrl struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents a video URL input. ```go type MessageVideoUrl struct { Url string `json:"url"` } ``` -------------------------------- ### GetReasoningContent method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Returns the reasoning content as a string. Use when reasoning content is present. ```go func (c *ChatCompletionsStreamResponseChoiceDelta) GetReasoningContent() string ``` -------------------------------- ### Tool struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines a tool available for invocation, including its schema and strictness. ```go type Tool struct { Name string `json:"name"` Description string `json:"description,omitempty"` InputSchema map[string]interface{} `json:"input_schema"` Strict *bool `json:"strict,omitempty"` } ``` -------------------------------- ### OutputConfigForEffort Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Used for extracting effort configuration. ```go type OutputConfigForEffort struct { Effort string `json:"effort,omitempty"` } ``` -------------------------------- ### IsQwenThinkingBudgetModel Function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Checks if the provided model name supports Qwen thinking budget (added in v0.2.0). ```go func IsQwenThinkingBudgetModel(modelName string) bool ``` -------------------------------- ### ClaudeCacheCreationUsage struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Tracks cache creation usage with ephemeral input token counts for 5-minute and 1-hour cache durations. ```go type ClaudeCacheCreationUsage struct { Ephemeral5mInputTokens int `json:"ephemeral_5m_input_tokens,omitempty"` Ephemeral1hInputTokens int `json:"ephemeral_1h_input_tokens,omitempty"` } ``` -------------------------------- ### Billing Usage Source Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants defining the sources for billing usage tracking. ```go const ( BillingUsageSourceClaudeMessages = "claude_messages" BillingUsageSourceGeminiChat = "gemini_chat" BillingUsageSourceOAIChat = "oai_chat" BillingUsageSourceOAIResponses = "oai_responses" BillingUsageSemanticAnthropic = "anthropic" BillingUsageSemanticGemini = "gemini" BillingUsageSemanticOpenAI = "openai" ) ``` -------------------------------- ### RealTimeTool Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines a tool available in real-time interactions. ```go type RealTimeTool struct { Type string `json:"type"` Name string `json:"name"` Description string `json:"description"` Parameters any `json:"parameters"` } ``` -------------------------------- ### RealtimeContent Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents content within a real-time message, supporting text and audio. ```go type RealtimeContent struct { Type string `json:"type"` Text string `json:"text,omitempty"` Audio string `json:"audio,omitempty"` // Base64-encoded audio bytes. Transcript string `json:"transcript,omitempty"` } ``` -------------------------------- ### GeminiThinkingConfig struct and methods Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Configuration for Gemini thinking capabilities, including methods for setting the budget and custom unmarshaling. ```go type GeminiThinkingConfig struct { IncludeThoughts *bool `json:"includeThoughts,omitempty"` ThinkingBudget *int `json:"thinkingBudget,omitempty"` // TODO Conflict with thinkingbudget. ThinkingLevel string `json:"thinkingLevel,omitempty"` } ``` ```go func (c *GeminiThinkingConfig) SetThinkingBudget(budget int) ``` ```go func (c *GeminiThinkingConfig) UnmarshalJSON(data []byte) error ``` -------------------------------- ### ReasoningConversionState struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Carries provider-native reasoning controls between conversion steps. It is not part of the wire protocol and should be tagged with json:"-" in requests. ```go type ReasoningConversionState struct { Mode string Effort string BudgetTokens *int IncludeThoughts *bool } ``` -------------------------------- ### GeneralOpenAIRequest ParseInput method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Method signature for parsing input from a GeneralOpenAIRequest into a slice of strings. ```go func (r *GeneralOpenAIRequest) ParseInput() []string ``` -------------------------------- ### GetToolsMap Method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Returns the tools configuration as a slice of maps. ```go func (r *OpenAIResponsesRequest) GetToolsMap() []map[string]any ``` -------------------------------- ### ToFileSource method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Converts the message to a file source. Use to transform the message into a file source representation. ```go func (c *ClaudeMediaMessage) ToFileSource() ``` -------------------------------- ### Realtime Event Type Constants (Input) Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants for incoming realtime event types. ```go const ( RealtimeEventTypeError = "error" RealtimeEventTypeSessionUpdate = "session.update" RealtimeEventTypeConversationCreate = "conversation.item.create" RealtimeEventTypeResponseCreate = "response.create" RealtimeEventInputAudioBufferAppend = "input_audio_buffer.append" ) ``` -------------------------------- ### RealtimeSession Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents a session configuration in the real-time API. ```go type RealtimeSession struct { ``` -------------------------------- ### ClientError type Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Marks invalid user-supplied reasoning controls so host handlers can return a 4xx without classifying unrelated adapter failures as client errors. ```go type ClientError struct { // contains filtered or unexported fields } ``` -------------------------------- ### GeminiChatTool type Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto GeminiChatTool struct for tool configuration, supporting GoogleSearch and GoogleSearchRetrieval. ```go type GeminiChatTool struct { GoogleSearch any `json:"googleSearch,omitempty"` GoogleSearchRetrieval any `json:"googleSearchRetrieval,omitempty"` } ``` -------------------------------- ### GeminiImage Structs Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Data structures for Imagen-related requests and responses. ```go type GeminiImageInstance struct { Prompt string `json:"prompt"` } ``` ```go type GeminiImageParameters struct { SampleCount int `json:"sampleCount,omitempty"` AspectRatio string `json:"aspectRatio,omitempty"` PersonGeneration string `json:"personGeneration,omitempty"` ImageSize string `json:"imageSize,omitempty"` } ``` ```go type GeminiImagePrediction struct { MimeType string `json:"mimeType"` BytesBase64Encoded string `json:"bytesBase64Encoded"` RaiFilteredReason string `json:"raiFilteredReason,omitempty"` SafetyAttributes any `json:"safetyAttributes,omitempty"` } ``` ```go type GeminiImageRequest struct { Instances []GeminiImageInstance `json:"instances"` Parameters GeminiImageParameters `json:"parameters"` } ``` ```go type GeminiImageResponse struct { Predictions []GeminiImagePrediction `json:"predictions"` } ``` -------------------------------- ### ChannelOtherSettings struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the ChannelOtherSettings struct with fields for Azure, Vertex, OpenRouter, and Claude-specific settings. ```go type ChannelOtherSettings struct { AzureResponsesVersion string `json:"azure_responses_version,omitempty"` VertexKeyType VertexKeyType `json:"vertex_key_type,omitempty"` // "json" or "api_key" OpenRouterEnterprise *bool `json:"openrouter_enterprise,omitempty"` ClaudeBetaQuery bool `json:"claude_beta_query,omitempty"` // Claude 渠道是否强制追加 ?beta=true AllowServiceTier bool `json:"allow_service_tier,omitempty"` // 是否允许 service_tier 透传(默认过滤以避免额外计费) AllowInferenceGeo bool `json:"allow_inference_geo,omitempty"` // 是否允许 inference_geo 透传(仅 Claude,默认过滤以满足数据驻留合规 AllowSpeed bool `json:"allow_speed,omitempty"` // 是否允许 speed 透传(仅 Claude,默认过滤以避免意外切换推理速度模式) } ``` -------------------------------- ### ClaudeRequest GetTools Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Retrieves the list of tools configured in the request. ```go func (c *ClaudeRequest) GetTools() []any ``` -------------------------------- ### NewGeminiChatBillingUsage function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Creates a BillingUsage from GeminiUsageMetadata. ```go func NewGeminiChatBillingUsage(metadata *GeminiUsageMetadata) *BillingUsage ``` -------------------------------- ### OpenAITextResponse Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents the standard text response structure from OpenAI. ```go type OpenAITextResponse struct { Id string `json:"id"` Model string `json:"model"` Object string `json:"object"` Created any `json:"created"` Choices []OpenAITextResponseChoice `json:"choices"` Error any `json:"error,omitempty"` Usage `json:"usage"` } ``` -------------------------------- ### ResponsesOutput struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents the output structure for responses, including content, reasoning, and tool-related fields. ```go type ResponsesOutput struct { Type string `json:"type"` ID string `json:"id"` Status string `json:"status"` Role string `json:"role"` Content []ResponsesOutputContent `json:"content"` Summary []ResponsesReasoningSummaryPart `json:"summary,omitempty"` Quality string `json:"quality"` Size string `json:"size"` Result string `json:"result,omitempty"` CallId string `json:"call_id,omitempty"` Name string `json:"name,omitempty"` Arguments json.RawMessage `json:"arguments,omitempty"` Action json.RawMessage `json:"action,omitempty"` Queries json.RawMessage `json:"queries,omitempty"` Results json.RawMessage `json:"results,omitempty"` Sources json.RawMessage `json:"sources,omitempty"` Code json.RawMessage `json:"code,omitempty"` ``` -------------------------------- ### NewOpenAIResponsesBillingUsage function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Creates a BillingUsage from a Usage for OpenAI responses. ```go func NewOpenAIResponsesBillingUsage(usage *Usage) *BillingUsage ``` -------------------------------- ### Notification Type Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants for different types of system notifications. ```go const ( NotifyTypeQuotaExceed = "quota_exceed" NotifyTypeChannelUpdate = "channel_update" NotifyTypeChannelTest = "channel_test" ) ``` -------------------------------- ### Intent.HasStrength method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Reports whether the intent has a strength setting. ```go func (i Intent) HasStrength() bool ``` -------------------------------- ### TextResponse struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Standard structure for text-based API responses. ```go type TextResponse struct { Id string `json:"id"` Object string `json:"object"` Created int64 `json:"created"` Model string `json:"model"` Choices []OpenAITextResponseChoice `json:"choices"` Usage `json:"usage"` } ``` -------------------------------- ### Video Status Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants representing the lifecycle status of video processing. ```go const ( VideoStatusUnknown = "unknown" VideoStatusQueued = "queued" VideoStatusInProgress = "in_progress" VideoStatusCompleted = "completed" VideoStatusFailed = "failed" ) ``` -------------------------------- ### RealtimeUsage struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the structure for tracking token usage in real-time operations. ```go type RealtimeUsage struct { TotalTokens int `json:"total_tokens"` InputTokens int `json:"input_tokens"` OutputTokens int `json:"output_tokens"` InputTokenDetails InputTokenDetails `json:"input_token_details"` OutputTokenDetails OutputTokenDetails `json:"output_token_details"` } ``` -------------------------------- ### GeminiUsageMetadata struct and merge function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Tracks token usage and billing metadata, with a utility to merge non-zero values. ```go type GeminiUsageMetadata struct { PromptTokenCount int `json:"promptTokenCount"` ToolUsePromptTokenCount int `json:"toolUsePromptTokenCount"` CandidatesTokenCount int `json:"candidatesTokenCount"` TotalTokenCount int `json:"totalTokenCount"` ThoughtsTokenCount int `json:"thoughtsTokenCount"` CachedContentTokenCount int `json:"cachedContentTokenCount"` PromptTokensDetails []GeminiPromptTokensDetails `json:"promptTokensDetails"` ToolUsePromptTokensDetails []GeminiPromptTokensDetails `json:"toolUsePromptTokensDetails"` CandidatesTokensDetails []GeminiPromptTokensDetails `json:"candidatesTokensDetails"` BillingUsage *BillingUsage `json:"billing_usage,omitempty"` } ``` ```go func MergeGeminiUsageMetadataNonZero(current *GeminiUsageMetadata, incoming *GeminiUsageMetadata) *GeminiUsageMetadata ``` -------------------------------- ### GeneralOpenAIRequest GetSystemRoleName method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Method signature for retrieving the system role name from a GeneralOpenAIRequest. ```go func (r *GeneralOpenAIRequest) GetSystemRoleName() string ``` -------------------------------- ### RealtimeItem Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents an item within a real-time conversation. ```go type RealtimeItem struct { Id string `json:"id"` Type string `json:"type"` Status string `json:"status"` Role string `json:"role"` Content []RealtimeContent `json:"content"` Name *string `json:"name,omitempty"` ToolCalls any `json:"tool_calls,omitempty"` CallId string `json:"call_id,omitempty"` } ``` -------------------------------- ### NewResponsesToChatStreamState constructor Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/internal/oai_responses Constructor for ResponsesToChatStreamState. Takes a model string and includeUsage boolean. ```go func NewResponsesToChatStreamState(model string, includeUsage bool) *ResponsesToChatStreamState ``` -------------------------------- ### NewResponsesBufferedAccumulator constructor Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/internal/oai_responses Constructor for ResponsesBufferedAccumulator. Returns a pointer to a new instance. ```go func NewResponsesBufferedAccumulator() *ResponsesBufferedAccumulator ``` -------------------------------- ### ResponsesBufferedAccumulator.BuildOutput method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/internal/oai_responses Method on ResponsesBufferedAccumulator that builds the output as a slice of dto.ResponsesOutput. ```go func (a *ResponsesBufferedAccumulator) BuildOutput() []dto.ResponsesOutput ``` -------------------------------- ### ResponsesBufferedAccumulator.SupplementResponseOutput method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/internal/oai_responses Method on ResponsesBufferedAccumulator that supplements the response output. ```go func (a *ResponsesBufferedAccumulator) SupplementResponseOutput(resp *dto.OpenAIResponsesResponse) ``` -------------------------------- ### AudioResponse struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the AudioResponse struct with a single Text field. ```go type AudioResponse struct { Text string `json:"text"` } ``` -------------------------------- ### FromGemini function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Converts a Gemini chat request into a portable Intent. Use when extracting reasoning controls from a Gemini-format request. ```go func FromGemini(req *dto.GeminiChatRequest) (Intent, error) ``` -------------------------------- ### Mode type Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Defines the Mode type as a string. ```go type Mode string ``` -------------------------------- ### Notify struct and NewNotify constructor Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines a notification structure and its constructor function. ```go type Notify struct { Type string `json:"type"` Title string `json:"title"` Content string `json:"content"` Values []interface{} `json:"values"` } ``` ```go func NewNotify(t string, title string, content string, values []interface{}) Notify ``` -------------------------------- ### ClaudeMessageSource Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents a source for Claude media content. ```go type ClaudeMessageSource struct { Type string `json:"type"` MediaType string `json:"media_type,omitempty"` Data any `json:"data,omitempty"` Url string `json:"url,omitempty"` } ``` -------------------------------- ### ToolCallResponse struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents the response from a tool invocation. ```go type ToolCallResponse struct { // Index is not nil only in chat completion chunk object Index *int `json:"index,omitempty"` ID string `json:"id,omitempty"` Type any `json:"type"` Function FunctionResponse `json:"function"` } ``` -------------------------------- ### Advanced Custom Path Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants identifying routes for model discovery and billing credit grants. ```go const ( // AdvancedCustomModelListPath identifies the optional OpenAI Models discovery route. AdvancedCustomModelListPath = "/v1/models" // AdvancedCustomBalancePath identifies the optional balance lookup route used by channel management. AdvancedCustomBalancePath = "/v1/dashboard/billing/credit_grants" ) ``` -------------------------------- ### OpenAIVideoResponse Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the response structure for video file operations. ```go type OpenAIVideoResponse struct { Id string `json:"id" example:"file-abc123"` Object string `json:"object" example:"file"` Bytes int64 `json:"bytes" example:"120000"` CreatedAt int64 `json:"created_at" example:"1677610602"` ExpiresAt int64 `json:"expires_at" example:"1677614202"` Filename string `json:"filename" example:"mydata.jsonl"` Purpose string `json:"purpose" example:"fine-tune"` } ``` -------------------------------- ### OpenAIResponsesCompactionRequest struct and methods Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the request structure for OpenAI response compaction and its associated helper methods. ```go type OpenAIResponsesCompactionRequest struct { Model string `json:"model"` Input json.RawMessage `json:"input,omitempty"` Instructions json.RawMessage `json:"instructions,omitempty"` PreviousResponseID string `json:"previous_response_id,omitempty"` // Codex compact request parity: // https://github.com/openai/codex/commit/53d59722268dde82fb93c1f37964ce196c2a86d7 // https://github.com/openai/codex/commit/5d6f23a27bf9c90709af527a7108c1c2eadf5123 Tools json.RawMessage `json:"tools,omitempty"` ParallelToolCalls json.RawMessage `json:"parallel_tool_calls,omitempty"` Reasoning *Reasoning `json:"reasoning,omitempty"` ServiceTier string `json:"service_tier,omitempty"` PromptCacheKey json.RawMessage `json:"prompt_cache_key,omitempty"` PromptCacheOptions json.RawMessage `json:"prompt_cache_options,omitempty"` PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"` Text json.RawMessage `json:"text,omitempty"` } ``` ```go func (r *OpenAIResponsesCompactionRequest) GetTokenCountMeta() *types.TokenCountMeta ``` ```go func (r *OpenAIResponsesCompactionRequest) IsStream(c *http.Request) bool ``` ```go func (r *OpenAIResponsesCompactionRequest) SetModelName(modelName string) ``` -------------------------------- ### EffectiveEffort function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Returns the effective effort for the given intent. ```go func EffectiveEffort(intent Intent) Effort ``` -------------------------------- ### SetContentString method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Sets the content field to the given string. Use to update the delta content. ```go func (c *ChatCompletionsStreamResponseChoiceDelta) SetContentString(s string) ``` -------------------------------- ### ResponseFormat struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the format for API responses, including optional JSON schema. ```go type ResponseFormat struct { Type string `json:"type,omitempty"` JsonSchema json.RawMessage `json:"json_schema,omitempty"` } ``` -------------------------------- ### Intent.IsEmpty method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Reports whether the intent is empty. ```go func (i Intent) IsEmpty() bool ``` -------------------------------- ### RealtimeResponse Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents a response in the real-time API. ```go type RealtimeResponse struct { Usage *RealtimeUsage `json:"usage"` } ``` -------------------------------- ### Source constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Defines the possible Source constants: explicit, native, suffix, and pivot. ```go const ( SourceExplicit Source = "explicit" SourceNative Source = "native" SourceSuffix Source = "suffix" SourcePivot Source = "pivot" ) ``` -------------------------------- ### GeminiChatRequest SetTools Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto SetTools sets the tools for the request. ```go func (r *GeminiChatRequest) SetTools(tools []GeminiChatTool) ``` -------------------------------- ### NewOpenAIChatBillingUsage function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Creates a BillingUsage from a Usage for OpenAI chat. ```go func NewOpenAIChatBillingUsage(usage *Usage) *BillingUsage ``` -------------------------------- ### Response Output Type Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants for response output lifecycle events. ```go const ( ResponsesOutputTypeItemAdded = "response.output_item.added" ResponsesOutputTypeItemDone = "response.output_item.done" ) ``` -------------------------------- ### ClaudeRequest IsStringSystem Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Checks if the system prompt is a string. ```go func (c *ClaudeRequest) IsStringSystem() bool ``` -------------------------------- ### PlayGroundRequest Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Request structure for playground interactions. ```go type PlayGroundRequest struct { Model string `json:"model,omitempty"` Group string `json:"group,omitempty"` } ``` -------------------------------- ### Realtime Event Type Constants (Output) Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants for outgoing realtime event types. ```go const ( RealtimeEventTypeResponseDone = "response.done" RealtimeEventTypeSessionUpdated = "session.updated" RealtimeEventTypeSessionCreated = "session.created" RealtimeEventResponseAudioDelta = "response.audio.delta" RealtimeEventResponseAudioTranscriptionDelta = "response.audio_transcript.delta" RealtimeEventResponseFunctionCallArgumentsDelta = "response.function_call_arguments.delta" RealtimeEventResponseFunctionCallArgumentsDone = "response.function_call_arguments.done" RealtimeEventConversationItemCreated = "conversation.item.created" ) ``` -------------------------------- ### Intent struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Defines the protocol-independent reasoning controls for a request. Summary visibility is intentionally independent from reasoning strength. ```go type Intent struct { Mode Mode Effort Effort BudgetTokens *int IncludeThoughts *bool Source Source BudgetSource Source } ``` -------------------------------- ### OpenAIModels struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents metadata for an OpenAI model. ```go type OpenAIModels struct { Id string `json:"id"` Object string `json:"object"` Created int `json:"created"` OwnedBy string `json:"owned_by"` SupportedEndpointTypes []types.EndpointType `json:"supported_endpoint_types"` } ``` -------------------------------- ### Advanced Custom Auth Type Constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constants defining authentication types for advanced custom configurations. ```go const ( AdvancedCustomAuthTypeNone = "none" AdvancedCustomAuthTypeHeader = "header" AdvancedCustomAuthTypeQuery = "query" ) ``` -------------------------------- ### OpenAIResponsesRequest Struct Variables Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the fields for the OpenAIResponsesRequest struct, including optional fields for streaming, tool usage, and provider-specific configurations like Qwen and Perplexity. ```go PreviousResponseID string `json:"previous_response_id,omitempty"` Reasoning *Reasoning `json:"reasoning,omitempty"` // ServiceTier specifies upstream service level and may affect billing. // This field is filtered by default and can be enabled via channel setting allow_service_tier. ServiceTier string `json:"service_tier,omitempty"` // Store controls whether upstream may store request/response data. // This field is allowed by default and can be disabled via channel setting disable_store. Store json.RawMessage `json:"store,omitempty"` PromptCacheKey json.RawMessage `json:"prompt_cache_key,omitempty"` PromptCacheOptions json.RawMessage `json:"prompt_cache_options,omitempty"` PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"` // SafetyIdentifier carries client identity for policy abuse detection. // This field is filtered by default and can be enabled via channel setting allow_safety_identifier. SafetyIdentifier json.RawMessage `json:"safety_identifier,omitempty"` Stream *bool `json:"stream,omitempty"` StreamOptions *StreamOptions `json:"stream_options,omitempty"` Temperature *float64 `json:"temperature,omitempty"` Text json.RawMessage `json:"text,omitempty"` ToolChoice json.RawMessage `json:"tool_choice,omitempty"` Tools json.RawMessage `json:"tools,omitempty"` // 需要处理的参数很少,MCP 参数太多不确定,所以用 map TopP *float64 `json:"top_p,omitempty"` Truncation json.RawMessage `json:"truncation,omitempty"` User json.RawMessage `json:"user,omitempty"` MaxToolCalls *uint `json:"max_tool_calls,omitempty"` Prompt json.RawMessage `json:"prompt,omitempty"` // Codex Responses metadata/client_metadata: // https://github.com/openai/codex/commit/14df0e8833aad0d6d78287954b61ffac67af936c ClientMetadata json.RawMessage `json:"client_metadata,omitempty"` // qwen EnableThinking json.RawMessage `json:"enable_thinking,omitempty"` ThinkingBudget json.RawMessage `json:"thinking_budget,omitempty"` // perplexity Preset json.RawMessage `json:"preset,omitempty"` // Internal conversion state; never serialized to an upstream protocol. ReasoningConversion *ReasoningConversionState `json:"-"` } ``` -------------------------------- ### GeminiGroundingMetadata Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Contains metadata related to grounding, such as web search and retrieval queries. ```go type GeminiGroundingMetadata struct { WebSearchQueries []string `json:"webSearchQueries,omitempty"` RetrievalQueries []string `json:"retrievalQueries,omitempty"` GroundingChunks json.RawMessage `json:"groundingChunks,omitempty"` GroundingSupports json.RawMessage `json:"groundingSupports,omitempty"` SearchEntryPoint json.RawMessage `json:"searchEntryPoint,omitempty"` RetrievalMetadata json.RawMessage `json:"retrievalMetadata,omitempty"` SourceFlaggingUris json.RawMessage `json:"sourceFlaggingUris,omitempty"` GoogleMapsWidgetContextToken string `json:"googleMapsWidgetContextToken,omitempty"` } ``` -------------------------------- ### VertexKeyType constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the supported key types for Vertex authentication. ```go type VertexKeyType string ``` ```go const ( VertexKeyTypeJSON VertexKeyType = "json" VertexKeyTypeAPIKey VertexKeyType = "api_key" ) ``` -------------------------------- ### SetReasoningContent method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Sets the reasoning content field to the given string. Use to update reasoning content. ```go func (c *ChatCompletionsStreamResponseChoiceDelta) SetReasoningContent(s string) ``` -------------------------------- ### GeneralOpenAIRequest fields with json.RawMessage and omitempty Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Field declarations for a request struct, showing the convention that unquoted parameters must use json.RawMessage with omitempty tags. Includes fields for search, Minimax, and vLLM options, plus an internal conversion state that is never serialized. ```go SearchRecencyFilter json.RawMessage `json:"search_recency_filter,omitempty"` ReturnImages *bool `json:"return_images,omitempty"` ReturnRelatedQuestions *bool `json:"return_related_questions,omitempty"` SearchMode json.RawMessage `json:"search_mode,omitempty"` // Minimax ReasoningSplit json.RawMessage `json:"reasoning_split,omitempty"` // vLLM ThinkingTokenBudget json.RawMessage `json:"thinking_token_budget,omitempty"` // Internal conversion state; never serialized to an upstream protocol. ReasoningConversion *ReasoningConversionState `json:"-"` ``` -------------------------------- ### ResolveGeminiDefault function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Materializes documented family defaults when a conversion targets another protocol. Dynamic 2.5 defaults retain their -1 budget in the in-process pivot; Flash-Lite's default is explicitly off. ```go func ResolveGeminiDefault(model string, intent Intent) Intent ``` -------------------------------- ### GeminiPromptTokensDetails struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Details regarding token counts for specific modalities. ```go type GeminiPromptTokensDetails struct { Modality string `json:"modality"` TokenCount int `json:"tokenCount"` } ``` -------------------------------- ### ShouldPreserveThinkingSuffix Method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/convmeta Checks if the thinking suffix should be preserved for a given model name. ```go func (o *Options) ShouldPreserveThinkingSuffix(modelName string) bool ``` -------------------------------- ### OpenAIEffort function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Maps the canonical cross-provider vocabulary to the public OpenAI reasoning_effort vocabulary. Claude/OpenRouter "max" has no direct OpenAI equivalent and is represented by xhigh at that wire boundary. ```go func OpenAIEffort(effort Effort) Effort ``` -------------------------------- ### IntentFromState function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Reconstructs a portable intent from host- or pivot-carried conversion state. A nil state is an empty intent. ```go func IntentFromState(state *dto.ReasoningConversionState) Intent ``` -------------------------------- ### Request interface Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the interface for request handling, including token counting and model naming. ```go type Request interface { GetTokenCountMeta() *types.TokenCountMeta IsStream(c *http.Request) bool SetModelName(modelName string) } ``` -------------------------------- ### OpenAIResponsesCompactionResponse struct and method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Defines the response structure for OpenAI response compaction and a method to retrieve errors. ```go type OpenAIResponsesCompactionResponse struct { ID string `json:"id"` Object string `json:"object"` CreatedAt int `json:"created_at"` Output json.RawMessage `json:"output"` Usage *Usage `json:"usage"` Error any `json:"error,omitempty"` } ``` ```go func (o *OpenAIResponsesCompactionResponse) GetOpenAIError() *types.OpenAIError ``` -------------------------------- ### Custom Type Constant Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Constant for custom type identification. ```go const CustomType = "custom" ``` -------------------------------- ### GeminiModel Struct Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Represents the metadata for a Gemini model. ```go type GeminiModel struct { Name interface{} `json:"name"` BaseModelId interface{} `json:"baseModelId"` Version interface{} `json:"version"` DisplayName interface{} `json:"displayName"` Description interface{} `json:"description"` InputTokenLimit interface{} `json:"inputTokenLimit"` OutputTokenLimit interface{} `json:"outputTokenLimit"` ``` -------------------------------- ### Define ConversionLossPolicy type and constants Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/types Defines policies for handling data loss during conversion, including safe, strict, and allow modes. ```go type ConversionLossPolicy string ``` ```go const ( // ConversionLossPolicySafe rejects request-phase conversions that would // change tool execution semantics, while returning non-fatal loss as // diagnostics. It is opt-in; the default is ConversionLossPolicyAllow. ConversionLossPolicySafe ConversionLossPolicy = "safe" // ConversionLossPolicyStrict rejects every lossy conversion, including // presentation-only metadata loss. ConversionLossPolicyStrict ConversionLossPolicy = "strict" // ConversionLossPolicyAllow is the default. It permits lossy conversion // and reports every loss through the conversion result. ConversionLossPolicyAllow ConversionLossPolicy = "allow" ) ``` -------------------------------- ### ResponseStreamState.UsageText Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert Returns a textual representation of the usage metadata. ```APIDOC ## ResponseStreamState.UsageText ### Description Returns a text representation of the usage information. ### Method func (s *ResponseStreamState) UsageText() string ### Returns - **string** - Usage as formatted text. ``` -------------------------------- ### ReasoningStateOf function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/convmeta Nil-safe reader for Meta.ReasoningState. Added in v0.2.0. ```go func ReasoningStateOf(m Meta) *dto.ReasoningConversionState ``` -------------------------------- ### SetContent method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto Sets the content field to the given value. Use to update the message content. ```go func (c *ClaudeMediaMessage) SetContent(content any) ``` -------------------------------- ### NewResponsesToClaudeStreamState constructor Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/internal/oai_responses Constructor for ResponsesToClaudeStreamState. Takes id and model strings. Added in v0.2.0. ```go func NewResponsesToClaudeStreamState(id string, model string) *ResponsesToClaudeStreamState ``` -------------------------------- ### ApplyToOpenAIChat function Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Writes the portable portion of an intent to the OpenAI pivot. reasoning_effort carries level-based strength; a JSON-excluded DTO state retains exact budgets and summary visibility across in-process steps. ```go func ApplyToOpenAIChat(req *dto.GeneralOpenAIRequest, intent Intent) error ``` -------------------------------- ### NewGeminiHostedStreamBridge Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert Instantiates a GeminiHostedStreamBridge for Gemini hosted streaming responses. ```APIDOC ## NewGeminiHostedStreamBridge ### Description Creates a new Gemini hosted stream bridge. ### Function NewGeminiHostedStreamBridge() *GeminiHostedStreamBridge ### Returns - **GeminiHostedStreamBridge** - Pointer to the new bridge. ``` -------------------------------- ### EffectiveToolLossPolicy Method Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/convmeta Returns the effective conversion loss policy for the options. ```go func (o *Options) EffectiveToolLossPolicy() types.ConversionLossPolicy ``` -------------------------------- ### OpenAI effort suffixes Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/relayconvert/reasoning Defines the list of effort suffixes for OpenAI models. ```go var OpenAIEffortSuffixes = []string{"-max", "-xhigh", "-high", "-medium", "-low", "-minimal", "-none"} ``` -------------------------------- ### GeminiChatRequest GetTools Source: https://pkg.go.dev/github.com/QuantumNous/new-api/relaykit/dto GetTools returns the tools associated with the request. ```go func (r *GeminiChatRequest) GetTools() []GeminiChatTool ```