Skip to main content

Interoperate between AI providers using the OpenAI Responses API as a common interface.

Project description

InteropRouter

Seamlessly call major LLMs and image generation models through a unified interface.

InteropRouter is designed to seamlessly interoperate between the most common AI providers at a high level of quality. It uses the OpenAI Responses API types as a common denominator for inputs and outputs, allowing you to switch between providers with minimal code changes. See examples/ for detailed notebooks covering interoperability, function calling, image generation, and more.

Getting Started

Installation

# With uv.
uv add interop-router

# With pip.
pip install interop-router

Usage

from anthropic import AsyncAnthropic
from google import genai
from openai import AsyncOpenAI
from openai.types.responses import EasyInputMessageParam

from interop_router.router import Router
from interop_router.types import ChatMessage

router = Router()
router.register("openai", AsyncOpenAI())
router.register("gemini", genai.Client())
router.register("anthropic", AsyncAnthropic())

# InteropRouter is strictly typed, so be sure to use OpenAI's Response types for inputs. 
# See https://platform.openai.com/docs/guides/migrate-to-responses and the library source for more details on typing.
messages = [ChatMessage(message=EasyInputMessageParam(role="user", content="Hello!"))]

response = await router.create(input=messages, model="gpt-5.2")
response = await router.create(input=messages, model="gemini-3-flash-preview")
response = await router.create(input=messages, model="claude-sonnet-4-5-20250929")

InteropRouter Design Philosophy

The only goal of InteropRouter is to interoperate between the most common AI providers. To make this goal achievable, we make several trade-offs:

  • Only support OpenAI (including Azure OpenAI), Gemini, and Anthropic. Each provider adds a significant amount of possible permutations of features. To maintain high-quality interoperability, we limit the number of providers.
  • Only support async APIs, but not streaming token by token as this adds significant complexity, and for agents the latency is not as important.
  • We do not support stateful features where possible. These features are contradictory to the goal of seamless swapping between providers.
  • We choose the OpenAI Responses API types as the common denominator for creating pivots between providers. The reason is two-fold: a) The Responses API supports most features b) By picking an existing API, we avoid the need to design and maintain our own schema and Responses API support is gained for "free".
  • The supported features will be rigorously tested to ensure seamless swapping between providers within a single conversation.

Development

Prerequisites

Setup

Create uv virtual environment and install dependencies:

uv sync --frozen --all-extras --all-groups

Set up git hooks:

prek install

To update dependencies (updates the lock file):

uv sync --all-extras --all-groups

Run formatting, linting, type checking, and tests in one command:

uv run ruff format && uv run ruff check --fix && uv run ty check && uv run pytest

Further Information

docs/DEVELOPMENT.md

Compatibility and Roadmap

docs/COMPATIBILITY_AND_ROADMAP.md

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

interop_router-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

interop_router-0.1.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file interop_router-0.1.0.tar.gz.

File metadata

  • Download URL: interop_router-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for interop_router-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4d856fb80a00b9ebd4ba5ec0b7408610e6d89fc8d5fbe05f75d839dc9775ffd4
MD5 3781ff4b9025b0d279460e492feee2af
BLAKE2b-256 c9a90e34a911e0455f3f974eff02b6725e39e7ed24a261403418dfcaa53dfc22

See more details on using hashes here.

File details

Details for the file interop_router-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: interop_router-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for interop_router-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be4f0f92a8190e2ed8f29890953ff6f60100054e3e5ef89ac45f2cae36aa71c3
MD5 f1219d75934a972c8978ba369126f8a1
BLAKE2b-256 ef3d552e48cce2d2d564581c28098bc0b82094fd4e43a979bd3c9f0db7e8497c

See more details on using hashes here.

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