Documentation
¶
Index ¶
- Constants
- Variables
- func FetchGeminiModels(baseURL, apiKey, proxyURL string) ([]string, error)
- func GeminiChatHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func GeminiEmbeddingHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func GeminiImageHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func GeminiResponsesHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func GeminiResponsesStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func GeminiTextGenerationStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
- func NativeGeminiEmbeddingHandler(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (*dto.Usage, *types.NewAPIError)
- func ValidateAntigravityGenerationConfig(options map[string]any) error
- type Adaptor
- func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error)
- func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error)
- func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.EmbeddingRequest) (any, error)
- func (a *Adaptor) ConvertGeminiRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeminiChatRequest) (any, error)
- func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (any, error)
- func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest) (any, error)
- func (a *Adaptor) ConvertOpenAIResponsesRequest(c *gin.Context, info *relaycommon.RelayInfo, ...) (any, error)
- func (a *Adaptor) ConvertRerankRequest(c *gin.Context, relayMode int, request dto.RerankRequest) (any, error)
- func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (any, error)
- func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.NewAPIError)
- func (a *Adaptor) GetChannelName() string
- func (a *Adaptor) GetModelList() []string
- func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error)
- func (a *Adaptor) Init(info *relaycommon.RelayInfo)
- func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *relaycommon.RelayInfo) error
- type AntigravityAgentConfig
- type AntigravityClient
- func (c *AntigravityClient) Cancel(ctx context.Context, interactionID string) (*AntigravityInteraction, error)
- func (c *AntigravityClient) Create(ctx context.Context, request AntigravityLifecycleRequest) (*AntigravityInteraction, error)
- func (c *AntigravityClient) Delete(ctx context.Context, interactionID string) error
- func (c *AntigravityClient) Get(ctx context.Context, interactionID string) (*AntigravityInteraction, error)
- func (c *AntigravityClient) Poll(ctx context.Context, interactionID string, interval time.Duration, ...) (*AntigravityInteraction, error)
- type AntigravityClientConfig
- type AntigravityConfig
- type AntigravityGroundingToolCount
- type AntigravityHTTPError
- type AntigravityInteraction
- type AntigravityInteractionError
- type AntigravityInteractionRequest
- type AntigravityLifecycleAgentConfig
- type AntigravityLifecycleRequest
- type AntigravityModalityTokens
- type AntigravityUsage
- type GeminiModelsResponse
Constants ¶
const ( // AntigravityAgentPreview is the currently documented managed agent name. // Keep this configurable because the preview identifier can change. AntigravityAgentPreview = "antigravity-preview-05-2026" // AntigravityInteractionsPath is relative to the Gemini API base URL. AntigravityInteractionsPath = "/v1beta/interactions" // AntigravityEnvironmentRemote is the managed Linux sandbox. MyAPI does not // infer or mount a user's local filesystem into an interaction. AntigravityEnvironmentRemote = "remote" // AntigravityMaxInputBytes bounds accidental oversized agent prompts. AntigravityMaxInputBytes = 4 << 20 // AntigravityMaxTotalTokens is a conservative upper bound for the optional // agent budget. The service may apply a lower plan-specific limit. AntigravityMaxTotalTokens = 10_000_000 )
const ( // AntigravityDefaultHTTPTimeout bounds a caller that does not provide its // own HTTP client. Long-running background interactions should be polled by // calling Get rather than keeping a request open indefinitely. AntigravityDefaultHTTPTimeout = 60 * time.Second // AntigravityMaxResponseBytes prevents a malformed upstream from allocating // an unbounded response body in the relay process. AntigravityMaxResponseBytes = 16 << 20 )
Variables ¶
var ChannelName = "google gemini"
var ModelList = []string{
"gemini-2.5-flash", "gemini-2.5-pro", "gemini-2.0-flash",
"gemini-2.0-flash-001", "gemini-2.0-flash-lite-001", "gemini-2.0-flash-lite",
"gemini-2.5-flash-lite",
"gemini-3-pro-image", "gemini-3.1-flash-image",
"gemini-flash-latest", "gemini-flash-lite-latest", "gemini-pro-latest",
"gemini-2.5-flash-native-audio-latest",
"gemini-2.5-flash-preview-tts", "gemini-2.5-pro-preview-tts",
"gemini-2.5-flash-image", "gemini-2.5-flash-lite-preview-09-2025",
"gemini-3-pro-preview", "gemini-3-flash-preview", "gemini-3.1-pro-preview",
"gemini-3.1-pro-preview-customtools", "gemini-3.1-flash-lite-preview",
"gemini-3-pro-image-preview", "nano-banana-pro-preview",
"gemini-3.1-flash-image-preview", "gemini-robotics-er-1.5-preview",
"gemini-2.5-computer-use-preview-10-2025", "deep-research-pro-preview-12-2025",
"gemini-2.5-flash-native-audio-preview-09-2025", "gemini-2.5-flash-native-audio-preview-12-2025",
"gemma-3-1b-it", "gemma-3-4b-it", "gemma-3-12b-it",
"gemma-3-27b-it", "gemma-3n-e4b-it", "gemma-3n-e2b-it",
"gemini-embedding-001", "gemini-embedding-2-preview",
"imagen-4.0-generate-001", "imagen-4.0-ultra-generate-001",
"imagen-4.0-fast-generate-001",
"veo-2.0-generate-001", "veo-3.0-generate-001", "veo-3.0-fast-generate-001",
"veo-3.1-generate-preview", "veo-3.1-fast-generate-preview",
"aqa",
}
var SafetySettingList = []string{
"HARM_CATEGORY_HARASSMENT",
"HARM_CATEGORY_HATE_SPEECH",
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
"HARM_CATEGORY_DANGEROUS_CONTENT",
}
var SupportedAntigravityModels = map[string]struct{}{
"gemini-3.7-flash": {},
"gemini-3.6-flash": {},
"gemini-3.5-flash": {},
"gemini-3.5-flash-lite": {},
}
SupportedAntigravityModels mirrors the models documented for the preview agent. Unknown models are rejected to avoid implying unsupported routing.
Functions ¶
func FetchGeminiModels ¶
func GeminiChatHandler ¶
func GeminiChatHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func GeminiChatStreamHandler ¶
func GeminiChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func GeminiEmbeddingHandler ¶
func GeminiEmbeddingHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func GeminiImageHandler ¶
func GeminiImageHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func GeminiResponsesHandler ¶
func GeminiResponsesHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func GeminiResponsesStreamHandler ¶
func GeminiResponsesStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func GeminiTextGenerationHandler ¶
func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func GeminiTextGenerationStreamHandler ¶
func GeminiTextGenerationStreamHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response) (*dto.Usage, *types.NewAPIError)
func NativeGeminiEmbeddingHandler ¶
func NativeGeminiEmbeddingHandler(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (*dto.Usage, *types.NewAPIError)
func ValidateAntigravityGenerationConfig ¶
ValidateGenerationConfig rejects options that the Interactions API documents as unsupported. It is kept as a standalone guard so a future relay adapter cannot silently forward an OpenAI/Gemini generation config that Antigravity will reject with HTTP 400.
Types ¶
type Adaptor ¶
type Adaptor struct {
}
func (*Adaptor) ConvertAudioRequest ¶
func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.AudioRequest) (io.Reader, error)
func (*Adaptor) ConvertClaudeRequest ¶
func (a *Adaptor) ConvertClaudeRequest(c *gin.Context, info *relaycommon.RelayInfo, req *dto.ClaudeRequest) (any, error)
func (*Adaptor) ConvertEmbeddingRequest ¶
func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.EmbeddingRequest) (any, error)
func (*Adaptor) ConvertGeminiRequest ¶
func (a *Adaptor) ConvertGeminiRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeminiChatRequest) (any, error)
func (*Adaptor) ConvertImageRequest ¶
func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.ImageRequest) (any, error)
func (*Adaptor) ConvertOpenAIRequest ¶
func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest) (any, error)
func (*Adaptor) ConvertOpenAIResponsesRequest ¶
func (a *Adaptor) ConvertOpenAIResponsesRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.OpenAIResponsesRequest) (any, error)
func (*Adaptor) ConvertRerankRequest ¶
func (*Adaptor) DoResponse ¶
func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.NewAPIError)
func (*Adaptor) GetChannelName ¶
func (*Adaptor) GetModelList ¶
func (*Adaptor) GetRequestURL ¶
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error)
func (*Adaptor) Init ¶
func (a *Adaptor) Init(info *relaycommon.RelayInfo)
func (*Adaptor) SetupRequestHeader ¶
type AntigravityAgentConfig ¶
type AntigravityAgentConfig struct {
Type string `json:"type"`
Model string `json:"model,omitempty"`
MaxTotalTokens int `json:"max_total_tokens,omitempty"`
}
AntigravityAgentConfig selects the managed agent's underlying model and optional total-token budget.
type AntigravityClient ¶
type AntigravityClient struct {
// contains filtered or unexported fields
}
func NewAntigravityClient ¶
func NewAntigravityClient(config AntigravityClientConfig) (*AntigravityClient, error)
func (*AntigravityClient) Cancel ¶
func (c *AntigravityClient) Cancel(ctx context.Context, interactionID string) (*AntigravityInteraction, error)
Cancel stops a still-running background interaction using the documented POST /interactions/{id}/cancel endpoint.
func (*AntigravityClient) Create ¶
func (c *AntigravityClient) Create(ctx context.Context, request AntigravityLifecycleRequest) (*AntigravityInteraction, error)
Create starts an interaction. Background executions return quickly with an in_progress resource; callers can use Get or Poll for state transitions.
func (*AntigravityClient) Delete ¶
func (c *AntigravityClient) Delete(ctx context.Context, interactionID string) error
Delete removes a stored interaction. It is separate from Cancel: cancelling stops execution while deleting removes the provider-side record.
func (*AntigravityClient) Get ¶
func (c *AntigravityClient) Get(ctx context.Context, interactionID string) (*AntigravityInteraction, error)
Get retrieves the current interaction state. It does not persist the body; callers decide which fields to expose or log.
func (*AntigravityClient) Poll ¶
func (c *AntigravityClient) Poll(ctx context.Context, interactionID string, interval time.Duration, attempts int) (*AntigravityInteraction, error)
Poll waits for a terminal state with bounded attempts. It is intentionally opt-in so a background request never consumes a worker indefinitely.
type AntigravityClientConfig ¶
type AntigravityClientConfig struct {
BaseURL string
APIKey string
APIRevision string
HTTPClient *http.Client
}
AntigravityClientConfig contains connection settings only. APIKey is held in memory for the request and is never included in an error, response, or persisted model.
type AntigravityConfig ¶
type AntigravityConfig struct {
BaseURL string
Agent string
Environment string
Model string
MaxTotalTokens int
}
AntigravityConfig contains non-secret connection and agent settings. The API key remains in the channel credential and is never copied here.
func (AntigravityConfig) BuildInteractionRequest ¶
func (c AntigravityConfig) BuildInteractionRequest(input string) ([]byte, error)
BuildInteractionRequest validates and serializes a text/image-free prompt. The current relay boundary only accepts text; multimodal and stateful continuation need explicit lifecycle handling before being enabled.
func (AntigravityConfig) Endpoint ¶
func (c AntigravityConfig) Endpoint() (string, error)
Endpoint returns the Interactions API URL after validating the configured base. Credentials and query parameters are deliberately rejected.
func (AntigravityConfig) Validate ¶
func (c AntigravityConfig) Validate() error
type AntigravityHTTPError ¶
AntigravityHTTPError deliberately omits response bodies. Upstream errors can contain prompt fragments or provider metadata, and returning only the status/code keeps them out of logs and API error strings.
func (*AntigravityHTTPError) Error ¶
func (e *AntigravityHTTPError) Error() string
type AntigravityInteraction ¶
type AntigravityInteraction struct {
ID string `json:"id,omitempty"`
Object string `json:"object,omitempty"`
Status string `json:"status,omitempty"`
Agent string `json:"agent,omitempty"`
Model string `json:"model,omitempty"`
EnvironmentID string `json:"environment_id,omitempty"`
PreviousInteractionID string `json:"previous_interaction_id,omitempty"`
OutputText string `json:"output_text,omitempty"`
Usage *AntigravityUsage `json:"usage,omitempty"`
Errors []AntigravityInteractionError `json:"errors,omitempty"`
}
AntigravityInteraction is the safe, typed subset returned by create/get/ cancel. Steps and output text are intentionally represented only as fields needed by the caller; this client does not store or log them.
type AntigravityInteractionRequest ¶
type AntigravityInteractionRequest struct {
Agent string `json:"agent"`
Input string `json:"input"`
Environment string `json:"environment,omitempty"`
AgentConfig *AntigravityAgentConfig `json:"agent_config,omitempty"`
}
AntigravityInteractionRequest is the minimal request supported by the managed Antigravity agent. Additional tools and stateful continuation are intentionally not represented until the relay lifecycle supports them.
type AntigravityLifecycleAgentConfig ¶
type AntigravityLifecycleAgentConfig struct {
Type string `json:"type,omitempty"`
MaxTotalTokens int `json:"max_total_tokens,omitempty"`
}
AntigravityLifecycleAgentConfig contains the small, explicitly supported dynamic-agent subset. The relay does not accept arbitrary tool, safety, or generation configuration until each field has a policy and billing model.
type AntigravityLifecycleRequest ¶
type AntigravityLifecycleRequest struct {
Agent string `json:"agent"`
Input string `json:"input"`
Environment string `json:"environment,omitempty"`
Background bool `json:"background,omitempty"`
PreviousInteractionID string `json:"previous_interaction_id,omitempty"`
AgentConfig *AntigravityLifecycleAgentConfig `json:"agent_config,omitempty"`
}
AntigravityLifecycleRequest is the first-phase create payload. It is kept separate from the normal Gemini request DTO so this endpoint cannot silently inherit GenerateContent fields or route through the regular Gemini path.
Environment accepts the documented "remote" value or a provider environment ID when continuing a prior interaction. Local files, credentials, and process state are never mounted by this client.
func (AntigravityLifecycleRequest) Validate ¶
func (r AntigravityLifecycleRequest) Validate() error
type AntigravityModalityTokens ¶
type AntigravityModalityTokens struct {
Modality string `json:"modality,omitempty"`
Tokens int64 `json:"tokens,omitempty"`
}
AntigravityModalityTokens and AntigravityGroundingToolCount model the provider usage response without retaining the full upstream payload.
type AntigravityUsage ¶
type AntigravityUsage struct {
CachedTokensByModality []AntigravityModalityTokens `json:"cached_tokens_by_modality,omitempty"`
InputTokensByModality []AntigravityModalityTokens `json:"input_tokens_by_modality,omitempty"`
OutputTokensByModality []AntigravityModalityTokens `json:"output_tokens_by_modality,omitempty"`
TotalCachedTokens int64 `json:"total_cached_tokens,omitempty"`
TotalInputTokens int64 `json:"total_input_tokens,omitempty"`
TotalOutputTokens int64 `json:"total_output_tokens,omitempty"`
TotalThoughtTokens int64 `json:"total_thought_tokens,omitempty"`
TotalToolUseTokens int64 `json:"total_tool_use_tokens,omitempty"`
TotalTokens int64 `json:"total_tokens,omitempty"`
GroundingToolCount []AntigravityGroundingToolCount `json:"grounding_tool_count,omitempty"`
}
type GeminiModelsResponse ¶
type GeminiModelsResponse struct {
Models []dto.GeminiModel `json:"models"`
NextPageToken string `json:"nextPageToken"`
}