Open Responses
A Rust client library for the Open Responses API specification.
Open Responses is an open-source specification for building multi-provider, interoperable LLM interfaces based on the OpenAI Responses API. It defines a shared schema and tooling layer that enable a unified experience for calling language models, streaming results, and composing agentic workflows—independent of provider.
Features
- Complete Type Coverage: All request/response types from the Open Responses specification
- Streaming Support: Built-in SSE (Server-Sent Events) streaming for real-time responses
- Type-Safe: Strongly typed API with comprehensive error handling
- Async/Await: Built on Tokio for high-performance async operations
- Easy to Use: Simple, intuitive API with builder patterns
- Multi-Provider Ready: Works with any Open Responses compatible API
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Quick Start
Basic Usage
use ;
async
Streaming Responses
use ;
use StreamExt;
async
Function Calling
use ;
use json;
let get_weather = function
.with_description
.with_parameters;
let request = CreateResponseBody ;
Core Concepts
Items
Items are the fundamental unit of context in Open Responses. They represent messages, tool calls, tool outputs, and reasoning.
use Item;
// Create different types of items
let user_msg = user_message;
let assistant_msg = assistant_message;
let system_msg = system_message;
let dev_msg = developer_message;
let reference = reference;
Content Types
use InputContent;
// Text
let text = text;
// Image
let image = image_url;
let image_high_res = image_url_with_detail;
// File
let file = file_url;
// Video
let video = video_url;
Tools
use Tool;
use json;
let tool = function
.with_description
.with_parameters
.strict;
API Reference
Client
The Client type provides synchronous (blocking) API calls:
Client::new(api_key)- Create a client with default base URLClient::with_base_url(api_key, base_url)- Create with custom base URLclient.create_response(request)- Send a request and get a response
StreamingClient
The StreamingClient provides SSE streaming:
StreamingClient::new(api_key)- Create a streaming clientclient.stream_response(request)- Returns a stream of events
Types
All types from the Open Responses specification are available:
CreateResponseBody- Request body for creating responsesResponseResource- Response from the APIItem- Core item types (messages, function calls, etc.)InputContent/OutputContent- Content typesStreamingEvent- Streaming event typesTool/ToolChoiceParam- Tool definitions- Enums:
MessageRole,MessageStatus,ToolChoice, etc.
Examples
See the examples/ directory for complete working examples:
basic_usage.rs- Simple API usagestreaming.rs- Streaming responsesfunction_calling.rs- Tool/Function calling
Run examples with:
Testing
Run the test suite:
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.