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.1

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.1
File Size Uploaded
llm_babel-0.2.1.tar.gz 431.6 kB Details

Built distribution (wheel)

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

Total release size: 1.0 MB

Release files / llm_babel-0.2.1.tar.gz

Download URL llm_babel-0.2.1.tar.gz
Size 431.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7905c1434557c6faf6971ab919f75790b935c23be3f52843d0c7ebeea7414e29
BLAKE2b-256 checksum
How to use checksums
da6111c538c1bf990c22f7005a2853b552e6a96b6190e0a9e85e4abcbbda2ff2
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.1-py3-none-any.whl

Download URL llm_babel-0.2.1-py3-none-any.whl
Size 597.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb968d55eca7a7f691fefd2b6ffd5ab3d2146f919182b7dd99bf780d125d7e37
BLAKE2b-256 checksum
How to use checksums
897ff4f711dc2e6c3f004bf039c32a9d132be16b394b5e856cb1c98783c6c6e2
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

This release

0.2.1 This release

2 release files

0.2.0

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