Skip to main content

Build LLM workflows like normal Python while keeping a full audit trail by default.

Project description

Republic

Release Build status codecov Commit activity License

Build LLM workflows like normal Python while keeping a full audit trail by default.

Visit https://getrepublic.org for concepts, guides, and API reference.

Republic is a tape-first LLM client: messages, tool calls, tool results, errors, and usage are all recorded as structured data. You can make the workflow explicit first, then decide where intelligence should be added.

Quick Start

pip install republic
from __future__ import annotations

import os

from republic import LLM

api_key = os.getenv("LLM_API_KEY")
if not api_key:
    raise RuntimeError("Set LLM_API_KEY before running this example.")

llm = LLM(model="openrouter:openrouter/free", api_key=api_key)
result = llm.chat("Describe Republic in one sentence.", max_tokens=48)
print(result)

Why It Feels Natural

  • Plain Python: The main flow is regular functions and branches, no extra DSL.
  • Structured error handling: Errors are explicit and typed, so retry and fallback logic stays deterministic.
  • Tools without magic: Supports both automatic and manual tool execution with clear debugging and auditing.
  • Tape-first memory: Use anchor/handoff to bound context windows and replay full evidence.
  • Event streaming: Subscribe to text deltas, tool calls, tool results, usage, and final state.

Authentication

Republic supports:

  • static api_key
  • provider maps such as api_key={"openai": "...", "anthropic": "..."}
  • dynamic api_key_resolver
  • provider-specific OAuth resolvers for OpenAI Codex and GitHub Copilot

Keep the README short and move auth setup into the docs:

Development

make check
make test

See CONTRIBUTING.md for local setup, testing, and release guidance.

License

Apache 2.0


This project is derived from lightning-ai/litai and inspired by pydantic/pydantic-ai; we hope you like them too.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

republic-0.5.7.tar.gz (155.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

republic-0.5.7-py3-none-any.whl (62.3 kB view details)

Uploaded Python 3

File details

Details for the file republic-0.5.7.tar.gz.

File metadata

  • Download URL: republic-0.5.7.tar.gz
  • Upload date:
  • Size: 155.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for republic-0.5.7.tar.gz
Algorithm Hash digest
SHA256 74cb0a02c3dffaa3438a8f41d19b137b7c8310a7d6c2c821b81cf98d5167200a
MD5 70d54f682ae30ef81972a20dcef70065
BLAKE2b-256 4d409ebd36e489696c0904df18bf4da6edc4b87f203b55f6942d3f782c69530c

See more details on using hashes here.

File details

Details for the file republic-0.5.7-py3-none-any.whl.

File metadata

  • Download URL: republic-0.5.7-py3-none-any.whl
  • Upload date:
  • Size: 62.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for republic-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 702e2a3b662a91e68cc9c5b4893460dba01e02f081f309e6ce30d1e79c336db3
MD5 846690689819ab231cabaec8d904c930
BLAKE2b-256 aa3326f4ad2665f96af4d02ae9c6f629e1d0c2538f22cecece3f8df6cd4c1da0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page