Skip to main content

llm-babel

Translate an LLM request, response, error, or stream between provider wire formats, and get the exact same result whether it runs in Python, Rust, or TypeScript.

Every provider speaks a slightly different dialect on the wire. llm-babel routes everything through one neutral intermediate representation, so a format is one decoder plus one encoder rather than a converter per pair. The transforms are authored once as a small pure spec and compiled to plain Python, Rust, and TypeScript, proven byte-identical against a shared golden corpus that ships in this package.

Formats: openai-chat, openai-responses, anthropic-messages, bedrock-converse, gemini, mistral, deepseek, cohere, plus the OpenAI-compatible providers (Groq, Cerebras, xAI, Z.AI, OpenRouter, HuggingFace) as routes over the openai-chat codec.

Install

pip install llm-babel                # the runtime: pure stdlib, no dependencies
pip install "llm-babel[validation]"  # adds Pydantic for the typed, validating IR surface

The import name is llm_transform.

Use

from llm_transform.registry import translate, decode, encode

translate("openai-chat", "anthropic-messages", openai_request)  # source wire -> target wire
decode("gemini", gemini_request)                                # any wire -> IR
encode("bedrock-converse", ir)                                  # IR -> any wire

Responses, errors, and streams have the same shape of API (translate_response, translate_error, fold_stream), and reconcile fits a request to a target's declared capabilities before encoding.

Re-run the proof against the corpus shipped in the wheel:

python -m llm_transform.corpus.runner

The same transforms are published for TypeScript as @pydantic/llm-babel on npm.

Release files for llm-babel 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 llm-babel 0.1.0
File Size Uploaded
llm_babel-0.1.0.tar.gz 350.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-babel 0.1.0
File Interpreter ABI Platform
llm_babel-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 854.4 kB

Release files / llm_babel-0.1.0.tar.gz

Download URL llm_babel-0.1.0.tar.gz
Size 350.6 kB
Tags Source
SHA-256 checksum
How to use checksums
274efac82184551a64588acdc7690f6407d41bc2242c663a864b184d8c7e0f28
BLAKE2b-256 checksum
How to use checksums
d83367e20c5b305293ad1c361486dde83d17bb3067186c005f22307c2b4111d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL llm_babel-0.1.0-py3-none-any.whl
Size 503.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e04e0df0d5540e5f27ecc33753473cc1d000c53eb39780317aa72f4ad47c5c4
BLAKE2b-256 checksum
How to use checksums
8843da74327aeb0966c79fa64d9eddfb6cbda7148761ee76d47f737cdead7dfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.2.1

2 release files

0.2.0

2 release files

This release

0.1.0 This release

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