Skip to main content

LLM-Rosetta: Unified LLM API adapter — bidirectional conversion between OpenAI, Anthropic, and Google formats via intermediate representation (IR).

Project description

LLM-Rosetta

PyPI version GitHub release Docker CI License: MIT arXiv

English Version | 中文版

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:

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
Google 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

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})

Related Projects

  • ToolRegistry — A lightweight Python framework for managing and dynamically registering tools with LLM integration support.
  • ToolRegistry-Hub — A ready-to-use MCP tool server built on ToolRegistry, providing web search, calculator, datetime, and more out of the box.

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.

License

This project is licensed under the MIT License — see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_rosetta-0.6.9.tar.gz (337.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_rosetta-0.6.9-py3-none-any.whl (373.5 kB view details)

Uploaded Python 3

File details

Details for the file llm_rosetta-0.6.9.tar.gz.

File metadata

  • Download URL: llm_rosetta-0.6.9.tar.gz
  • Upload date:
  • Size: 337.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llm_rosetta-0.6.9.tar.gz
Algorithm Hash digest
SHA256 8bde101b4a775baa0c8cd1b4f724a891aa740f619996976a0ee0b10028033157
MD5 a6b2fcffbcecb0614a44d06cc08ac7ab
BLAKE2b-256 4e76db4b43c5b5cd5ad3b7cf9a5297e4518c1fc770f9c11c0f6c8e99fdfa19db

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_rosetta-0.6.9.tar.gz:

Publisher: release.yml on Oaklight/llm-rosetta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_rosetta-0.6.9-py3-none-any.whl.

File metadata

  • Download URL: llm_rosetta-0.6.9-py3-none-any.whl
  • Upload date:
  • Size: 373.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llm_rosetta-0.6.9-py3-none-any.whl
Algorithm Hash digest
SHA256 9db34c72c0d339827010ee4078d172ce305aeedd54030cf29ca6bf1cfc5730f8
MD5 6387e52114135a18401b7a1ab3fbb48c
BLAKE2b-256 f15483b239e3fad1d034ca52049d72cd8348a4b3e26eeb8b856a5ec2fdd087e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_rosetta-0.6.9-py3-none-any.whl:

Publisher: release.yml on Oaklight/llm-rosetta

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page