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.

Download files

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

Source Distribution

metorial_google-1.0.5.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

metorial_google-1.0.5-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file metorial_google-1.0.5.tar.gz.

File metadata

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

File hashes

Hashes for metorial_google-1.0.5.tar.gz
Algorithm Hash digest
SHA256 e1fd08113c2d7590d75757ee3a15f3ae26476a13b6cec085ea595625cd66f715
MD5 46543b321a8d83b75455f940f6f5c604
BLAKE2b-256 cf31a525e5a99c94f18cb9ffe045f6c240585fb82b4de84a582cf17606344238

See more details on using hashes here.

Provenance

The following attestation bundles were made for metorial_google-1.0.5.tar.gz:

Publisher: release.yml on metorial/metorial-python

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

File details

Details for the file metorial_google-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for metorial_google-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9858f159691610dac2b16a94429076db2b37bfc0664df30b629d0b36c0a242fd
MD5 1387ff5bf6f92e276c61a63c43ffa151
BLAKE2b-256 21d62a4926344ce7a7b10742801ba6c9bc081f56a5d330a8d1a9fd15bb27a2cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for metorial_google-1.0.5-py3-none-any.whl:

Publisher: release.yml on metorial/metorial-python

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

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

Supported by

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