Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/GewoonJaap/gemini-cli-openai
/ functions
Functions
83 in github.com/GewoonJaap/gemini-cli-openai
⨍
Functions
83
◇
Types & classes
61
↓ 7 callers
Method
initializeAuth
* Initializes authentication using OAuth2 credentials with KV storage caching.
src/auth.ts:49
↓ 3 callers
Method
createCustomOnlyConfig
(customTools: Tool[])
src/helpers/native-tools-manager.ts:108
↓ 3 callers
Method
extractBooleanParam
(options: Record<string, unknown> | undefined, key: string)
src/gemini-client.ts:891
↓ 3 callers
Method
getFallbackModel
* Gets the fallback model for the given original model. * Returns null if no fallback is configured for the model.
src/helpers/auto-model-switching.ts:26
↓ 3 callers
Method
isEnabled
* Checks if auto model switching is enabled via environment variable.
src/helpers/auto-model-switching.ts:18
↓ 3 callers
Function
isMediaTypeSupported
(modelId: string, supportKey: keyof ModelInfo)
src/utils/validation.ts:13
↓ 3 callers
Method
shouldEnableGoogleSearch
(params: NativeToolsRequestParams)
src/helpers/native-tools-manager.ts:119
↓ 3 callers
Function
validateContent
( type: string, content: MessageContent )
src/utils/validation.ts:40
↓ 2 callers
Method
cacheTokenInKV
* Cache the access token in KV storage.
src/auth.ts:180
↓ 2 callers
Method
clearTokenCache
* Clear cached token from KV storage.
src/auth.ts:208
↓ 2 callers
Method
createSwitchNotification
* Creates a notification message for when a model switch occurs.
src/helpers/auto-model-switching.ts:57
↓ 2 callers
Method
createThinkingConfig
* Creates a thinkingConfig object for Gemini 2.5 models (uses thinkingBudget). * @param budget - The thinking budget (0 = disabled, -1 = dynamic, po
src/helpers/generation-config-validator.ts:83
↓ 2 callers
Method
discoverProjectId
* Discovers the Google Cloud project ID. Uses the environment variable if provided.
src/gemini-client.ts:115
↓ 2 callers
Function
encodeSignatureInToolCallId
(signature: string | undefined)
src/helpers/thought-signature.ts:10
↓ 2 callers
Function
getAllModelIds
()
src/models.ts:94
↓ 2 callers
Method
getCompletion
* Get a complete response from Gemini API (non-streaming).
src/gemini-client.ts:801
↓ 2 callers
Method
isRateLimitStatus
* Checks if the HTTP status code indicates a rate limit error.
src/helpers/auto-model-switching.ts:43
↓ 2 callers
Method
isValidEffortLevel
* Type guard to check if a value is a valid EffortLevel. * @param value - The value to check * @returns True if the value is a valid EffortLevel
src/helpers/generation-config-validator.ts:73
↓ 2 callers
Method
processChunk
(textChunk: string, metadata?: GroundingMetadata)
src/helpers/citations-processor.ts:43
↓ 2 callers
Method
shouldEnableUrlContext
(params: NativeToolsRequestParams)
src/helpers/native-tools-manager.ts:125
↓ 2 callers
Method
streamContent
* Stream content from Gemini API.
src/gemini-client.ts:351
↓ 2 callers
Function
validateModel
(modelId: string)
src/utils/validation.ts:23
↓ 2 callers
Method
validateThinkingBudget
* Validates and corrects the thinking budget for a specific model. * @param modelId - The Gemini model ID * @param thinkingBudget - The requested
src/helpers/generation-config-validator.ts:181
↓ 1 callers
Method
callEndpoint
* A generic method to call a Code Assist API endpoint.
src/auth.ts:246
↓ 1 callers
Method
cleanSchema
* Recursively cleans a schema object to remove fields not supported by Gemini * (like keys starting with $, strict, const, etc.) * @param schema -
src/helpers/generation-config-validator.ts:114
↓ 1 callers
Method
createFinalToolConfiguration
( config: NativeToolsConfiguration, options: Partial<ChatCompletionRequest> = {} )
src/helpers/generation-config-validator.ts:327
↓ 1 callers
Method
createGemini3ThinkingConfig
* Creates a thinkingConfig object for Gemini 3 models (uses thinkingLevel). * * Gemini 3 models use thinkingLevel instead of thinkingBudget. * U
src/helpers/generation-config-validator.ts:101
↓ 1 callers
Method
createNativeToolsArray
* Creates the array of native tools to be sent to the Gemini API.
src/helpers/native-tools-manager.ts:55
↓ 1 callers
Function
createOpenAIStreamTransformer
(model: string)
src/stream-transformer.ts:85
↓ 1 callers
Method
createSafetySettings
* Creates safety settings configuration for Gemini API. * @param env - Environment variables containing safety thresholds * @returns Safety settin
src/helpers/generation-config-validator.ts:141
↓ 1 callers
Method
createSearchAndUrlConfig
( requestParams: NativeToolsRequestParams, customTools: Tool[], modelId: string )
src/helpers/native-tools-manager.ts:79
↓ 1 callers
Method
createValidateTools
(options: Partial<ChatCompletionRequest> = {})
src/helpers/generation-config-validator.ts:292
↓ 1 callers
Method
createValidatedConfig
* Creates a validated generation config for a specific model. * @param modelId - The Gemini model ID * @param options - Generation options includi
src/helpers/generation-config-validator.ts:214
↓ 1 callers
Method
determineToolConfiguration
* Determines the final tool configuration based on environment settings, * request parameters, and tool compatibility rules.
src/helpers/native-tools-manager.ts:30
↓ 1 callers
Function
encodeImageToBase64
(imagePath)
examples/image-example.js:16
↓ 1 callers
Method
extractNativeToolsParams
(options?: Record<string, unknown>)
src/gemini-client.ts:878
↓ 1 callers
Method
extractSearchQueries
* Extracts search queries that were used to generate the grounded response.
src/helpers/citations-processor.ts:101
↓ 1 callers
Function
extractSignatureFromToolCallId
(toolCallId: string | undefined)
src/helpers/thought-signature.ts:25
↓ 1 callers
Method
extractSourceList
* Extracts a structured list of sources with IDs, titles, and URIs.
src/helpers/citations-processor.ts:108
↓ 1 callers
Method
extractStringParam
( options: Record<string, unknown> | undefined, key: string, guard: (v: string) => v is T )
src/gemini-client.ts:899
↓ 1 callers
Method
findSafeInsertionPoint
* Finds a "safe" insertion point for a citation to avoid breaking words or URLs. * It searches for the nearest whitespace or punctuation after the g
src/helpers/citations-processor.ts:19
↓ 1 callers
Method
generateReasoningOutput
* Generates reasoning output for thinking models.
src/gemini-client.ts:468
↓ 1 callers
Method
getAccessToken
* Get the current access token.
src/auth.ts:276
↓ 1 callers
Method
getCachedTokenInfo
* Get cached token info from KV storage.
src/auth.ts:220
↓ 1 callers
Method
handleNonStreamingFallback
* Handles rate limit fallback for non-streaming requests. * This method requires a stream content function to perform the actual retry.
src/helpers/auto-model-switching.ts:65
↓ 1 callers
Function
isGeminiFunctionCall
(data: unknown)
src/stream-transformer.ts:70
↓ 1 callers
Method
isLegacyModel
(modelId: string)
src/helpers/native-tools-manager.ts:131
↓ 1 callers
Function
isNativeToolResponse
(data: unknown)
src/stream-transformer.ts:77
↓ 1 callers
Method
isRateLimitError
* Checks if the error message indicates a rate limit error that should trigger auto switching.
src/helpers/auto-model-switching.ts:33
↓ 1 callers
Function
isReasoningData
(data: unknown)
src/stream-transformer.ts:66
↓ 1 callers
Function
isUsageData
(data: unknown)
src/stream-transformer.ts:74
↓ 1 callers
Function
main
()
examples/image-example.js:123
↓ 1 callers
Method
mapEffortToThinkingBudget
* Maps reasoning effort to thinking budget based on model type. * @param effort - The reasoning effort level * @param modelId - The model ID to de
src/helpers/generation-config-validator.ts:25
↓ 1 callers
Method
mapEffortToThinkingLevel
* Maps reasoning effort to a Gemini 3 thinkingLevel based on model type. * * Gemini 3 uses thinkingLevel instead of thinkingBudget. The two parame
src/helpers/generation-config-validator.ts:62
↓ 1 callers
Method
messageToGeminiFormat
* Converts a message to Gemini format, handling both text and image content.
src/gemini-client.ts:191
↓ 1 callers
Method
parseEnvironmentSettings
(env: Env)
src/helpers/native-tools-manager.ts:135
↓ 1 callers
Method
parseSSEStream
* Parses a server-sent event (SSE) stream from the Gemini API.
src/gemini-client.ts:149
↓ 1 callers
Method
performStreamRequest
* Performs the actual stream request with retry logic for 401 errors and auto model switching for rate limits.
src/gemini-client.ts:563
↓ 1 callers
Method
refreshAndCacheToken
* Refresh the OAuth token and cache it in KV storage.
src/auth.ts:121
↓ 1 callers
Function
testImageWithGemini
(imageDataUrl, question = "What do you see in this image?")
examples/image-example.js:47
↓ 1 callers
Function
validateImageUrl
(imageUrl: string)
src/utils/image-utils.ts:26
↓ 1 callers
Function
validatePdfBase64
(base64String: string)
src/utils/pdf-utils.ts:8
Method
constructor
(env: Env, authManager: AuthManager)
src/gemini-client.ts:106
Method
constructor
(env: Env)
src/auth.ts:42
Method
constructor
(env: Env)
src/helpers/auto-model-switching.ts:11
Method
constructor
(env: Env)
src/helpers/citations-processor.ts:11
Method
constructor
(env: Env)
src/helpers/native-tools-manager.ts:21
Method
createGroundingSummary
* Creates a summary of the grounding information for debugging/logging.
src/helpers/citations-processor.ts:126
Function
estimateImageTokens
(imageUrl: string, detail: "low" | "high" | "auto" = "auto")
src/utils/image-utils.ts:98
Function
flush
(controller)
src/stream-transformer.ts:181
Function
getModelInfo
(modelId: string)
src/models.ts:90
Method
getSearchEntryPoint
* Generates search entry point HTML if available and enabled.
src/helpers/citations-processor.ts:119
Function
isTextContent
(content: MessageContent)
src/gemini-client.ts:92
Function
isValidModel
(modelId: string)
src/models.ts:98
Function
loggingMiddleware
(c: Context<{ Bindings: Env }>, next: Next)
src/middlewares/logging.ts:12
Function
modelSupportsImages
(modelId: string, models: ModelRegistry)
src/utils/image-utils.ts:90
Function
openAIApiKeyAuth
(c, next)
src/middlewares/auth.ts:8
Function
parseDataUrl
(dataUrl: string)
src/utils/image-utils.ts:76
Method
processCitationsInText
* Processes text to add inline citations if enabled.
src/helpers/native-tools-manager.ts:75
Method
processGroundingMetadata
* Processes grounding metadata from the Gemini API response.
src/helpers/native-tools-response-processor.ts:28
Method
processNativeToolResponse
* Processes a single part from the Gemini API response and returns a * structured native tool response if the part is a native tool output.
src/helpers/native-tools-response-processor.ts:13
Method
shouldAttemptFallback
* Determines if fallback should be attempted for the given model and conditions.
src/helpers/auto-model-switching.ts:50
Function
transform
(chunk, controller)
src/stream-transformer.ts:95