Skip to main content

Python class

OpenResponsesRequest

OpenResponsesRequest

class max.interfaces.OpenResponsesRequest(*, request_id, body)

source

Bases: BaseModel

General request container for OpenResponses API requests.

This class wraps an OpenResponsesRequestBody and adheres to the Request schema. All request fields are accessed directly from the body.

Parameters:

  • request_id (RequestID)
  • body (OpenResponsesRequestBody)

body

body: OpenResponsesRequestBody

source

The complete OpenResponses request body.

from_fastapi_request()

async classmethod from_fastapi_request(request)

source

Create an OpenResponsesRequest from a FastAPI/Starlette Request.

Extracts the request_id from request.state.request_id and parses the request body as an OpenResponsesRequestBody. If the request contains image URLs (http/https), they will be downloaded and converted to base64 data URIs before validation.

Parameters:

request (FastAPIRequestProtocol) – A request object with state.request_id and body() method. Compatible with FastAPI/Starlette Request objects.

Returns:

An OpenResponsesRequest instance with all web image URLs converted to base64 data URIs.

Raises:

  • ValueError – If request.state.request_id is not set, or if any image URL cannot be downloaded.
  • pydantic.ValidationError – If the request body is invalid.

Return type:

OpenResponsesRequest

model_config

model_config: ClassVar[ConfigDict] = {'frozen': True}

source

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

request_id

request_id: RequestID

source

A unique identifier for the request.