OpenResponses Python
OpenResponses Python provides a robust, typed interface for interacting with LLMs that adhere to the Open Responses standard. It includes a high-performance async client, Pydantic V2 models, and utilities for building compliant providers.
✨ Features
- Standardization: Strict Pydantic V2 models for
InputText,MessageItem,ReasoningItem,ToolCallItem, ensuring type safety and validation. - High Performance: Built on
httpxwith full async/await support and efficient streaming. - Semantic Streaming: First-class support for streaming reasoning (thinking) and text deltas separately.
- Provider Agnostic: Seamlessly switch between OpenRouter, OpenAI, Ollama, LM Studio, and HuggingFace TGI.
- Developer-First: Fully typed, thoroughly tested, and ready for production.
📦 Installation
Install via pip:
pip install openresponses-python
We recommend using uv for modern dependency management:
uv add openresponses-python
🚀 Quick Start
Here's how to send a request to a compliant provider (e.g., OpenRouter or a local proxy).
1. Simple Request
import asyncio
from openresponses.client import AsyncOpenResponsesClient
async def main():
# Initialize client (defaults to local proxy if base_url not set)
# Ensure you have a provider running (see Examples below)
client = AsyncOpenResponsesClient(base_url="http://localhost:8001")
response = await client.create(
model="deepseek/deepseek-r1",
input="Explain semantic streaming.",
)
# Access the output items directly
for item in response.output:
if item.type == "message":
print(f"Answer: {item.content}")
if __name__ == "__main__":
asyncio.run(main())
2. Semantic Streaming
Stream reasoning ("thinking") and the final response in real-time.
stream = await client.create(
model="deepseek/deepseek-r1",
input="Why is the sky blue?",
stream=True
)
async for event in stream:
if event.event == "response.reasoning.delta":
print(f"🧠 {event.data['delta']}", end="", flush=True)
elif event.event == "response.text.delta":
print(f"🤖 {event.data['delta']}", end="", flush=True)
🔌 Supported Providers
This package includes proxy examples to adapt popular providers to the Open Responses standard.
| Provider | Command | Port | Description |
|---|---|---|---|
| OpenRouter | make run-openrouter |
8001 |
Access DeepSeek R1, Claude 3.5, Gemini via OpenRouter. |
| OpenAI | make run-openai |
8002 |
Standard OpenAI API proxy. |
| Ollama | make run-ollama |
8003 |
Local AI models (Llama 3, Mistral). |
| LM Studio | make run-lmstudio |
8004 |
Local inference server. |
| HuggingFace | make run-huggingface |
8005 |
TGI / Inference Endpoints. |
🛠️ Development
We use uv for dependency management and make for task automation.
git clone https://github.com/uday/openresponses-python.git
cd openresponses-python
make install # Sync dependencies
make test # Run tests
make lint # Run linters
make docs-serve # Preview documentation
🔮 Future Scope
In alignment with the Open Responses standard, we are planning the following enhancements:
- Expanded Provider Ecosystem: Native integrations for Anthropic, Google Vertex AI, and AWS Bedrock.
- Framework Adapters: Drop-in compatibility with LangChain and LlamaIndex for seamless orchestration.
- Observability: Built-in OpenTelemetry tracing for full visibility into requests and stream events.
- Enterprise resilience: Advanced retries, circuit breakers, and failover strategies.
- Smart Caching: Semantic caching strategies to reduce latency and API costs.
- CLI Tools: A comprehensive CLI for testing providers and debugging stream deltas.
🤝 Contributing
We welcome contributions! Please see CONTRIBUTION.md for guidelines.
📄 License
This project is licensed under the MIT License.
Metadata
Release files for openresponses-python 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openresponses_python-0.1.4.tar.gz | 90.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openresponses_python-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 98.6 kB
Release files / openresponses_python-0.1.4.tar.gz
| Download URL | openresponses_python-0.1.4.tar.gz |
|---|---|
| Size | 90.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37e16ae238a025d722b53d817557f2190b6b4f315159c5d3f9172dc6e3135ea5
|
|
BLAKE2b-256 checksum How to use checksums |
5bb915bf0f2b6f1b0c933803509a4cd74c93b8fb49ef42a7538d2ec8c0eb31e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / openresponses_python-0.1.4-py3-none-any.whl
| Download URL | openresponses_python-0.1.4-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a7ae8c3866535c544f282734737f22c6990503c5e92617bf8de56fffe28d633
|
|
BLAKE2b-256 checksum How to use checksums |
1973344e43ad76851ae6ddb14f7bd6b3fd76cb6d2116767fc1fb188c425d74f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|