Skip to main content

A unified toolkit for working with multiple LLM providers

Project description

llm-kit

llm-kit is a unified, async-first Python toolkit for interacting with multiple Large Language Model (LLM) providers through a consistent, provider-agnostic API.

It supports:

  • Multiple LLM providers (OpenAI, Gemini, Anthropic, etc.)
  • Text and structured JSON generation
  • Multimodal inputs (PDFs, images, text files)
  • Clean abstractions and strong typing

✨ Core Ideas

1. Outputs are explicit

LLMs generate outputs, not OCR results.

llm-kit exposes two primary operations:

  • generate_text → free-form text
  • generate_json → structured, schema-driven output

2. Inputs can be text and/or files

Files (PDFs, images, etc.) are first-class inputs and can be passed directly to generation methods.

OCR and file parsing are treated as provider implementation details.


📦 Installation

pip install llm-kit

Optional provider support (example):

pip install llm-kit[openai]
pip install llm-kit[gemini]

🚀 Quick Start

Text-only generation

text = await llm.generate_text(
    prompt="Explain what power factor is in simple terms"
)

Text generation with a file (PDF, image, etc.)

from llm_kit.core import LLMFile

pdf = LLMFile(
    content=pdf_bytes,
    mime_type="application/pdf",
    filename="bill.pdf",
)

summary = await llm.generate_text(
    prompt="Summarize this electricity bill",
    files=[pdf],
)

Structured JSON extraction

schema = {
    "type": "object",
    "properties": {
        "consumer_name": {"type": "string"},
        "bill_amount": {"type": "number"},
        "due_date": {"type": "string"},
    },
    "required": ["consumer_name", "bill_amount"],
}

data = await llm.generate_json(
    prompt="Extract billing details from this document",
    schema=schema,
    files=[pdf],
)

🧠 Design Philosophy

  • Provider-agnostic: No OpenAI/Gemini specifics in the public API
  • Async-first: Built for modern Python backends
  • Composable: Easy to plug into pipelines (FastAPI, background jobs, ETL)
  • Explicit contracts: Clear separation of inputs, outputs, and providers

🧩 Core Abstractions

BaseLLMClient

All providers implement the same interface:

class BaseLLMClient:
    async def generate_text(...)
    async def generate_json(...)

LLMFile

A provider-agnostic representation of file inputs:

from llm_kit.core import LLMFile

🔌 Providers

Each provider is implemented as an adapter that conforms to BaseLLMClient.

Supported / planned:

  • OpenAI
  • Gemini
  • Anthropic
  • Local / OSS models (future)

🛠 Development

Install dependencies

poetry install

Format & lint

poetry run ruff check . --fix
poetry run black .

Run tests

poetry run pytest

📍 Status

🚧 Under active development

The public API is stabilizing. Expect rapid iteration until v1.0.


📄 License

MIT License

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

llm_kit_pro-0.1.3.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

llm_kit_pro-0.1.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file llm_kit_pro-0.1.3.tar.gz.

File metadata

  • Download URL: llm_kit_pro-0.1.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for llm_kit_pro-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9a3dc997739f7bc12c6a7a918d23ba14f07d1fab50a1375f628248417f1414c6
MD5 3d4e2e3f2848cbf185393433ab03c8c0
BLAKE2b-256 c4ed292991874d06fef6396c214e31232cc84559828e9f3d583e5110d3d8a2e6

See more details on using hashes here.

File details

Details for the file llm_kit_pro-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: llm_kit_pro-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for llm_kit_pro-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 aa2629be8efd7d3067a9a1e248a8f85d40d16df5fabeb3339c41afcb1c59917f
MD5 305a1afa5d5416ccd832dee3d2ef87fe
BLAKE2b-256 2a1a83bf50f8b510acff3270cd7de2c6a67af96694f5d0d7777d4c7bd7ab61e8

See more details on using hashes here.

Supported by

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