vllm.entrypoints.openai.responses.protocol
¶
Classes:
-
PromptCacheOptions–OpenAI prompt_cache_options; defined here because openai>=2.25 lacks it
-
PromptCacheOptionsParam–Request-side variant; prewarm is request-only in OpenAI's schema.
-
ResponseRawMessageAndToken–Class to show the raw message.
-
ResponsesRequest–
Functions:
-
serialize_message–Serializes a single message.
-
serialize_messages–Serializes multiple messages.
PromptCacheOptions
¶
Bases: OpenAIBaseModel
OpenAI prompt_cache_options; defined here because openai>=2.25 lacks it
PromptCacheOptionsParam
¶
ResponseRawMessageAndToken
¶
Bases: OpenAIBaseModel
Class to show the raw message. If message / tokens diverge, tokens is the source of truth
ResponsesRequest
¶
Bases: OpenAIBaseModel
Methods:
-
extract_structured_outputs–Normalize request constraints into
StructuredOutputsParams. -
hoist_additional_tools_items–Move tools declared by
additional_toolsinput items intotools. -
input_item_parsing–Parse input items that are missing required fields or that Pydantic
-
is_include_output_logprobs–Check if the request includes output logprobs.
_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.
_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.
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.
_default_input_image_details(value)
¶
Set the API default for input images before SDK type validation.
_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.
serialize_message(msg)
¶
Serializes a single message.
serialize_messages(msgs)
¶
Serializes multiple messages.