ceveyne's profile picture
ceveyne

gemini-compat-endpoint

Public

Gemini Pro Image Compatibility Endpoint for LM Studio

249 Downloads

3 stars

2 forks

README

Gemini Compatibility Endpoint for LM Studio

An LM Studio plugin that provides access to Google Gemini models, including native image generation, within the LM Studio chat interface.

Features

  • Image-based reasoning — Vision Promotion carries attached and generated images forward across conversation turns, allowing the model to reason about visual context without manual re-uploads.
  • Native image generation and editing — Gemini 3 Pro Image produces images as part of the conversation stream. Iterative edits ("make the background darker", "remove the text") work against the model's own output, preserving context between rounds.
  • Thinking / reasoning — Both models expose their reasoning process. Thoughts appear in a collapsible block in the LM Studio UI.
  • LM Studio tool compatibility — Existing tool definitions (function calling) are forwarded to Gemini as native function declarations.

Setup

API Key

  • Obtain an API key from Google AI Studio → Keys.
  • In LM Studio, open the plugin's Global Settings and paste the key into Google AI Studio API Key.

No Google Cloud project, service account, or IAM configuration is required.

Vision Capability Primer

LM Studio currently gates image attachments on whether a vision-capable model is loaded on the client side. Since this plugin registers as a generator rather than a local model, LM Studio does not recognise its vision capabilities and blocks image uploads.

Image upload blocked in LM Studio

The workaround is called vision-capability-priming: download the helper model qwen/qwen3-vl-4b to your local machine. The plugin detects its presence and uses it to signal vision support to the LM Studio client. The model is not used for inference and does not require GPU resources.

This is tracked upstream as lmstudio-ai/lmstudio-js#459.

Supported Models

ModelCapabilitiesTypical use
gemini-3-pro-image-previewMultimodal generation (text + images), up to 14 reference images, native editingImage creation, iterative refinement, design exploration
gemini-3.1-pro-previewText reasoning, configurable thinking depth (Low / Medium / High), tool useAnalysis, coding, research, multi-step tasks

Model names follow Google's preview naming convention. See the Gemini model documentation for current availability.

Vision Promotion

Most chat interfaces discard image context after a single turn. Vision Promotion addresses this by automatically re-injecting relevant images — both user-attached and model-generated — into subsequent requests. This enables the model to reason about, compare, or edit images across multiple turns.

Two transport modes are available, toggled per chat via Use Files for Vision:

ModeMechanismTrade-off
Base64Images embedded inline as JPEG previewsSimpler; higher per-request payload
Files APIImages uploaded once to Google's temporary storage, referenced by URILower bandwidth; better for longer sessions

Configuration

Per-Chat Settings

SettingDescriptionDefault
ModelGemini model to usegemini-3-pro-image-preview
Thinking LevelReasoning depth for Gemini 3.1 ProLow
Show Only Last Image VariantSuppress intermediate images, display only the final variantOn
Use Files for VisionRoute image promotion through Google Files APIOn

Global Settings

SettingDescriptionDefault
Vision Promotion: PersistentRe-inject images every turn rather than only when newOff
Google AI Studio API KeyAPI key (AIza...)—

Debug Settings

SettingDescription
Log ChunksVerbose streaming and tool-call event logging
Log RequestsFull request/response JSON (may expose sensitive data)

Architecture

The plugin uses a strategy pattern to route generation to the appropriate handler:

  • GeminiThinkingStrategy — gemini-3.1-pro-preview: streaming generation with configurable thinking levels and thought-signature persistence across turns.
  • GeminiImageThinkingStrategy — gemini-3-pro-image-preview: image generation pipeline with native multimodal output, variant tracking, and edit support.

Both strategies share a common base for message conversion, tool handling, and vision promotion.

Thought signatures — opaque tokens required by Gemini for multi-turn reasoning context — are persisted and replayed automatically. When thinking and tool calls co-occur, the plugin restructures conversation history to satisfy API constraints.

Development

npm install          # Install dependencies
npm run build        # Build
npm run rebuild      # Clean build
npm run dev          # Dev server

Credits

Based on the LM Studio openai-compat-endpoint plugin template.

Licence

MIT