Skip to main content

OpenResponsesRequestExtension

Trait OpenResponsesRequestExtension 

Source
pub trait OpenResponsesRequestExtension: Send + Sync {
    // Required method
    fn decorate(
        &self,
        body: &mut Value,
        config: &LlmCallConfig,
    ) -> Result<(), AgentLoopError>;

    // Provided methods
    fn decorate_headers(
        &self,
        _headers: &mut HeaderMap,
        _config: &LlmCallConfig,
    ) -> Result<(), AgentLoopError> { ... }
    fn update_rate_limit_info(
        &self,
        _info: &mut RateLimitInfo,
        _headers: &HeaderMap,
        _error_body: &str,
    ) { ... }
}
Expand description

Open Responses Protocol Driver (OpenAI implementation)

Implements ChatDriver using the Open Responses specification (https://www.openresponses.org/). This driver targets OpenAI’s API but follows the vendor-neutral Open Responses standard.

Rate limit handling: On 429 errors, automatically retries with exponential backoff, respecting x-ratelimit-reset-* and retry-after headers.

The Open Responses spec is recommended for new projects, offering:

  • Better performance with reasoning models (o1, o3, GPT-5)
  • Provider-agnostic streaming events
  • Native agentic loop support

§Example

use everruns_core::OpenResponsesProtocolChatDriver;

let driver = OpenResponsesProtocolChatDriver::new("your-api-key");
// or with custom endpoint
let driver = OpenResponsesProtocolChatDriver::with_base_url("your-api-key", "https://api.example.com/v1/responses");
// or with custom retry config
let driver = OpenResponsesProtocolChatDriver::new("your-api-key")
    .with_retry_config(LlmRetryConfig::aggressive());

Hook for provider-specific augmentation of an Open Responses request.

The Open Responses request shape this driver builds is vendor-neutral. Providers reached through it (e.g. OpenRouter) layer extra top-level fields onto the outgoing JSON or HTTP headers via this seam, so the core driver stays free of provider branching. decorate and decorate_headers run once per request, after the base body is serialized and before it is sent; either may return an error to abort the request (e.g. failed routing validation).

Required Methods§

Source

fn decorate( &self, body: &mut Value, config: &LlmCallConfig, ) -> Result<(), AgentLoopError>

Provided Methods§

Source

fn decorate_headers( &self, _headers: &mut HeaderMap, _config: &LlmCallConfig, ) -> Result<(), AgentLoopError>

Add provider-specific non-auth request headers (routing, attribution, session_id, OpenAI-Beta, originator, account ids, …).

Authentication is a separate seam (AuthHeaderProvider, set via OpenResponsesProtocolChatDriver::with_auth_provider). The driver applies these decoration headers first, then applies the resolved auth header, so the auth header always wins on a name conflict. Do not set Authorization / api-key here; use an auth provider instead.

Source

fn update_rate_limit_info( &self, _info: &mut RateLimitInfo, _headers: &HeaderMap, _error_body: &str, )

Refine retry metadata from provider-specific rate limit response fields.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§