This release is a pre-release and may not be stable for production use.
LLM-Rosetta
LLM-Rosetta — A Python library for converting between different LLM provider API formats using a hub-and-spoke architecture with a central IR (Intermediate Representation).
Full Documentation
Full documentation is available at:
- English: https://llm-rosetta.readthedocs.io/en/latest/
- 中文: https://llm-rosetta.readthedocs.io/zh-cn/latest/
The Problem
When building applications that work with multiple LLM providers, you face an N² conversion problem — every provider pair requires its own conversion logic. LLM-Rosetta solves this with a hub-and-spoke approach: each provider only needs a single converter to/from the shared IR format.
Provider A ──→ IR ──→ Provider B
Provider C ──→ IR ──→ Provider D
... and so on
Supported Providers
| Provider | API Standard | Request | Response | Streaming |
|---|---|---|---|---|
| OpenAI | Chat Completions | ✅ | ✅ | ✅ |
| OpenAI | Responses API | ✅ | ✅ | ✅ |
| Anthropic | Messages API | ✅ | ✅ | ✅ |
| GenAI API | ✅ | ✅ | ✅ |
Ollama & Other OpenAI-Compatible Servers
LLM-Rosetta works out of the box with any server that exposes OpenAI-compatible endpoints. Ollama (v0.13+) is a great example — it supports three of the four API formats that LLM-Rosetta converts between:
| Ollama Endpoint | LLM-Rosetta Converter | Since |
|---|---|---|
/v1/chat/completions |
openai_chat |
Early versions |
/v1/responses |
openai_responses |
v0.13.3 |
/v1/messages |
anthropic |
v0.14.0 |
Other compatible servers include HuggingFace TGI, vLLM, and LM Studio.
Features
- Unified IR format for messages, tool calls, and content parts
- Bidirectional conversion: requests to provider format, responses from provider format
- Streaming support with typed stream events
- Auto-detection of provider from request/response objects
- Support for text, images, tool calls, and tool results
- Zero required dependencies (only
typing_extensions); provider SDKs are optional
Compliance Testing
llm-comply is a companion tool that validates LLM API endpoints against official specs. Use it to verify that a gateway or proxy correctly implements the OpenAI Chat, Open Responses, Anthropic Messages, and Google GenAI formats.
pip install llm-comply
# Test your gateway endpoint
llm-comply -u https://your-gateway/v1 -k $API_KEY -m your-model --format openai-chat
A hosted version is available at llm-comply.service.oaklight.top. An on-demand Compliance workflow is also included in CI.
Installation
Basic Installation
Install the core package (requires Python >= 3.8):
pip install llm-rosetta
Installing with Provider SDKs
# Individual providers
pip install llm-rosetta[openai]
pip install llm-rosetta[anthropic]
pip install llm-rosetta[google]
# All providers
pip install llm-rosetta[openai,anthropic,google]
Optional Dependencies
| Extra | Packages | Description |
|---|---|---|
openai |
openai |
OpenAI Chat Completions & Responses API |
anthropic |
anthropic |
Anthropic Messages API |
google |
google-genai |
Google GenAI API |
Quick Start
from llm_rosetta import OpenAIChatConverter, AnthropicConverter
# Create converters
openai_conv = OpenAIChatConverter()
anthropic_conv = AnthropicConverter()
# Convert an OpenAI response to IR, then to Anthropic format
ir_messages = openai_conv.response_from_provider(openai_response)
anthropic_request = anthropic_conv.request_to_provider(ir_messages)
Auto-Detection
from llm_rosetta import convert, detect_provider
# Automatically detect provider and convert
provider = detect_provider(some_response)
ir_messages = convert(some_response, direction="from_provider")
Cross-Provider Conversation
from llm_rosetta import OpenAIChatConverter, GoogleGenAIConverter
from llm_rosetta.types.ir import Message, ContentPart
# Shared IR message history
ir_messages = []
# Turn 1: Ask OpenAI
ir_messages.append(Message(role="user", content=[ContentPart(type="text", text="Hello!")]))
openai_request = openai_conv.request_to_provider({"messages": ir_messages})
openai_response = openai_client.chat.completions.create(**openai_request)
ir_messages.extend(openai_conv.response_from_provider(openai_response))
# Turn 2: Continue with Google — full context preserved
google_request = google_conv.request_to_provider({"messages": ir_messages})
Citation
If you use LLM-Rosetta in your research, please cite our paper:
@article{ding2026llm,
title={LLM-Rosetta: A Hub-and-Spoke Intermediate Representation for Cross-Provider LLM API Translation},
author={Ding, Peng},
journal={arXiv preprint arXiv:2604.09360},
year={2026}
}
Contributing
Contributions are welcome! Please visit the GitHub repository to get started.
Community
Feel free to discuss the project via GitHub Issues or the LINUX DO community.
License
This project is licensed under the MIT License — see the LICENSE file for details.
Release files for llm-rosetta 0.14.0.dev4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_rosetta-0.14.0.dev4.tar.gz | 624.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_rosetta-0.14.0.dev4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.3 MB
Release files / llm_rosetta-0.14.0.dev4.tar.gz
| Download URL | llm_rosetta-0.14.0.dev4.tar.gz |
|---|---|
| Size | 624.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96d96bd0a0f857c71e7844d9c1edf168b919f6c53fb783ff7f50655e43b78d7a
|
|
BLAKE2b-256 checksum How to use checksums |
02cc0c5c022e9f30d9c4beee629718862c56b0ced596974a72504ee431756dd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 17, 2026.
Transparency logRelease files / llm_rosetta-0.14.0.dev4-py3-none-any.whl
| Download URL | llm_rosetta-0.14.0.dev4-py3-none-any.whl |
|---|---|
| Size | 688.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7dea1fde3bd46ae747585d46f1b7874bceab9a4e8376cc60c35ffd2a4dc46452
|
|
BLAKE2b-256 checksum How to use checksums |
36f713b7a6f457bae05f72b29a4ef8864715178fbb4ca561f32a37785b03700d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 17, 2026.
Transparency log