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")
Count input tokens before making a request using each provider's native token counting endpoint:
token_count = await router.count_tokens(input=messages, model="gpt-5.2")
token_count = await router.count_tokens(input=messages, model="gemini-3-flash-preview")
token_count = await router.count_tokens(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 -U --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
Compatibility and Roadmap
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interop_router-0.1.13.tar.gz.
File metadata
- Download URL: interop_router-0.1.13.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18b7d57f0fdea4724a3e11a8aaa7ca0bddcf8b950d0563f58ae2520e04d45f19
|
|
| MD5 |
f7068e2a201adddca5df491627dcd538
|
|
| BLAKE2b-256 |
22eb5d74f45e2c8a11efc31bb3bfbc3a3a650d6e1f7824967cfcff26dd265d00
|
Provenance
The following attestation bundles were made for interop_router-0.1.13.tar.gz:
Publisher:
publish.yml on DavidKoleczek/interop-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
interop_router-0.1.13.tar.gz -
Subject digest:
18b7d57f0fdea4724a3e11a8aaa7ca0bddcf8b950d0563f58ae2520e04d45f19 - Sigstore transparency entry: 1575892095
- Sigstore integration time:
-
Permalink:
DavidKoleczek/interop-router@7d3208d6bf3f76e9f66a620fb5fac7d7d83a60ad -
Branch / Tag:
refs/tags/v0.1.13 - Owner: https://github.com/DavidKoleczek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d3208d6bf3f76e9f66a620fb5fac7d7d83a60ad -
Trigger Event:
release
-
Statement type:
File details
Details for the file interop_router-0.1.13-py3-none-any.whl.
File metadata
- Download URL: interop_router-0.1.13-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13c0b1df1915da6b2c1850d463353f8f2515f3d5c96231faf73a4699f67bb531
|
|
| MD5 |
fe2d81a05fec2604aa0d3d29a3ad5d7c
|
|
| BLAKE2b-256 |
5ab38bcaea623059f8e9277b543f854f45d56319f28bbbc6b23a6a4a525238ec
|
Provenance
The following attestation bundles were made for interop_router-0.1.13-py3-none-any.whl:
Publisher:
publish.yml on DavidKoleczek/interop-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
interop_router-0.1.13-py3-none-any.whl -
Subject digest:
13c0b1df1915da6b2c1850d463353f8f2515f3d5c96231faf73a4699f67bb531 - Sigstore transparency entry: 1575892099
- Sigstore integration time:
-
Permalink:
DavidKoleczek/interop-router@7d3208d6bf3f76e9f66a620fb5fac7d7d83a60ad -
Branch / Tag:
refs/tags/v0.1.13 - Owner: https://github.com/DavidKoleczek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7d3208d6bf3f76e9f66a620fb5fac7d7d83a60ad -
Trigger Event:
release
-
Statement type: