Class ResponseCreateParams
-
- All Implemented Interfaces:
-
com.openai.core.Params
public final class ResponseCreateParams implements Params
Creates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call your own custom code or use built-in tools like web search or file search to use your own data as input for the model's response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
ResponseCreateParams.Body
public final class
ResponseCreateParams.Builder
A builder for ResponseCreateParams.
public final class
ResponseCreateParams.Input
Text, image, or file inputs to the model, used to generate a response.
Learn more:
public final class
ResponseCreateParams.ToolChoice
How the model should select which tool (or tools) to use when generating a response. See the
tools
parameter to see how to specify which tools the model can call.public final class
ResponseCreateParams.Truncation
The truncation strategy to use for the model response.
auto
: If the context of this response and previous ones exceeds the model's context window size, the model will truncate the response to fit the context window by dropping input items in the middle of the conversation.disabled
(default): If a model response will exceed the context window size for a model, the request will fail with a 400 error.
-
Method Summary
Modifier and Type Method Description final ResponseCreateParams.Input
input()
Text, image, or file inputs to the model, used to generate a response. final ChatModel
model()
Model ID used to generate the response, like gpt-4o
oro1
.final Optional<List<ResponseIncludable>>
include()
Specify additional output data to include in the model response. final Optional<String>
instructions()
Inserts a system (or developer) message as the first item in the model's context. final Optional<Long>
maxOutputTokens()
An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens. final Optional<Metadata>
metadata()
Set of 16 key-value pairs that can be attached to an object. final Optional<Boolean>
parallelToolCalls()
Whether to allow the model to run tool calls in parallel. final Optional<String>
previousResponseId()
The unique ID of the previous response to the model. final Optional<Reasoning>
reasoning()
o-series models onlyConfiguration options for reasoning models. final Optional<Boolean>
store()
Whether to store the generated model response for later retrieval via API. final Optional<Double>
temperature()
What sampling temperature to use, between 0 and 2. final Optional<ResponseTextConfig>
text()
Configuration options for a text response from the model. final Optional<ResponseCreateParams.ToolChoice>
toolChoice()
How the model should select which tool (or tools) to use when generating a response. final Optional<List<Tool>>
tools()
An array of tools the model may call while generating a response. final Optional<Double>
topP()
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. final Optional<ResponseCreateParams.Truncation>
truncation()
The truncation strategy to use for the model response. final Optional<String>
user()
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. final JsonField<ResponseCreateParams.Input>
_input()
Returns the raw JSON value of input. final JsonField<ChatModel>
_model()
Returns the raw JSON value of model. final JsonField<List<ResponseIncludable>>
_include()
Returns the raw JSON value of include. final JsonField<String>
_instructions()
Returns the raw JSON value of instructions. final JsonField<Long>
_maxOutputTokens()
Returns the raw JSON value of maxOutputTokens. final JsonField<Metadata>
_metadata()
Returns the raw JSON value of metadata. final JsonField<Boolean>
_parallelToolCalls()
Returns the raw JSON value of parallelToolCalls. final JsonField<String>
_previousResponseId()
Returns the raw JSON value of previousResponseId. final JsonField<Reasoning>
_reasoning()
Returns the raw JSON value of reasoning. final JsonField<Boolean>
_store()
Returns the raw JSON value of store. final JsonField<Double>
_temperature()
Returns the raw JSON value of temperature. final JsonField<ResponseTextConfig>
_text()
Returns the raw JSON value of text. final JsonField<ResponseCreateParams.ToolChoice>
_toolChoice()
Returns the raw JSON value of toolChoice. final JsonField<List<Tool>>
_tools()
Returns the raw JSON value of tools. final JsonField<Double>
_topP()
Returns the raw JSON value of topP. final JsonField<ResponseCreateParams.Truncation>
_truncation()
Returns the raw JSON value of truncation. final JsonField<String>
_user()
Returns the raw JSON value of user. final Map<String, JsonValue>
_additionalBodyProperties()
final Headers
_additionalHeaders()
final QueryParams
_additionalQueryParams()
Headers
_headers()
The full set of headers in the parameters, including both fixed and additional headers. QueryParams
_queryParams()
The full set of query params in the parameters, including both fixed and additional query params. final ResponseCreateParams.Builder
toBuilder()
Boolean
equals(Object other)
Integer
hashCode()
String
toString()
final static ResponseCreateParams.Builder
builder()
Returns a mutable builder for constructing an instance of ResponseCreateParams. -
-
Method Detail
-
input
final ResponseCreateParams.Input input()
Text, image, or file inputs to the model, used to generate a response.
Learn more:
-
model
final ChatModel model()
Model ID used to generate the response, like
gpt-4o
oro1
. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.
-
include
final Optional<List<ResponseIncludable>> include()
Specify additional output data to include in the model response. Currently supported values are:
file_search_call.results
: Include the search results of the file search tool call.message.input_image.image_url
: Include image urls from the input message.computer_call_output.output.image_url
: Include image urls from the computer call output.
-
instructions
final Optional<String> instructions()
Inserts a system (or developer) message as the first item in the model's context.
When using along with
previous_response_id
, the instructions from a previous response will be not be carried over to the next response. This makes it simple to swap out system (or developer) messages in new responses.
-
maxOutputTokens
final Optional<Long> maxOutputTokens()
An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.
-
metadata
final Optional<Metadata> metadata()
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
parallelToolCalls
final Optional<Boolean> parallelToolCalls()
Whether to allow the model to run tool calls in parallel.
-
previousResponseId
final Optional<String> previousResponseId()
The unique ID of the previous response to the model. Use this to create multi-turn conversations. Learn more about conversation state.
-
reasoning
final Optional<Reasoning> reasoning()
o-series models only
Configuration options for reasoning models.
-
store
final Optional<Boolean> store()
Whether to store the generated model response for later retrieval via API.
-
temperature
final Optional<Double> temperature()
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or
top_p
but not both.
-
text
final Optional<ResponseTextConfig> text()
Configuration options for a text response from the model. Can be plain text or structured JSON data. Learn more:
-
toolChoice
final Optional<ResponseCreateParams.ToolChoice> toolChoice()
How the model should select which tool (or tools) to use when generating a response. See the
tools
parameter to see how to specify which tools the model can call.
-
tools
final Optional<List<Tool>> tools()
An array of tools the model may call while generating a response. You can specify which tool to use by setting the
tool_choice
parameter.The two categories of tools you can provide the model are:
Built-in tools: Tools that are provided by OpenAI that extend the model's capabilities, like web search or file search. Learn more about built-in tools.
Function calls (custom tools): Functions that are defined by you, enabling the model to call your own code. Learn more about function calling.
-
topP
final Optional<Double> topP()
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or
temperature
but not both.
-
truncation
final Optional<ResponseCreateParams.Truncation> truncation()
The truncation strategy to use for the model response.
auto
: If the context of this response and previous ones exceeds the model's context window size, the model will truncate the response to fit the context window by dropping input items in the middle of the conversation.disabled
(default): If a model response will exceed the context window size for a model, the request will fail with a 400 error.
-
user
final Optional<String> user()
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
-
_input
final JsonField<ResponseCreateParams.Input> _input()
Returns the raw JSON value of input.
Unlike input, this method doesn't throw if the JSON field has an unexpected type.
-
_model
final JsonField<ChatModel> _model()
Returns the raw JSON value of model.
Unlike model, this method doesn't throw if the JSON field has an unexpected type.
-
_include
final JsonField<List<ResponseIncludable>> _include()
Returns the raw JSON value of include.
Unlike include, this method doesn't throw if the JSON field has an unexpected type.
-
_instructions
final JsonField<String> _instructions()
Returns the raw JSON value of instructions.
Unlike instructions, this method doesn't throw if the JSON field has an unexpected type.
-
_maxOutputTokens
final JsonField<Long> _maxOutputTokens()
Returns the raw JSON value of maxOutputTokens.
Unlike maxOutputTokens, this method doesn't throw if the JSON field has an unexpected type.
-
_metadata
final JsonField<Metadata> _metadata()
Returns the raw JSON value of metadata.
Unlike metadata, this method doesn't throw if the JSON field has an unexpected type.
-
_parallelToolCalls
final JsonField<Boolean> _parallelToolCalls()
Returns the raw JSON value of parallelToolCalls.
Unlike parallelToolCalls, this method doesn't throw if the JSON field has an unexpected type.
-
_previousResponseId
final JsonField<String> _previousResponseId()
Returns the raw JSON value of previousResponseId.
Unlike previousResponseId, this method doesn't throw if the JSON field has an unexpected type.
-
_reasoning
final JsonField<Reasoning> _reasoning()
Returns the raw JSON value of reasoning.
Unlike reasoning, this method doesn't throw if the JSON field has an unexpected type.
-
_store
final JsonField<Boolean> _store()
Returns the raw JSON value of store.
Unlike store, this method doesn't throw if the JSON field has an unexpected type.
-
_temperature
final JsonField<Double> _temperature()
Returns the raw JSON value of temperature.
Unlike temperature, this method doesn't throw if the JSON field has an unexpected type.
-
_text
final JsonField<ResponseTextConfig> _text()
Returns the raw JSON value of text.
Unlike text, this method doesn't throw if the JSON field has an unexpected type.
-
_toolChoice
final JsonField<ResponseCreateParams.ToolChoice> _toolChoice()
Returns the raw JSON value of toolChoice.
Unlike toolChoice, this method doesn't throw if the JSON field has an unexpected type.
-
_tools
final JsonField<List<Tool>> _tools()
Returns the raw JSON value of tools.
Unlike tools, this method doesn't throw if the JSON field has an unexpected type.
-
_topP
final JsonField<Double> _topP()
Returns the raw JSON value of topP.
Unlike topP, this method doesn't throw if the JSON field has an unexpected type.
-
_truncation
final JsonField<ResponseCreateParams.Truncation> _truncation()
Returns the raw JSON value of truncation.
Unlike truncation, this method doesn't throw if the JSON field has an unexpected type.
-
_user
final JsonField<String> _user()
Returns the raw JSON value of user.
Unlike user, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalBodyProperties
final Map<String, JsonValue> _additionalBodyProperties()
-
_additionalHeaders
final Headers _additionalHeaders()
-
_additionalQueryParams
final QueryParams _additionalQueryParams()
-
_headers
Headers _headers()
The full set of headers in the parameters, including both fixed and additional headers.
-
_queryParams
QueryParams _queryParams()
The full set of query params in the parameters, including both fixed and additional query params.
-
toBuilder
final ResponseCreateParams.Builder toBuilder()
-
builder
final static ResponseCreateParams.Builder builder()
Returns a mutable builder for constructing an instance of ResponseCreateParams.
The following fields are required:
.input() .model()
-
-
-
-