Repolode
bubbuild

bubbuild/republic

A Python library giving one interface for chat, streaming, tool calls, and structured output across AI providers.

Stars
84
Forks
23
Open issues
0
Last commit
4 days ago

What is it?

Republic is a Python library that wraps multiple AI model providers behind one interface. A model is selected with a `provider:model` string, so switching between services such as OpenAI, Anthropic, Google, or DeepSeek only means changing that name. Each provider reads its API key from a `REPUBLIC_<PROVIDER>_API_KEY` environment variable.

The library covers chat completion, streaming responses as typed events, tool calls, and structured output. It is scoped to the provider layer: agent loops, tool execution, and gateways are left to the application. Optional async middleware can observe and rewrite the events of each call, for example to add retries.

The documentation also covers media input, embeddings, image generation, decision models, conversation history, and custom providers. Requires Python 3.11 or later.

Key features

  • 01Switch providers by changing a `provider:model` name.
  • 02Streaming responses delivered as typed events.
  • 03Tool calls and structured output through one API.
  • 04Optional async middleware to observe or rewrite calls and retries.
  • 05Supports embeddings, image generation, and custom providers.

Use cases

  • Building an application that must work with several LLM providers.
  • Adding streaming chat or tool calling to a Python service without tying code to one vendor.
  • Writing your own agent loop on top of a provider-neutral client.

Quick start

  1. 1

    Install Republic with pip

    python -m pip install republic
  2. 2

    Set your OpenAI API key in the environment

    export REPUBLIC_OPENAI_API_KEY="your-api-key"
  3. 3

    Run the Python example that calls a model with chat and streaming

Things to know

  • Requires Python 3.11 or later.
  • Each provider needs its own API key or login.

In collections

Topics

FAQ

What is republic?
A Python library giving one interface for chat, streaming, tool calls, and structured output across AI providers. Republic is a Python library that wraps multiple AI model providers behind one interface. A model is selected with a `provider:model` string, so switching between services such as OpenAI, Anthropic, Google, or DeepSeek only means changing that name. Each provider reads its API key from a `REPUBLIC_<PROVIDER>_API_KEY` environment variable.
Is republic free to use? What license does it have?
republic is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is republic still maintained?
Actively maintained. The last commit to republic was on Nov 2, 2026.
What can I use republic for?
Building an application that must work with several LLM providers. Adding streaming chat or tool calling to a Python service without tying code to one vendor. Writing your own agent loop on top of a provider-neutral client.
How do I install republic?
Install Republic with pip: python -m pip install republic Set your OpenAI API key in the environment: export REPUBLIC_OPENAI_API_KEY="your-api-key" Run the Python example that calls a model with chat and streaming
Where can I get republic?
The source code and installation instructions are on GitHub: https://github.com/bubbuild/republic

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects