Skip to main content

LLMCall

PyPI version Python versions License Tests Downloads

A lite abstraction layer for LLM calls.

Motivation

As AI becomes more prevalent in software development, there's a growing need for simple and intuitive APIs for
interacting with AI for quick text generation, decision making, and more. This is especially important now that we
have structured outputs, which allow us to seamlessly integrate AI into our application flow.

llmcall provides a minimal intelligence interface for common LLM operations without unnecessary complexity.

Installation

pip install llmcall

Quick Start

# 1. Install
pip install llmcall

# 2. Set your API key (copy .env.example to .env and fill in your key)
cp .env.example .env
# 3. Use it
from llmcall import generate

response = generate("What is the capital of France?")
print(response)  # Paris

Configuration

Copy .env.example to .env and set your values:

# Required
LLMCALL_API_KEY=sk-...

# Optional (defaults)
LLMCALL_MODEL=openai/gpt-4.1
LLMCALL_BASE_URL=          # customise for Ollama, Azure, LM Studio, etc.
LLMCALL_DEBUG=false

Or set environment variables directly:

export LLMCALL_API_KEY=sk-...

Uses LiteLLM under the hood — any supported provider works. We recommend OpenAI models for structured outputs.

Using local models (Ollama)

LLMCALL_MODEL=ollama/llama3.2
LLMCALL_BASE_URL=http://localhost:11434
LLMCALL_API_KEY=ollama

Example Usage

Generation

from llmcall import generate, generate_decision
from pydantic import BaseModel

# i. Basic generation
response = generate("Write a story about a fictional holiday to the sun.")

# ii. Structured generation
class ResponseSchema(BaseModel):
    story: str
    tags: list[str]

response: ResponseSchema = generate(
    "Create a rare story about the history of civilisation.",
    output_schema=ResponseSchema,
)

# iii. Streaming — get tokens as they arrive
for chunk in generate("Tell me a joke.", stream=True):
    print(chunk, end="", flush=True)

# iv. Decision making
decision = generate_decision(
    "Which is bigger?",
    options=["apple", "berry", "pumpkin"],
)
print(decision.selection)  # pumpkin
print(decision.reason)     # Pumpkins are significantly larger than...

Async generation

import asyncio
from llmcall import agenerate, agenerate_decision, aextract

# Async generate
response = await agenerate("Write a story about a fictional holiday to the sun.")

# Async streaming
async for chunk in await agenerate("Tell me a joke.", stream=True):
    print(chunk, end="", flush=True)

# Async decision
decision = await agenerate_decision("Which is bigger?", options=["apple", "berry", "pumpkin"])

# Async extract
result = await aextract(text=my_text, output_schema=MySchema)

# Run concurrently
story, decision = await asyncio.gather(
    agenerate("Write a story."),
    agenerate_decision("Which language?", options=["Python", "Go", "Rust"]),
)

Extraction

from llmcall import extract, extract_pdf, extract_image
from pydantic import BaseModel

class EmailSchema(BaseModel):
    email_subject: str
    email_body: str
    email_topic: str
    email_sentiment: str

# i. Extract from plain text
text = """To whom it may concern, Request for Admission at Harvard University ..."""
result: EmailSchema = extract(text=text, output_schema=EmailSchema)

# ii. Extract from a PDF — URL, local path, or raw bytes all work
class InvoiceSchema(BaseModel):
    vendor: str
    total: float
    line_items: list[str]

result: InvoiceSchema = extract_pdf(
    source="https://example.com/invoice.pdf",
    output_schema=InvoiceSchema,
)
# local file
result: InvoiceSchema = extract_pdf(source="/path/to/invoice.pdf", output_schema=InvoiceSchema)
# raw bytes
with open("invoice.pdf", "rb") as f:
    result: InvoiceSchema = extract_pdf(source=f.read(), output_schema=InvoiceSchema)

# iii. Extract from an image — URL, local path, or raw bytes all work
class ReceiptSchema(BaseModel):
    store: str
    total: float
    items: list[str]

result: ReceiptSchema = extract_image(
    source="https://example.com/receipt.jpg",
    output_schema=ReceiptSchema,
)
# local PNG (MIME type auto-detected from extension)
result: ReceiptSchema = extract_image(source="/path/to/receipt.png", output_schema=ReceiptSchema)
# raw bytes with explicit MIME type
with open("receipt.webp", "rb") as f:
    result: ReceiptSchema = extract_image(source=f.read(), output_schema=ReceiptSchema, media_type="image/webp")

Model requirements: PDF extraction requires a model with document-understanding support (e.g. anthropic/claude-sonnet-4-6, openai/gpt-4.1, google/gemini-3-flash-preview). Image extraction requires a vision-capable model. An informative ValueError is raised if the configured model does not support the required capability.

Async multimodal extraction

from llmcall import aextract_pdf, aextract_image
import asyncio

invoice, receipt = await asyncio.gather(
    aextract_pdf("https://example.com/invoice.pdf", InvoiceSchema),
    aextract_image("https://example.com/receipt.jpg", ReceiptSchema),
)

Roadmap

  • Simple API for generating unstructured text
  • Structured output generation using Pydantic
  • Decision making
  • Custom model selection (via LiteLLM - See documentation)
  • Custom base URL for OpenAI-compatible endpoints (Ollama, Azure, LM Studio)
  • Structured text extraction
  • Structured extraction from PDF (URL, local path, or bytes)
  • Structured extraction from Images (URL, local path, or bytes)
  • Structured text extraction from Websites
  • Async support (agenerate, aextract, aextract_pdf, aextract_image, agenerate_decision)
  • Streaming support (generate(..., stream=True), agenerate(..., stream=True))

Documentation

Please refer to our comprehensive documentation to learn more about this tool.

Metadata

Release files for llmcall 1.0.0

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

Source distribution (sdist)

Source distribution for llmcall 1.0.0
File Size Uploaded
llmcall-1.0.0.tar.gz 13.7 kB Details

Built distribution (wheel)

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

Total release size: 27.1 kB

Release files / llmcall-1.0.0.tar.gz

Download URL llmcall-1.0.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4c5561e432d2ed82232f3270a5d75482ddf7d8c5bd8b4cdf1d956f8296447d30
BLAKE2b-256 checksum
How to use checksums
93ba3ac3619c448b543686dd0779b76f6273e2e03d013751385a5ec2fd4b3fbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Sep 28, 2026.

Transparency log

Release files / llmcall-1.0.0-py3-none-any.whl

Download URL llmcall-1.0.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
367ead0b27774e8e0548009d7103ec0817c854df6c28e5c2c7f6e8b076f3cff6
BLAKE2b-256 checksum
How to use checksums
f85b4637f57aa3ed71b73358a62021e497edce9b964b7bfc48da736fb83ee2cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Sep 28, 2026.

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