Skip to main content

Un-Official Python SDK for the Open Responses standard

Project description

OpenResponses Python

License: MIT Docs PyPI Ruff

Un-Official Python SDK for the Open Responses standard.

Documentation | Source Code | Bug Tracker


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 httpx with 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.

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

openresponses_python-0.1.3.tar.gz (90.6 kB view details)

Uploaded Source

Built Distribution

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

openresponses_python-0.1.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file openresponses_python-0.1.3.tar.gz.

File metadata

  • Download URL: openresponses_python-0.1.3.tar.gz
  • Upload date:
  • Size: 90.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for openresponses_python-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dbb5756f629d7cda7ac6019668c072b6478161becdd363aa30002802bcdb720a
MD5 f7065ea2079c2276152659398b481b60
BLAKE2b-256 15c3734657ea4ed7b6b5a6cac677e9dacadeb79f4ae583de25dd7b568fb3ef2c

See more details on using hashes here.

File details

Details for the file openresponses_python-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: openresponses_python-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for openresponses_python-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4266144a5f5e8ba39e5043f3f57bd5f734f90762d73ae5744f50832b29690c70
MD5 3b22365bde0cf0f2c20cdd9cfdce40e8
BLAKE2b-256 5c18401e73956a639e4f2b8389feb625d1230b499991671654d5e2113a8fe3c7

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