Skip to main content

InteropRouter

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

uv ty PyPI License: MIT

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())
router.register("chat_completions", AsyncOpenAI(base_url="http://localhost:8000/v1"))  # Can point to local models, OpenAI, OpenRouter, etc.

# 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.6-terra")
response = await router.create(input=messages, model="gemini-3.6-flash")
response = await router.create(input=messages, model="claude-sonnet-5")
# Explicit provider routing with provider/model.
response = await router.create(input=messages, model="chat_completions/nvidia/Qwen3.6-27B-NVFP4")

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.6-terra")
token_count = await router.count_tokens(input=messages, model="gemini-3.6-flash")
token_count = await router.count_tokens(input=messages, model="claude-sonnet-5")

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:

  • Focus on OpenAI (Responses API, 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 first-class providers.
  • Also support a chat_completions adapter for OpenAI-compatible Chat Completions endpoints.
  • 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

docs/COMPATIBILITY_AND_ROADMAP.md

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.4.0.tar.gz (32.7 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.4.0-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: interop_router-0.4.0.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for interop_router-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fd7149e21f3388e9a528d7c97dded5a66c3b879c620a5b42eb1a8d5e4bff2114
MD5 93ff5d1b765e17443d9e19686d33fb38
BLAKE2b-256 710aae7d18d05d5b9624d9d5f24d4b0a34b06b2673f49ea4746e4534e94c905b

See more details on using hashes here.

Provenance

The following attestation bundles were made for interop_router-0.4.0.tar.gz:

Publisher: publish.yml on DavidKoleczek/interop-router

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

File details

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

File metadata

  • Download URL: interop_router-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for interop_router-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43d935d280d607b053bd3df7ff71b90e2e6a24e87b2b64282217c4d8b45eddbc
MD5 b0281a8bc93675a0981949a35310d71d
BLAKE2b-256 fb035cf016bcd11c07d7a7d22b01dcdf79bd8a996b266387359c7837a2e791b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for interop_router-0.4.0-py3-none-any.whl:

Publisher: publish.yml on DavidKoleczek/interop-router

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

Release history Release notifications | RSS feed

0.5.0

2 files

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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