Skip to main content

Prerequisites

  • Python 3.10 or higher
  • An API key for at least one provider, or a local server such as Ollama

Install the package

RouteHub has three direct dependencies: openai, pydantic and tiktoken. It works with openai 2.x and 3.x.

Faster JSON with the fast extra

The fast extra installs orjson, which RouteHub uses for JSON encoding and decoding when it is available.
Set ROUTEHUB_USE_ORJSON=0 to fall back to the standard json module without uninstalling orjson.

Set a provider key

RouteHub reads each provider’s key from its environment variable on every call. Set the ones you need:
You can also pass api_key= to any call. See Providers for every variable name.
Keep keys in a .env file or a secrets manager and never commit them. RouteHub never writes keys to logs, including with set_verbose=True.

Verify the install

mock_response returns a real ChatCompletion without a network call or an API key, so you can check the install offline:

Next steps

Quickstart

Make your first real call

Configuration

Retries, timeouts, TLS and environment variables