Add support for local/offline language models (Ollola, LM Studio, etc.)
What would you like to be added?
Support for local language models like Ollama, LM Studio, and other offline AI models that can run on-premises without cloud connectivity.
Why is this needed?
Enterprise organizations with strict data privacy requirements cannot use cloud-based AI services due to regulatory compliance (HIPAA, SOX, PCI-DSS, GDPR). Financial institutions, healthcare companies, government agencies, and defense contractors are prohibited from sending code or sensitive data to external cloud services. Recent security incidents have made enterprises even more cautious about cloud AI:
The Samsung incident where employees accidentally leaked source code to ChatGPT JPMorgan Chase restricting ChatGPT usage after code exposure concerns Multiple healthcare organizations blocking AI tools due to HIPAA violations
Meanwhile, local models like CodeLlama, StarCoder, and DeepSeek-Coder have reached production quality and can run effectively on modern hardware. Tools like Ollama make local model deployment trivial, but there's no way to integrate them with Gemini CLI. This creates a massive adoption barrier - entire enterprise development teams (thousands of potential users) cannot adopt Gemini CLI despite wanting to use it. Local model support would unlock this market while maintaining the superior UX that Gemini CLI provides.
Additional context
No response
This is doable I made a patch script to make it work with LM Studio OpenAI compatible API.
High-Level Approach
1. Core Concept
The Gemini CLI uses an authentication system to determine which AI service to connect to. We can add "local-model" as a new authentication type alongside the existing Google services.
2. Key Components to Modify
A. Create a Local Model Content Generator
- Create a new TypeScript class that implements the
ContentGeneratorinterface - This class translates between Gemini's message format and OpenAI's chat completion format
- Handles streaming responses from the local server
B. Add Local Model to Auth Types
In packages/core/src/core/contentGenerator.ts:
- Add
LOCAL_MODEL = 'local-model'to the AuthType enum - Add logic to instantiate your LocalModelContentGenerator when this auth type is selected
C. Update Authentication Validation
In packages/cli/src/config/auth.ts:
- Add validation that checks for
LOCAL_MODEL_ENDPOINTenvironment variable - Return appropriate error messages if configuration is missing
D. Update the Auth Dialog UI
In packages/cli/src/ui/components/AuthDialog.tsx:
- Add "Local Model" as an option in the authentication selection dialog
- Add detection logic for when LOCAL_MODEL_ENDPOINT is set
3. Environment Configuration
Users configure their local model via environment variables:
AUTH_METHOD=local-model
LOCAL_MODEL_ENDPOINT=http://[YOUR_LM_STUDIO_IP]:1234/v1/chat/completions
GEMINI_MODEL=[model_name_from_lm_studio]
I am not sure this is the forum for dropping the patch or if my patch works with the current version as I did this for version 0.1.17 and we are at 0.4.1 now, but if this hasn't been updated and there is interest I can make a gist.
@tibrownace I was wondering if you be interest in helping with my fork https://github.com/dloring1988/agent-cli as I am gearing this towards using all local providers along with gemini
@tibrownace I was wondering if you be interest in helping with my fork https://github.com/dloring1988/agent-cli as I am gearing this towards using all local providers along with gemini
broken link
@jodinathan get this one instead https://github.com/acoliver/llxprt-code
This issue has been automatically marked as stale due to 60 days of inactivity. It will be closed in 14 days if no further activity occurs.
Please drop the patch)
Google will always be preferential to their own, so LLXPRT is the best bet
This is doable I made a patch script to make it work with LM Studio OpenAI compatible API.
High-Level Approach
1. Core Concept
The Gemini CLI uses an authentication system to determine which AI service to connect to. We can add "local-model" as a new authentication type alongside the existing Google services.
2. Key Components to Modify
A. Create a Local Model Content Generator
* Create a new TypeScript class that implements the `ContentGenerator` interface * This class translates between Gemini's message format and OpenAI's chat completion format * Handles streaming responses from the local serverB. Add Local Model to Auth Types
In
packages/core/src/core/contentGenerator.ts:* Add `LOCAL_MODEL = 'local-model'` to the AuthType enum * Add logic to instantiate your LocalModelContentGenerator when this auth type is selectedC. Update Authentication Validation
In
packages/cli/src/config/auth.ts:* Add validation that checks for `LOCAL_MODEL_ENDPOINT` environment variable * Return appropriate error messages if configuration is missingD. Update the Auth Dialog UI
In
packages/cli/src/ui/components/AuthDialog.tsx:* Add "Local Model" as an option in the authentication selection dialog * Add detection logic for when LOCAL_MODEL_ENDPOINT is set3. Environment Configuration
Users configure their local model via environment variables:
AUTH_METHOD=local-model LOCAL_MODEL_ENDPOINT=http://[YOUR_LM_STUDIO_IP]:1234/v1/chat/completions GEMINI_MODEL=[model_name_from_lm_studio]
I am not sure this is the forum for dropping the patch or if my patch works with the current version as I did this for version 0.1.17 and we are at 0.4.1 now, but if this hasn't been updated and there is interest I can make a gist.
drop the patch
The local model support everyone is looking for is actually already available in the @google/gemini-cli-core SDK. The SDK was architected as a modular orchestrator, and you can bypass the cloud router natively using the OverrideStrategy.
I've implemented a bridge for this in Tars (github.com/agustinsacco/tars) using a custom LlamaCppGenerator.
How it works (Technical TL;DR):
- Bypass Cloud Pings: During initialization, passing a concrete model name (e.g.,
qwen-3b) instead ofautotrips theOverrideStrategy, which 'amputates' theClassifierStrategy(no cloud router, no API key required). - Tool-Calling Bridge: To make the core recognize local tool calls, you must map the model output to the
response.functionCallsprototype getter. This allows local models like Qwen 3.5 to participate in the exact same multi-turn tool-loops as Gemini Pro. - Future-Proof: Since this uses the standard
ContentGeneratorinterface, it doesn't require forking the core and remains compatible with upstream SDK updates.
If you want to test this today, you can run tars setup and select the Llama.cpp backend.
This is a feature request to add support for local/offline language models. It relates to the core agent's capabilities to interface with different models.
I write a https://github.com/WuJunkai2004/api-for-gemini for routing gemini cli's request to custom model provider, it may help you.
because the gemini will stop the service for non-enterprise user, I write it for continue using gemini cli.
I try antigravity cli but found it is actually a b*** ***t.
I have created Gemini-CLI fork and added local models support check it out OpenAgent
This item has been automatically marked as stale due to 60 days of inactivity. It will be closed in 14 days if no further activity occurs. Thank you!
This item has been closed due to 14 additional days of inactivity after being marked as stale. If you believe this is still relevant, feel free to comment or reopen. Thank you!