Skip to content

vllm.entrypoints.openai.responses.protocol

Classes:

Functions:

PromptCacheOptions

Bases: OpenAIBaseModel

OpenAI prompt_cache_options; defined here because openai>=2.25 lacks it

PromptCacheOptionsParam

Bases: PromptCacheOptions

Request-side variant; prewarm is request-only in OpenAI's schema.

ResponseRawMessageAndToken

Bases: OpenAIBaseModel

Class to show the raw message. If message / tokens diverge, tokens is the source of truth

ResponsesRequest

Bases: OpenAIBaseModel

Methods:

_grammar_from_parser = PrivateAttr(default=False) class-attribute instance-attribute

CAUTION: Should only be set by the parser's adjust_request.

_parser_structured_outputs = PrivateAttr(default=None) class-attribute instance-attribute

Parser-derived constraints that preserve the public request's text metadata.

_tool_search_tools = PrivateAttr(default_factory=list) class-attribute instance-attribute

Tools that tool search loaded and tools did not declare.

They are merged into tools, so the tool parser and the tool-call grammar know them, but are left out of the chat template's tool list (see template_tools). The model sees their schemas in the tool messages.

_normalize_openresponses_input_item(item) staticmethod

Normalize input items to bridge OpenResponses schema and openai-python.

The OpenResponses specification treats several fields as optional (id, status on assistant/reasoning items; annotations on output_text content) that the openai-python SDK marks as required. Fill sensible defaults so payloads conforming to the OpenResponses spec pass SDK validation.

_parse_tool_search_item(item, answered_calls, pending_calls) staticmethod

Parse a tool_search_call / tool_search_output input item into its SDK model, filling the fields the spec makes optional.

A call without call_id uses its id. An output without call_id answers the oldest call that no output answers by call_id and no earlier output answered, so the replayed tool calls and tool messages share ids.

Add tools that tool_search_output input items loaded to tools.

The model sees the loaded schemas in the tool message rendered for each item. A loaded tool that tools already declares (typically a deferred one) keeps its declaration. An undeclared one is added to tools, so that the tool parser and grammar know it, and recorded in _tool_search_tools, so that the chat template does not list it. Either way the template's tool list does not change across searches.

Pydantic runs wrap validators before every before validator, so additional_tools items are hoisted here first, and the tools they declare count as declared.

extract_structured_outputs()

Normalize request constraints into StructuredOutputsParams.

hoist_additional_tools_items(data) classmethod

Move tools declared by additional_tools input items into tools.

Clients such as Codex declare tools through an input item ({"type": "additional_tools", "role": "developer", "tools": [...]}) rather than the top-level tools field. Everything downstream reads request.tools, so merge them there and drop the item from input.

Defined last on purpose: Pydantic runs before validators in reverse definition order, so this runs before the validators that read tools.

input_item_parsing(data) classmethod

Parse input items that are missing required fields or that Pydantic cannot disambiguate in a Union of TypedDict / BaseModel types.

Specifically handles: - function_call -> ResponseFunctionToolCall - reasoning -> ResponseReasoningItem (auto-generates id) - message(role=assistant) -> ResponseOutputMessage (auto-generates id/status and annotations)

Invalid structures are left for Pydantic to reject.

is_include_output_logprobs()

Check if the request includes output logprobs.

template_tools()

tools as the chat template should list them.

Tools that only tool search loaded are left out, so the start of the prompt, and with it the prompt cache, stays the same across searches.

_called_names(tools)

The names the model calls tools by (<namespace>__<name> for namespace members).

_default_input_image_details(value)

Set the API default for input images before SDK type validation.

_hoist_additional_tools_items(data)

See ResponsesRequest.hoist_additional_tools_items. Once the items are gone this does nothing, so it can run more than once.

_merge_additional_tools(tools, added)

Append added to tools, keeping one definition per tool.

Named tools are keyed by (type, namespace, name). A repeated key replaces the earlier definition in place, so the latest one wins (a client resending its history carries every redefinition), and a namespace that is already present is updated and gains only its new tools.

_resolve_named_tool_choice(tool_name, tools)

Resolve a named tool choice to the flat <namespace>__<name> form.

_tool_keys(tools)

(type, namespace, name) of each named tool, namespace members included.

_undeclared_tools(tools, loaded)

The tools in loaded that tools does not declare yet.

Only functions, custom tools and namespaces of them can be loaded; other tool types are ignored. A tool counts as declared when the model would call a declared tool by the same name, whatever its type, so a loaded tool never shadows a declared one or the tool_search function. A namespace that is already declared keeps its own fields and only gains its undeclared tools.

_without_tools(tools, hidden)

tools without the tools whose (type, namespace, name) is in hidden.

A namespace left with no tools is dropped.

serialize_message(msg)

Serializes a single message.

serialize_messages(msgs)

Serializes multiple messages.