Skip to main content

gento

A lightweight LLM client.

Features

  • Unified Client Interface: Interact with multiple LLM providers (Gemini, OpenAI, Volcengine/Ark) via a single LLMClient.
  • Default Model Support: Defaults to google/gemini-3.5-flash if no model is specified during initialization, or set a default model for subsequent calls.
  • Environment-based Credentials: No need to hardcode API keys in the client — seamlessly picks up GEMINI_API_KEY, OPENAI_API_KEY, or VOLC_API_KEY / ARK_API_KEY.
  • Structured Pydantic Outputs: Validate and parse LLM outputs into Pydantic models with automatic retries on schema parse failures.
  • Tenacity Retry Logic: Automatic retry with exponential backoff and jitter for transient errors and schema validation failures.
  • Rate Limiting: Built-in rate limiting using aiolimiter.
  • Web Search: Grounding support with enable_search=True.

Installation

pip install gento

or with Poetry:

poetry add gento

Quick Start

Basic Text Generation

import asyncio
from gento import LLMClient

async def main():
    # Defaults to model="google/gemini-3.5-flash"
    client = LLMClient()

    # Generate response using default model
    response = await client.generate("Explain quantum computing in one sentence.")
    print("Content:", response.content)

    # Override model for specific call
    response_openai = await client.generate(
        "Explain special relativity in one sentence.",
        model="openai/gpt-4o"
    )
    print("OpenAI Content:", response_openai.content)

asyncio.run(main())

Structured Output with Pydantic

import asyncio
from pydantic import BaseModel, Field
from gento import LLMClient

class MovieInfo(BaseModel):
    title: str = Field(description="Title of the movie")
    release_year: int = Field(description="Release year")
    director: str = Field(description="Director of the movie")

async def main():
    client = LLMClient(model="google/gemini-3.5-flash")

    # Generate structured Pydantic model output
    movie: MovieInfo = await client.generate_structured(
        "Provide details about the movie Inception.",
        response_schema=MovieInfo,
    )

    print(f"Title: {movie.title}, Director: {movie.director}, Year: {movie.release_year}")

asyncio.run(main())

Web Search Grounding

import asyncio
from gento import LLMClient

async def main():
    client = LLMClient(model="google/gemini-3.5-flash")

    response = await client.generate(
        "What are the latest developments in AI technology this week?",
        enable_search=True,
    )
    print(response.content)

asyncio.run(main())

Supported Models & Provider Resolution

google/gemini-3.5-flash
google/gemini-3.6-flash
google/gemini-3.7-flash
openai/gpt-4o
openai/gpt-4o-mini
openai/gpt-5
openai/gpt-4o-mini
openai/gpt-4o
volcengine/doubao-1.5-pro-32k
volcengine/doubao-pro-32k

Environment Variables

  • Gemini: GEMINI_API_KEY
  • OpenAI: OPENAI_API_KEY (Optional: OPENAI_BASE_URL)
  • Volcengine/Ark: VOLCENGINE_API_KEY (Optional: VOLC_BASE_URL)

License

MIT

TODO

Do not retry if API error: File "/Users/kunlu/proj/gento/gento/adapters/gemini.py", line 119, in generate raise APIError(f"Gemini API error: {str(e)}") from e

File "/Users/kunlu/proj/gento/gento/adapters/gemini.py", line 117, in generate raise APIError(f"Gemini API error: {str(e)}") from e gento.exceptions.APIError: Gemini API error: Object of type ModelMetaclass is not JSON serializable

Release files for gento 0.1.1

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

Source distribution (sdist)

Source distribution for gento 0.1.1
File Size Uploaded
gento-0.1.1.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gento 0.1.1
File Interpreter ABI Platform
gento-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.5 kB

Release files / gento-0.1.1.tar.gz

Download URL gento-0.1.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
21247c92e5a084dc6d293bee45f1a793e38d19999d78b75eeebf44d92b2e5a5b
BLAKE2b-256 checksum
How to use checksums
58c55c4c73321a826dbee0aaf803187e23e77f0bc35afdfef9ec4c2ed7d5128a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.8 Darwin/24.6.0

Release files / gento-0.1.1-py3-none-any.whl

Download URL gento-0.1.1-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
886358cbcc9fb2c6174cd3b2baf8dd908ff19b5f76ad929ef104e5a7a717aeb2
BLAKE2b-256 checksum
How to use checksums
8bf6c0f75b262b3e4f49f9d6ebb8759d1ef58e78f10ff771ac6ff8811660bd27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.8 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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