Gemini provider plugin for llm-sdk.
Project description
llm-sdk-provider-gemini
Gemini provider plugin for llm-sdk, implemented using google-genai (Vertex AI).
This package installs a provider plugin via Python entry points, enabling Gemini support without modifying the core SDK.
Table of Contents
- Overview
- Architecture
- Features
- Installation
- Usage
- Configuration
- Project Structure
- Development
- Testing
- Deployment
- Roadmap
- Contributing
- License
- Contact
Overview
llm-sdk-provider-gemini is a plugin package that adds support for:
- Gemini chat completions
- Gemini embeddings
- Gemini streaming chat
It integrates with the llm-sdk core using Python entry points, so the provider is automatically discoverable via:
sdk.registry.load_plugins()
Architecture
Plugin mechanism
This package declares an entry point:
[project.entry-points."llm_sdk.providers"]
gemini = "llm_sdk_provider_gemini.plugin:GeminiProviderFactory"
At runtime:
llm-sdkscans installed packages for llm_sdk.providers- Loads the GeminiProviderFactory
- Calls:
- spec() for metadata
- create(settings) to build a provider client
Features
- Async Gemini client
- Supports:
- chat completions
- embeddings
- streaming chat
- Uses google-genai (Vertex AI mode)
- Unified SDK error mapping (ProviderError)
- Strong typing
- Clean separation from SDK core
Installation
Install core SDK
pip install llm-sdk
Install Gemini provider
pip install llm-sdk-provider-gemini
Usage
Async quickstart
import asyncio
from llm_sdk.async_sdk import AsyncSDK
async def main() -> None:
sdk = AsyncSDK.default()
# Load installed plugins (entry points)
sdk.registry.load_plugins()
resp = await sdk.chat(
provider="gemini",
model="gemini-2.5-flash",
messages=[("user", "Write a haiku about software architecture.")],
)
print(resp.content)
if __name__ == "__main__":
asyncio.run(main())
Streaming example
import asyncio
from llm_sdk.async_sdk import AsyncSDK
async def main() -> None:
sdk = AsyncSDK.default()
sdk.registry.load_plugins()
async for ev in sdk.stream_chat(
provider="gemini",
model="gemini-2.5-flash",
messages=[("user", "Explain AI in Spanish, in 5 short bullets.")],
):
print(ev.delta, end="", flush=True)
print("\n[done]")
if __name__ == "__main__":
asyncio.run(main())
Embeddings example
import asyncio
from llm_sdk.async_sdk import AsyncSDK
async def main() -> None:
sdk = AsyncSDK.default()
sdk.registry.load_plugins()
resp = await sdk.embed(
provider="gemini",
model="text-multilingual-embedding-002",
input=["Hola mundo", "Hello world"],
)
print(resp.vectors[0][:10])
if __name__ == "__main__":
asyncio.run(main())
Configuration
This provider uses Google credentials from the environment.
Authentication (Vertex AI)
You must have:
- Google Cloud project enabled for Vertex AI
- Proper credentials available through ADC (Application Default Credentials)
Typical local setup:
gcloud auth application-default login
Provider-specific settings
This package typically reads:
- Gemini location (example:
us-central1)
Depending on your llm-sdk settings design, you may configure:
export LLM_SDK_LOCATION="us-central1"
Or if you implement namespaced settings:
export LLM_SDK_GEMINI_LOCATION="us-central1"
Project Structure
llm-sdk-provider-gemini/
├─ src/
│ └─ llm_sdk_provider_gemini/
│ ├─ plugin.py
│ ├─ settings.py
│ ├─ async_client.py
│ ├─ sync_client.py
│ └─ __init__.py
├─ tests/
│ ├─ test_factory.py
│ └─ test_contracts.py
├─ pyproject.toml
└─ README.md
Setup
Development
python -m venv venv
source venv/bin/activate
pip install -U pip
pip install -e .
Install core SDK in editable mode (local dev)
pip install -e ../llm-sdk
Testing
pytest -q
Notes
Provider tests should include:
- Factory loads correctly
- Spec metadata is correct
- Client implements required methods
- Error mapping works as expected
Avoid real network tests in unit tests. If you want integration tests, put them behind an env flag.
Deployment
Build package
python -m build
Upload to TestPyPI
python -m twine upload --repository testpypi dist/*
Upload to PyPI
python -m twine upload dist/*
Roadmap
- Better usage extraction for Gemini responses
- Support for Gemini tool calling (if SDK adds tool abstractions)
- Optional support for non-Vertex Gemini API mode
- Optional response caching hooks
Contributing
PRs welcome.
Recommended workflow:
- Fork repo
- Create a feature branch
- Add tests
- Run pytest
- Submit PR
License
MIT License
Contact
Author: Esteban Flores
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_sdk_provider_gemini-0.1.3.tar.gz.
File metadata
- Download URL: llm_sdk_provider_gemini-0.1.3.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f09091b5804b5aeff0f52fb757a5b3286e5d2209e1451e76aec87cec2f9bb43
|
|
| MD5 |
1ec5d03544f9e15632e6e283721339ef
|
|
| BLAKE2b-256 |
4374ef40f840fca74ec9c8d50b8377823c3ebef3a304d007851b253f468e5a5c
|
File details
Details for the file llm_sdk_provider_gemini-0.1.3-py3-none-any.whl.
File metadata
- Download URL: llm_sdk_provider_gemini-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34532e7b643ade33ff2f14cd7d81e2f225d76eeaaec293dd36116c202fc891fa
|
|
| MD5 |
6d4b9bf104c44b716fc112f61641a862
|
|
| BLAKE2b-256 |
dcba34bc38cc0a8024907f86ffcc83448ed1857bba165d29c6665fda7e3550a9
|