Skip to main content

callm

Keep callm and process thousands of requests without (rate) limits

PyPI version Python versions License

Installation • Quick Start • Providers • Examples • Contributing


😌 Why callm?

Building LLM-powered applications often means processing thousands of API requests. You've probably experienced:

Problem Without callm With callm
Rate limit errors Constant 429 errors, manual sleep/retry Automatic RPM & TPM throttling
Retry logic Write custom backoff for each project Built-in exponential backoff with jitter
Token tracking No visibility into usage Real-time token consumption metrics
Boilerplate code Copy-paste the same async code everywhere One function call, any provider
Waiting for batch APIs Provider batch APIs take up to 24 hours Results in minutes, not hours
Multiple SDKs Install openai, anthropic, cohere, ... One library, all providers

Stop rewriting the same parallel processing code. callm handles the infrastructure so you can focus on your application.

Testing multiple providers? Just swap the provider class—no new dependencies, no code changes. Find what works best for your use case.

Installation

pip install callm-py

From source:

git clone https://github.com/milistu/callm.git
cd callm
pip install -e .

Quick Start

Process 1,000 product descriptions to extract structured data—in under a minute:

import asyncio
from callm import process_requests, RateLimitConfig
from callm.providers import OpenAIProvider

# Configure your provider
provider = OpenAIProvider(
    api_key="sk-...",
    model="gpt-5-mini",
    request_url="https://api.openai.com/v1/responses",
)

# Your data processing requests
products = [
    {"id": 1, "description": "Nike Air Max 90 - Classic sneakers in white/black, size 10"},
    {"id": 2, "description": "Sony WH-1000XM5 Wireless Headphones - Noise cancelling, 30hr battery"},
    # ... thousands more
]

requests = [
    {
        "input": f"Extract brand, category, and key features from: {p['description']}",
        "metadata": {"product_id": p["id"]},
    }
    for p in products
]

async def main():
    results = await process_requests(
        provider=provider,
        requests=requests,
        rate_limit=RateLimitConfig(
            max_requests_per_minute=5_000,    # Stay under your tier limit
            max_tokens_per_minute=2_000_000,
        ),
    )

    print(f"Processed {results.stats.successful} requests in {results.stats.duration_seconds:.1f}s")
    print(f"Tokens used: {results.stats.total_input_tokens + results.stats.total_output_tokens:,}")

    # Access results
    for result in results.successes:
        print(f"Product {result.metadata['product_id']}: {result.response}")

asyncio.run(main())

Features

  • Precise Rate Limiting — Token buckets for RPM and TPM, respects provider limits
  • Smart Retries — Exponential backoff with jitter, automatic 429/5xx handling
  • Usage Tracking — Metrics for input tokens and output tokens
  • Flexible I/O — Process from Python lists or JSONL files, output to memory or disk
  • Structured Outputs — Support for Pydantic models and JSON schemas
  • Provider Agnostic — Same API across OpenAI, Anthropic, Gemini, DeepSeek, and more

Supported Providers

OpenAI
OpenAI
Chat, Responses, Embeddings
Anthropic
Anthropic
Messages API
Google Gemini
Gemini
Generate, Embeddings
DeepSeek
DeepSeek
Chat Completions
Cohere
Cohere
Embed API
Voyage AI
Voyage AI
Embeddings

Examples

Explore real-world use cases in the examples/ directory:

Use Case Description
Data Extraction Extract structured data from product listings, invoices
Embeddings Generate embeddings for RAG and semantic search
Evaluation Multi-judge consensus evaluation
Synthetic Data Generate training data and evaluation sets
Classification Sentiment analysis, content moderation
Translation Dataset translation for multilingual evaluation

Processing Modes

callm supports four processing modes depending on your input source and output destination:

Input Output Best For
Python list In-memory Small batches, interactive use
Python list JSONL file Medium batches, need persistence
JSONL file JSONL file Large batches, low memory
JSONL file In-memory Loading saved requests, testing
# 1. List → Memory (small batches)
results = await process_requests(
    provider=provider,
    requests=my_list,
    rate_limit=rate_limit,
)
# Access: results.successes, results.failures

# 2. List → File (persist results)
results = await process_requests(
    provider=provider,
    requests=my_list,
    rate_limit=rate_limit,
    output_path="results.jsonl",
)

# 3. File → File (large batches, low memory)
results = await process_requests(
    provider=provider,
    requests="input.jsonl",
    rate_limit=rate_limit,
    output_path="results.jsonl",
)

# 4. File → Memory (reload saved requests)
results = await process_requests(
    provider=provider,
    requests="input.jsonl",
    rate_limit=rate_limit,
)

Configuration

from callm import RateLimitConfig, RetryConfig

# Rate limiting (required)
rate_limit = RateLimitConfig(
    max_requests_per_minute=1000,
    max_tokens_per_minute=100_000,
)

# Retry behavior (optional, sensible defaults)
retry = RetryConfig(
    max_attempts=5,
    base_delay_seconds=0.5,
    max_delay_seconds=15.0,
    jitter=0.1,
)

results = await process_requests(
    provider=provider,
    requests=requests,
    rate_limit=rate_limit,
    retry=retry,
)

API Reference

process_requests()

Main function for parallel API request processing.

Parameter Type Description
provider BaseProvider Provider instance (OpenAI, Anthropic, etc.)
requests list[dict] | str List of request dicts or path to JSONL file
rate_limit RateLimitConfig RPM and TPM limits
retry RetryConfig Optional retry configuration
output_path str Optional path for output JSONL (enables streaming)
errors_path str Optional path for error JSONL
logging_level int Logging verbosity (default: 20/INFO)

Returns: ProcessingResults with successes, failures, and stats.

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

# Setup development environment
git clone https://github.com/milistu/callm.git
cd callm
uv sync --dev
uv run pre-commit install

# Run tests
uv run nox

License

MIT License - see LICENSE for details.


Built with 🧡 for engineers who process data at scale

Metadata

Release files for callm-py 0.1.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 callm-py 0.1.0
File Size Uploaded Provenance
callm_py-0.1.0.tar.gz 27.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for callm-py 0.1.0
File Interpreter ABI Platform
callm_py-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.7 kB

Release files / callm_py-0.1.0.tar.gz

Download URL callm_py-0.1.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d37860476633c6b11c71565840d3b3b338016214241b537fb83bd2211b8b561a
BLAKE2b-256 checksum
How to use checksums
c50179ffa31c10a9a648502d109dc21c9b829f2fd8964eaeba46c5f20cc3dc59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 17, 2025.

Transparency log

Release files / callm_py-0.1.0-py3-none-any.whl

Download URL callm_py-0.1.0-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b372a853a16f27c850f0c6cb02dffecc5dcf5d2596c5b20e8d7833078577af34
BLAKE2b-256 checksum
How to use checksums
5bcdf2ba6c78dc317b650c6473f09002cd245eeaccf36edf48ad8f99eabf0181
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 17, 2025.

Transparency log

Security for callm-py 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for callm_py-0.1.0.tar.gz

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 Dec 17, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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