Skip to main content

lmux-google

Google (Gemini) provider for lmux. Wraps the google-genai SDK, which serves Google's models through either backend:

  • Vertex AI (default) — authenticated with Google Cloud credentials
  • Gemini Developer API (AI Studio) — authenticated with an API key (vertexai=False)

Supports chat completions, streaming, and embeddings for Google-published models: Gemini and the Gemini/text embedding models.

Part of the lmux ecosystem: standardized interface, cost tracking on every response, and registry-based routing across providers.

Auth

Three authentication methods:

Application Default Credentials (default)

Uses google.auth.default(), which works with GOOGLE_APPLICATION_CREDENTIALS, gcloud CLI, or instance metadata.

from lmux_google import GoogleProvider

provider = GoogleProvider(project="my-project", location="us-central1")

Service Account

from lmux_google import GoogleServiceAccountAuthProvider

provider = GoogleProvider(
    project="my-project",
    location="us-central1",
    auth=GoogleServiceAccountAuthProvider(service_account_file="/path/to/key.json"),
)

API Key

Set GOOGLE_API_KEY in your environment:

from lmux_google import GoogleAPIKeyAuthProvider

provider = GoogleProvider(auth=GoogleAPIKeyAuthProvider(), vertexai=False)

Usage

Chat

from lmux import UserMessage

response = provider.chat("gemini-2.5-pro", [UserMessage(content="Hello")])
print(response.content)
print(response.cost)

Streaming

for chunk in provider.chat_stream("gemini-2.5-pro", [UserMessage(content="Hello")]):
    if chunk.delta:
        print(chunk.delta, end="")

Embeddings

response = provider.embed("text-embedding-005", "Hello")
print(response.embeddings)

Async

All methods have async variants: achat, achat_stream, aembed.

Registry

Use with the lmux registry to route across multiple providers:

from lmux import Registry

registry = Registry()
registry.register("google", provider)
response = registry.chat("google/gemini-2.5-pro", messages)

Provider Params

from lmux_google import GoogleParams

response = provider.chat(
    "gemini-2.5-pro",
    messages,
    provider_params=GoogleParams(thinking_config={"thinking_budget": 1024}),
)
Parameter Type Description
safety_settings list[SafetySetting] Content safety thresholds
presence_penalty float Presence penalty
frequency_penalty float Frequency penalty
seed int Deterministic sampling seed
labels dict[str, str] Request labels
thinking_config dict Thinking/reasoning configuration

Constructor Options

GoogleProvider(
    auth=...,       # AuthProvider, default: GoogleADCAuthProvider()
    project=...,    # GCP project ID
    location=...,   # GCP region
    vertexai=...,   # Use Vertex AI (default: True) vs. AI Studio
)

Download files

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

Source Distribution

lmux_google-0.8.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

lmux_google-0.8.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file lmux_google-0.8.1.tar.gz.

File metadata

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

File hashes

Hashes for lmux_google-0.8.1.tar.gz
Algorithm Hash digest
SHA256 a78ba346a5c978c9ea33fe511914d329f540f0819836adb46846488a0e370d81
MD5 2ce3c71cbbd5306bd5efdb49bc25f99f
BLAKE2b-256 167d2bd7a755148ee568aeb1fe60440a6290279ef73051c52f55aa1f72f23fc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_google-0.8.1.tar.gz:

Publisher: publish.yml on cluebbehusen/lmux

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

File details

Details for the file lmux_google-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: lmux_google-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lmux_google-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9be5e817ab52c7c25be75b30472e186a5809a06a650257854f1085ecfe553b5
MD5 72d0a909ecedb7ab0378e8995d5f403a
BLAKE2b-256 1a314a1b9c48f2c0acfd6e081acff6701c9b4662b1ad5d1058098639d9abf3f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_google-0.8.1-py3-none-any.whl:

Publisher: publish.yml on cluebbehusen/lmux

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 Sentry Error logging StatusPage Status page