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.2.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.2.0
File Size Uploaded
llm_babel-0.2.0.tar.gz 431.6 kB Details

Built distribution (wheel)

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

Total release size: 1.0 MB

Release files / llm_babel-0.2.0.tar.gz

Download URL llm_babel-0.2.0.tar.gz
Size 431.6 kB
Tags Source
SHA-256 checksum
How to use checksums
dfef8e83c45418ae8f08e4a376444a68a6172d7cd99dd0b62f803f8d75846aa1
BLAKE2b-256 checksum
How to use checksums
605e17c882fd691457f1aad300eef130fa7f13ea12cf6bcecedcb273616a7ba7
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.2.0-py3-none-any.whl

Download URL llm_babel-0.2.0-py3-none-any.whl
Size 597.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1890797af344bd787724bef950f8d02e62d27c9f032efe9a81a90eba874c6da8
BLAKE2b-256 checksum
How to use checksums
fee561852f0cf5e87be43a194d680d4bb762058307c53a070e2a50cad54faf06
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

This release

0.2.0 This release

2 release files

0.1.0

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