Skip to main content

LLM plugin to access Google's Gemini via Code Assist API with OAuth

Project description

llm-gemini-code-assist

PyPI Changelog Tests License

API access to Google's Gemini models via the Code Assist API with OAuth authentication.

This is a fork of llm-gemini modified to use Google's Code Assist API, which requires OAuth authentication instead of API keys.

Installation

Install this plugin in the same environment as LLM:

llm install llm-gemini-code-assist

Authentication

Unlike the standard llm-gemini plugin, this version uses OAuth authentication with the Code Assist API. Authentication generally is automatic if you have gemini-cli installed; else, you can authenticate manually:

llm gemini-ca auth

This will:

  1. Open your browser to Google's OAuth consent page
  2. After you approve, save credentials to ~/.gemini/oauth_creds.json
  3. The credentials include a refresh token for automatic renewal

The OAuth credentials are stored with file permissions 0600 for security.

Usage

Once authenticated, use the models with the gemini-ca/ prefix:

llm -m gemini-ca/gemini-2.5-flash "Tell me a joke about a pelican"

You can set it as your default model:

llm models default gemini-ca/gemini-2.5-flash
llm "Tell me a joke about a pelican"

Available Models

Models available via Code Assist API with the gemini-ca/ prefix:

  • gemini-ca/gemini-3-pro-preview - Gemini 3 Pro (preview)
  • gemini-ca/gemini-3-flash-preview - Gemini 3 Flash (preview)
  • gemini-ca/gemini-2.5-pro - Gemini 2.5 Pro
  • gemini-ca/gemini-2.5-flash - Gemini 2.5 Flash
  • gemini-ca/gemini-2.5-flash-lite - Gemini 2.5 Flash Lite

See gemini-cli model configs for the canonical model list.

Model Latency

Typical response times for a simple prompt (tested January 2026):

Model Avg (ms) Notes
gemini-2.5-flash-lite ~1200 Fastest
gemini-2.5-flash ~1500
gemini-3-flash-preview ~1900 Preview
gemini-2.5-pro ~4000 High variance
gemini-3-pro-preview ~4500 Preview

Note: Code Assist API has rate limits (~3 requests/minute). Use scripts/profile_request.py to benchmark.

Features

All features from llm-gemini are supported:

Multi-modal Input

llm -m gemini-ca/gemini-2.5-flash 'describe image' -a image.jpg

JSON Output

llm -m gemini-ca/gemini-2.5-flash -o json_object 1 \
  '3 largest cities in California'

Code Execution

llm -m gemini-ca/gemini-2.0-flash -o code_execution 1 \
  'calculate factorial of 13'

Google Search

llm -m gemini-ca/gemini-2.5-flash -o google_search 1 \
  'What happened today?'

Chat

llm chat -m gemini-ca/gemini-2.5-flash

Troubleshooting

If you get authentication errors:

  1. Check if your credentials are expired:

    cat ~/.gemini/oauth_creds.json | python -m json.tool
    
  2. Re-authenticate:

    llm gemini-ca auth
    

Development

To set up the development environment:

cd llm-gemini-code-assist
uv sync
uv run pre-commit install

This installs dependencies and sets up pre-commit hooks (including secret scanning).

Run tests:

uv run pytest

The pre-commit hooks will automatically run linting, formatting, type checking, and secret scanning before each commit. You can also run them manually:

uv run pre-commit run --all-files

Releasing

Releases are tag-driven and automated via GitHub Actions.

# 1. Ensure tests pass
uv run pytest

# 2. Create and push a version tag (triggers release workflow)
git tag v0.27.0
git push origin v0.27.0

This will automatically build the package, create a GitHub Release with changelog, and publish to PyPI.

Differences from llm-gemini

  • Uses OAuth authentication instead of API keys
  • Requires Code Assist API access
  • Models use gemini-ca/ prefix
  • Tokens auto-refresh using stored refresh tokens

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_gemini_code_assist-0.28.2.tar.gz (141.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_gemini_code_assist-0.28.2-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file llm_gemini_code_assist-0.28.2.tar.gz.

File metadata

  • Download URL: llm_gemini_code_assist-0.28.2.tar.gz
  • Upload date:
  • Size: 141.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llm_gemini_code_assist-0.28.2.tar.gz
Algorithm Hash digest
SHA256 fbd4b6d0ed032f6d405f5d8dec9ff29f6503c3c873d754d01e92449f32e8155b
MD5 948fd34856d92980540720bfc9ea0d05
BLAKE2b-256 72aac6324e93e18efa8f7db4185eb78f523ab856548b11dbd0cf3dc62e23274d

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_gemini_code_assist-0.28.2.tar.gz:

Publisher: publish.yml on lokkju/llm-gemini-code-assist

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_gemini_code_assist-0.28.2-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_gemini_code_assist-0.28.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9bd0460d3a2e89a94673baf327ccc787a363196d49c9072bea87d1ce549e5c8e
MD5 c62ed663b5056636d14849bda43fa157
BLAKE2b-256 400e057e962cc703d0716776da45465ebba956b5abeb13a8807bf239519cbd37

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_gemini_code_assist-0.28.2-py3-none-any.whl:

Publisher: publish.yml on lokkju/llm-gemini-code-assist

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page