Implementation:Openai Openai python Response Prompt
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete type for representing a reference to a reusable prompt template and its variable substitutions, provided by the openai-python SDK.
Description
ResponsePrompt is a Pydantic model that holds a reference to a stored prompt template. It contains an id field identifying the template, an optional variables dictionary that maps variable names to substitution values (which can be strings, ResponseInputText, ResponseInputImage, or ResponseInputFile objects), and an optional version string to pin a specific template revision. This enables the Responses API's reusable prompts feature.
Usage
Import this type when you need to inspect or type-check prompt template references returned from the API. For constructing prompt parameters to send to the API, use ResponsePromptParam instead.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/response_prompt.py
Signature
class ResponsePrompt(BaseModel):
"""Reference to a prompt template and its variables."""
id: str
variables: Optional[Dict[str, Variables]] = None
version: Optional[str] = None
Import
from openai.types.responses import ResponsePrompt
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes | The unique identifier of the prompt template to use. |
| variables | Optional[Dict[str, Variables]] | No | Optional map of values to substitute for variables in the prompt. Values can be strings or input types (text, image, file). |
| version | Optional[str] | No | Optional version of the prompt template. |
Usage Examples
import openai
client = openai.OpenAI()
response = client.responses.create(
model="gpt-4o",
input={
"prompt": {
"id": "prompt_abc123",
"variables": {"user_name": "Alice", "topic": "quantum computing"},
"version": "v2",
}
},
)
# The response.prompt field (if present) would be a ResponsePrompt instance
print(response)