Repository navigation
feat(gemini): add GeminiGateway integration for Google Gemini - #10
Merged
Merged
Conversation
Port of identark/integrations/gemini.py: GeminiGateway (alias IdentArkGeminiGateway) on the optional @google/generative-ai peer dependency, with function calling, multimodal input, streaming, cost cap, local file URLs and Gemini error classification. Exposed at identark/integrations/gemini. Co-Authored-By: Claude <noreply@anthropic.com>
The JS SDK prefixes every error with "[GoogleGenerativeAI Error]" and includes the generativelanguage.googleapis.com URL, both of which contain the substring "rate", so all failures became RateLimitError. Match keywords at word starts and use the HTTP status when present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Goldokpa
pushed a commit
that referenced
this pull request
Oct 9, 2026
* feat(gemini): add GeminiGateway integration for Google Gemini Port of identark/integrations/gemini.py: GeminiGateway (alias IdentArkGeminiGateway) on the optional @google/generative-ai peer dependency, with function calling, multimodal input, streaming, cost cap, local file URLs and Gemini error classification. Exposed at identark/integrations/gemini. * fix(gemini): stop classifying every SDK error as a rate limit The JS SDK prefixes every error with "[GoogleGenerativeAI Error]" and includes the generativelanguage.googleapis.com URL, both of which contain the substring "rate", so all failures became RateLimitError. Match keywords at word starts and use the HTTP status when present. --------- Co-authored-by: Kem-Ada <283358351+Kem-Ada@users.noreply.github.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
GeminiGateway(aliasIdentArkGeminiGateway), a port of the Python SDK'sidentark/integrations/gemini.py. It is published at the subpathidentark/integrations/geminiand is deliberately not re-exported from the barrel, the same as the LangChain and Vercel integrations. It depends on@google/generative-ai, added as an optional peer dependency. Python'sDirectGatewayhas no Gemini branch, so this PR does not touchDirectGateway.Python → TS parity mapping
identark/integrations/gemini.py)src/integrations/gemini.ts)GeminiGateway(api_key, model, system_prompt, cost_cap_usd, workspace_dir, safety_settings, generation_config)new GeminiGateway({ apiKey, model, systemPrompt, costCapUsd, workspaceDir, safetySettings, generationConfig, client? })ConfigurationErroron empty key/model or missing SDKcreateRequire, so construction stays sync.invoke_llm/invoke_llm_streaminvokeLlm/invokeLlmStreampersist_messages,request_file_url,get_session_cost,resetpersistMessages,requestFileUrl,getSessionCost,resethistory,model,providerpropertiesgetHistory(),getModel(),getProvider()(same asDirectGateway)_estimate_gemini_cost(private)estimateGeminiCost(exported for testing)_convert_tools_to_gemini,_convert_role_to_geminiconvertToolsToGemini,convertRoleToGemini_classify_gemini_error(substring ladder)_classifyGeminiError, same ladder and orderIdentArkGeminiGatewayaliasIdentArkGeminiGatewayDeliberate differences, all forced by the JS SDK's shapes:
functionResponse,inlineData.mimeType,functionDeclarations).JSON.stringify'd. Python usesstr(list), which is a repr and not portable.clientcan be injected. The tests use it, since the SDK is not a devDependency.Python quirks kept on purpose (rule 6):
tool_call_id.finish_reasonis always"stop".tool_choiceis accepted and ignored.Test plan
Gate, run from
identark-json branchfeat/gemini:tests/gemini-integration.test.ts.tests/unit/test_integrations_gemini.py.Errorrejections)Object.prototypemodel names in cost estimationControl-plane: untouched (check_scope OK)
🤖 Generated with Claude Code