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.4.tar.gz (90.7 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.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openresponses_python-0.1.4.tar.gz
  • Upload date:
  • Size: 90.7 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.4.tar.gz
Algorithm Hash digest
SHA256 37e16ae238a025d722b53d817557f2190b6b4f315159c5d3f9172dc6e3135ea5
MD5 6d32bba3dbc63c220ff0487528d1498e
BLAKE2b-256 5bb915bf0f2b6f1b0c933803509a4cd74c93b8fb49ef42a7538d2ec8c0eb31e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openresponses_python-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6a7ae8c3866535c544f282734737f22c6990503c5e92617bf8de56fffe28d633
MD5 d7c31e514c66a025011315543cc99417
BLAKE2b-256 1973344e43ad76851ae6ddb14f7bd6b3fd76cb6d2116767fc1fb188c425d74f9

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