Skip to main content
Before you begin, install RouteHub and set an API key for at least one provider.

Make your first call

1

Set a provider key

2

Call a model

response is an openai.types.chat.ChatCompletion, the same object the OpenAI SDK returns.
3

Switch providers

Change the model string to change providers. The call and the response type stay the same:
Each provider reads its own key variable, such as ANTHROPIC_API_KEY or GROQ_API_KEY. See Providers.

Stream a response

Pass stream=True to get an iterator of ChatCompletionChunk objects:

Run async

acompletion takes exactly the same arguments as completion:

Call a tool

Tools use the OpenAI format for every provider. RouteHub translates them for Claude.

Handle errors

Every provider failure is raised as a typed exception:

Next steps

Streaming and async

Usage on streams, context managers and async streams

Tool calling

Run a complete tool loop

Structured output

Get JSON that matches a pydantic model

Reasoning

Control thinking with one argument across providers