Skip to main content

A minimal, ergonomic Python library for interacting with LLMs

Project description

llmini

A minimal, ergonomic Python library for interacting with LLMs. Built on top of LiteLLM.

Features

  • Unified LLM access — works with Anthropic, OpenAI, and any LiteLLM-supported provider
  • Tool calling — define tools as Python functions, schemas are auto-generated from type hints and docstrings
  • Structured output — parse LLM responses into Pydantic models
  • Image support — send images in messages with automatic base64 encoding
  • Approval gating — mark tools as requiring approval before execution
  • Message serialization — export conversations as JSON or JSONL
  • Zero config — works out of the box with environment variables for API keys

Installation

uv add llmini

# or
pip install llmini

Quick Start

from llmini import ModelConfig, complete, system_message, user_message

reply = complete(
    model=ModelConfig(model="anthropic/claude-3-5-haiku-latest"),
    messages=[
        system_message("You are a helpful assistant."),
        user_message("What is the capital of France?"),
    ],
)

print(reply.content)  # "The capital of France is Paris."

With tools:

from llmini import ModelConfig, complete, system_message, user_message, make_tool

@make_tool()
def get_weather(location: str) -> str:
    """Get the current weather at a location."""
    return "Sunny, 22°C"

reply = complete(
    model=ModelConfig(model="anthropic/claude-3-5-haiku-latest"),
    messages=[
        system_message("You are a helpful assistant."),
        user_message("How's the weather in Paris?"),
    ],
    tools=[get_weather],
)

Building a tool-using agent loop: see examples/test_04_agent.py.

Documentation

  • USAGE.md — full API reference with all parameters, defaults, and detailed examples
  • examples/ — runnable example scripts

License

MIT

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

llmini-1.0.0.tar.gz (169.3 kB view details)

Uploaded Source

Built Distribution

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

llmini-1.0.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file llmini-1.0.0.tar.gz.

File metadata

  • Download URL: llmini-1.0.0.tar.gz
  • Upload date:
  • Size: 169.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for llmini-1.0.0.tar.gz
Algorithm Hash digest
SHA256 551ec2ff57211d82e31ef84643a8d3fcdaa6ec5f8464855524860b8932410938
MD5 5a6f4fc2b42ed47a821fd63498d68b4f
BLAKE2b-256 9536f2f525fc8ae7ae69885f4f93e5155325472a564641c04635f1110e621f75

See more details on using hashes here.

File details

Details for the file llmini-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: llmini-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for llmini-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d818b736be1dd5c6c72a6f30733fa4c7f0c117c335594bf96a604180da5c2b8
MD5 db14415b1a4892ac828ef17a7a0d2f56
BLAKE2b-256 3651aaae3da79e2350dc7d28fe2677ca98821885e0dc93692f108a60685fa2c5

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