Provider-specific Swarmauri import package for Google Gemini generateContent, streaming, function calling, tool use, and async LLM workflows.
Project description
Swarmauri Gemini LLM
swarmauri_llm_gemini provides provider-specific imports for Google Gemini
models in Swarmauri applications. It exports GeminiProModel for standard
generation and streaming workflows and GeminiToolModel for Gemini function
calling through Swarmauri toolkits.
The adapters use Google Gemini's generateContent and streamGenerateContent
API shape through generativelanguage.googleapis.com/v1beta. They translate
Swarmauri conversations into Gemini contents, apply safety settings, preserve
system instructions where supported by the implementation, and append generated
responses back to the conversation as AgentMessage instances.
Why Use This Package?
- Keep Google Gemini-specific dependencies explicit in provider-aware Swarmauri applications.
- Use the same Swarmauri
Conversation, message, and toolkit workflows across Gemini and other LLM providers. - Support both direct text generation and Gemini function-calling workflows.
- Stream Gemini responses through the same high-level Swarmauri model interface used by other provider packages.
FAQ
What does swarmauri_llm_gemini install?
It installs provider package entry points for GeminiProModel and
GeminiToolModel, both re-exported from swarmauri_standard.
Which Gemini API methods does it use?
GeminiProModel calls models.generateContent for standard prediction and
models.streamGenerateContent for streaming. GeminiToolModel uses
generateContent with Gemini-compatible function declarations converted from a
Swarmauri Toolkit.
Does this package support tools?
Yes. Use GeminiToolModel when a conversation should give Gemini access to
Swarmauri tools. The adapter converts toolkit schemas with
GeminiSchemaConverter, executes returned function calls, and can make a
follow-up model call with tool results.
Which models are listed by default?
The current implementation includes Gemini 2.0 Flash, Gemini 2.0 Flash Lite, Gemini 2.0 Pro experimental, Gemini 1.5 Flash, Gemini 1.5 Flash 8B, and Gemini 1.5 Pro in its allowed model list. Confirm current production model availability in Google's Gemini API documentation before pinning deployment defaults.
Can it include usage metadata?
GeminiProModel can attach token usage metadata to the returned Swarmauri
AgentMessage when include_usage is enabled and the provider response
contains usage metadata.
Features
GeminiProModelfor generation, async generation, streaming, and batch conversation workflows.GeminiToolModelfor Gemini function calling through Swarmauri toolkits.- Support for Gemini
systemInstruction/system_instructionpayloads in the current adapters. - Safety settings for harassment, hate speech, sexually explicit content, and dangerous content thresholds.
- Configurable generation controls such as
temperatureandmax_tokens. - Optional usage metadata handling on
GeminiProModel. - Compatibility with Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_llm_gemini
pip install swarmauri_llm_gemini
Prerequisites
Create a Gemini API key in Google AI Studio or Google Cloud and pass it to the
model constructor as api_key=....
Usage
from swarmauri_llm_gemini import GeminiProModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
conversation = Conversation()
conversation.add_message(HumanMessage(content="Write a concise project status update."))
model = GeminiProModel(api_key="GEMINI_API_KEY")
result = model.predict(conversation=conversation, max_tokens=200)
print(result.get_last().content)
Streaming
from swarmauri_llm_gemini import GeminiProModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
conversation = Conversation()
conversation.add_message(HumanMessage(content="List three risks for an AI release."))
model = GeminiProModel(api_key="GEMINI_API_KEY")
for token in model.stream(conversation=conversation, max_tokens=200):
print(token, end="")
Tool Calling
from swarmauri_llm_gemini import GeminiToolModel
from swarmauri_standard.conversations.Conversation import Conversation
from swarmauri_standard.messages.HumanMessage import HumanMessage
from swarmauri_standard.toolkits.Toolkit import Toolkit
conversation = Conversation()
conversation.add_message(HumanMessage(content="Use the available tool if needed."))
toolkit = Toolkit()
model = GeminiToolModel(api_key="GEMINI_API_KEY")
result = model.predict(conversation=conversation, toolkit=toolkit)
print(result.get_last().content)
Related Packages
- swarmauri_llm_anthropic
- swarmauri_llm_cohere
- swarmauri_llm_deepseek
- swarmauri_llm_groq
- swarmauri_llm_mistral
- swarmauri_llm_openai
Foundational Swarmauri Packages
Provider Documentation
Best Practices
- Store Gemini API keys in environment variables or a secrets manager.
- Confirm model availability against the current Gemini API before pinning model names for production.
- Use
GeminiToolModelonly when the workflow actually needs tool execution. - Keep tool schemas small and deterministic so Gemini can select and call tools reliably.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
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 swarmauri_llm_gemini-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_llm_gemini-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9160458530ff0660d2709ec23a876aaf4617cdb59081b690aecfba4a75aa91a
|
|
| MD5 |
08da430d9bf48fd75af19f2c7a724990
|
|
| BLAKE2b-256 |
a60c38972d6e0302e8dbdb743a47e295d6f5210d16af59027616c3a911ae34fa
|
File details
Details for the file swarmauri_llm_gemini-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_llm_gemini-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b569ed0283e83f6af01e5b12e89cce8703e89cded35d4ed8e0a63d00fb2f9d6
|
|
| MD5 |
8f0fca4fb5b6d7149a065849902ff572
|
|
| BLAKE2b-256 |
c5f0469554bbbb012a1cf23bab20d04e7820777983ec7e8494d67fd603256112
|