Skip to main content

metorial-google

Google (Gemini) provider integration for Metorial.

Installation

pip install metorial google-generativeai

Quick Start

import asyncio
from metorial import Metorial, MetorialGoogle
import google.generativeai as genai

metorial = Metorial(api_key="your-metorial-api-key")
genai.configure(api_key="your-google-api-key")

async def main():
    async def session_handler(session):
        model = genai.GenerativeModel(
            model_name="gemini-2.5-flash",
            tools=session["tools"]
        )

        response = await model.generate_content_async("What's the latest news?")

        # Handle function calls if present
        # ... tool call handling logic

        await session["closeSession"]()

    await metorial.with_provider_session(
        MetorialGoogle,
        {"serverDeployments": [{"serverDeploymentId": "your-server-deployment-id"}]},
        session_handler
    )

asyncio.run(main())

Streaming

import asyncio
from metorial import Metorial, MetorialGoogle
import google.generativeai as genai

metorial = Metorial(api_key="your-metorial-api-key")
genai.configure(api_key="your-google-api-key")

async def main():
    async def session_handler(session):
        model = genai.GenerativeModel(
            model_name="gemini-2.5-flash",
            tools=session["tools"]
        )

        response = await model.generate_content_async(
            "What's the latest news?",
            stream=True
        )

        async for chunk in response:
            print(chunk.text, end="", flush=True)

        await session["closeSession"]()

    await metorial.with_provider_session(
        MetorialGoogle,
        {
            "serverDeployments": [{"serverDeploymentId": "your-server-deployment-id"}],
            "streaming": True,  # Required for streaming with tool calls
        },
        session_handler
    )

asyncio.run(main())

Supported Models

  • gemini-2.5-pro: Most capable Gemini model
  • gemini-2.5-flash: Fast Gemini model
  • gemini-pro: Gemini Pro

Session Object

async def session_handler(session):
    tools = session["tools"]           # Tool definitions in Gemini format
    call_tools = session["callTools"]  # Execute tools and get responses
    close_session = session["closeSession"]  # Close the session when done

Error Handling

from metorial import MetorialAPIError

try:
    await metorial.with_provider_session(...)
except MetorialAPIError as e:
    print(f"API Error: {e.message} (Status: {e.status})")
except Exception as e:
    print(f"Unexpected error: {e}")

License

MIT License - see LICENSE file for details.

Metadata

Release files for metorial-google 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metorial-google 1.0.5
File Size Uploaded
metorial_google-1.0.5.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metorial-google 1.0.5
File Interpreter ABI Platform
metorial_google-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / metorial_google-1.0.5.tar.gz

Download URL metorial_google-1.0.5.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e1fd08113c2d7590d75757ee3a15f3ae26476a13b6cec085ea595625cd66f715
BLAKE2b-256 checksum
How to use checksums
cf31a525e5a99c94f18cb9ffe045f6c240585fb82b4de84a582cf17606344238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.

Transparency log

Release files / metorial_google-1.0.5-py3-none-any.whl

Download URL metorial_google-1.0.5-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9858f159691610dac2b16a94429076db2b37bfc0664df30b629d0b36c0a242fd
BLAKE2b-256 checksum
How to use checksums
21d62a4926344ce7a7b10742801ba6c9bc081f56a5d330a8d1a9fd15bb27a2cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 23, 2025.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page