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.2.tar.gz (90.4 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.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openresponses_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 be304678cfbcd35b8cecadc20f1412cbe01d29dba09559c8dda64e6d9c642835
MD5 497843c857574067c8a7423c8f40be3a
BLAKE2b-256 0f3110285439285c68b5d50871656eee8597eaed62dd3f7cf3ca4198b623402e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openresponses_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50a467645af7f251eae2c02f377000def63f64afcddbb9c29a30ae1f26c1f03b
MD5 95f8853aee2b92cc30081a491fb45298
BLAKE2b-256 a93d76321834c59254fd589667d39bb029ff84797253c6c6db72936a26e11ae2

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