Repository navigation
0.6.0
Republic 0.6 is a ground-up rewrite. It is now a focused provider library: one async interface over AI services, with gateways, agent loops, and tool execution left to the caller.
This release includes everything from 0.6.0a1 and 0.6.0a2, plus image models and call extensions.
pip install republic==0.6.0import republic
model = republic.get_model("openai:gpt-6-sol") # reads REPUBLIC_OPENAI_API_KEY
response = await model.chat("Hello, how are you?")
async with model.stream("Tell me a story", reasoning_effort="high") as stream:
async for event in stream:
if isinstance(event, republic.events.TextDelta):
print(event.chunk, end="")⚠️ Breaking changes from 0.5.x
- The 0.5.x API has been removed (#58). Republic no longer wraps
any-llm-sdk; it talks to providers directly overhttpx2. Code written against 0.5.x needs to be ported. See the quickstart and the Provider API reference. - Error classes now live in
republic.errorsrather than at the package top level. - Tool results are
toolmessages built withrepublic.tool(call, *content, is_error=False), replacingToolResult,republic.tool_result(), andassistant(tool_results=...)(#79).
Highlights
- Provider API (#61):
get_model(),get_embedding_model(),get_decision_model(), streaming events, structured output, tool calling, andregister_provider()for custom providers. Each model picks a native API format (responses,messages,gemini,chat, …) and lets you override it withapi_format=. - 17 providers: OpenAI, Anthropic, Google Gemini (alias
gemini), OpenRouter, Azure OpenAI, DeepSeek, MiniMax, Mistral, Moonshot, Together AI, Z.ai, Magpie, Ollama, TypeSafe, Codex, GitHub Copilot, and Grok (#61, #72, #69). - Authentication: OAuth for Codex, GitHub Copilot, and Grok CLI, plus OpenRouter PKCE login (#61, #69, #70).
- Model listing:
Provider.list_models()returnsModelInfoacross all pages (#75). - Reliability (#76): retries with jittered exponential backoff and
Retry-Aftersupport (max_retries,retry_delay,max_retry_delay).headersandrequest_idare exposed on responses, streams, and errors. Truncated streams raiseStreamIncompleteErrorinstead of producing a silently incomplete response. - Connection reuse (#78): each
Providerkeeps a single HTTP client that its models share, withclose()and async context-manager support. - Multimodal input: images, video, and audio (
republic.audio()) parts (#77). Tool results can mix text and media (#79). - Serialization:
Message.to_dict()/Message.from_dict()round-trip messages through JSON (#79). - Ships a
py.typedmarker for downstream type checking.
New since 0.6.0a2
-
Image models (#82): generate and edit images with
get_image_model().model = republic.get_image_model("openai:gpt-image-2") # or "google:MODEL_ID" response = await model.generate("A watercolor fox", size="1024x1024", quality="high") response = await model.edit("Give it a scarf", [republic.image("fox.png")], mask=republic.image("mask.png")) response.image_parts # list[republic.Image], inline data or URLs response.images # decoded with Pillow (pip install "republic[image]")
OpenAI and Azure OpenAI use the
imagesformat (Azure edits are sent as multipart form data); Google uses the newgemini_imageformat. Options includen,size,aspect_ratio,quality,background,output_format,output_compression, andmoderation. A format raisesUnsupportedFeatureErrorfor options it cannot express. Streaming partial images is not supported yet. -
Call extensions (#83): subclass
republic.extensions.Extensionand pass instances throughextensions=on a Provider or model factory to observe chat, streaming, embedding, image, decision, and model-listing calls.on_start()returns per-call state that is passed toon_retry()andon_finish(), so overlapping calls can be tracked independently. A failing callback is logged and does not change the call's result or error.from republic.extensions import Extension class CallLog(Extension): def on_start(self, provider, operation, model): return f"{provider}:{model or operation}" def on_finish(self, context, response, error): print(context, "failed" if error else "ok") model = republic.get_model("openai:gpt-6-sol", extensions=[CallLog()])
Fixes and changes in the pre-releases
- Messages format keeps assistant block order (#81). Assistant turns that interleave text, tool uses, and round-tripped provider blocks (such as
thinking,server_tool_use, andweb_search_tool_result) are replayed in their original order. Anthropic-compatible APIs like DeepSeek's reject the old order in thinking mode. - Magpie sends a default key. The
magpieprovider sendsAuthorization: Bearer magpieby default, so a local gateway works without any key configuration. Passapi_key=orauth=to override it.
Documentation
Documentation lives at https://getrepublic.org, with a page for each provider plus guides to authentication, tool use, a minimal agent loop, structured output, image models, and extensions (#71, #73, #74, #82, #83). The site is built with Zensical (#80).
Full Changelog: 0.5.8...0.6.0
🚀 Features
- Dynamic version from VCS and release notes auto-generation - by @PsiACE in #48 (553f7)
- Add the provider API - by @frostming and Claude Opus 5.5 in #61 (811c1)
- Add OpenAI-compatible providers - by @frostming and Claude Opus 5.5 in #72 (8f4d5)
- Add Provider.list_models - by @frostming and Claude Opus 5.5 in #75 (e9373)
- Add native audio input encoding to provider formats - by @PsiACE in #77 (d2222)
- Update Magpie provider to use default API key and enhance documentation - by @frostming (ce85b)
- Add image models with OpenAI Images and Gemini image formats - by @frostming and Claude Opus 5.5 in #82 (d9b1e)
- Add optional call extensions - by @PsiACE in #83 (7b9fd)
- auth:
🐞 Bug Fixes
- Add alias gemini to google provider - by @frostming (df9df)
- Keep assistant block order in the Messages format - by @frostming and Claude Opus 5.5 in #81 (75372)