create Response
Sends a request to the Responses API.
This is the low-level entry point; the createResponse overloads that take parameters and an input are usually more convenient.
Example:
val request = responseParams { model = ChatModel.DEEPSEEK_V4_PRO }
.createRequest("Explain the Kotlin type system")
val response = client.createResponse(request)Return
The ModelResponse the API produced
Parameters
The fully configured request object containing all parameters for the API call
Throws
if the API returns a non-2xx status
Sends a conversation to the Responses API with custom parameters.
The API keeps no state between calls, so input carries the whole history — appending the previous response's ModelResponse.output to it is what continues the conversation.
Example:
val params = responseParams { instructions = "You are a helpful assistant." }
val history = mutableListOf<ResponseItem>(MessageItem(ResponseRole.USER, "What is 6 * 7?"))
val answer = client.createResponse(params, history)
history += answer.output
history += MessageItem(ResponseRole.USER, "And 6 * 8?")
val next = client.createResponse(params, history)Return
The ModelResponse the API produced
Parameters
Configuration parameters that control the model's behavior
The conversation so far, in the order the model should see it
Throws
if the API returns a non-2xx status
Sends a single user message to the Responses API with custom parameters.
Example:
val params = responseParams {
model = ChatModel.DEEPSEEK_V4_PRO
reasoning = ReasoningConfig(ReasoningEffort.MAX)
}
val response = client.createResponse(params, "Prove that sqrt(2) is irrational")Return
The ModelResponse the API produced
Parameters
Configuration parameters that control the model's behavior
Text of the user's message
Throws
if the API returns a non-2xx status
Sends a single user message to the Responses API with default parameters.
Example:
println(client.createResponse("What is the capital of France?").outputText)Return
The ModelResponse the API produced
Parameters
Text of the user's message
Throws
if the API returns a non-2xx status
Sends a conversation to the Responses API with default parameters.
Return
The ModelResponse the API produced
Parameters
The conversation so far, in the order the model should see it
Throws
if the API returns a non-2xx status
Sends a conversation built by a DSL, with custom parameters.
Example:
val response = client.createResponse(params) {
user("What is in this image?")
items(previous.output)
functionCallOutput(callId, """{"temp_c": 21}""")
}Return
The ModelResponse the API produced
Parameters
Configuration parameters that control the model's behavior
A builder block for constructing the conversation
Throws
if the API returns a non-2xx status
Sends a fully customizable Responses API request.
Example:
val response = client.createResponse {
params {
model = ChatModel.DEEPSEEK_FLASH
instructions = "You are a helpful assistant."
maxOutputTokens = 2000
}
input {
user {
text("What is in this image?")
image("https://example.com/cat.jpg", ImageDetail.LOW)
}
}
}Return
The ModelResponse the API produced
Parameters
A builder block for constructing the complete request
Throws
if the API returns a non-2xx status
Streams a conversation through the Responses API with custom parameters.
Example:
val params = responseStreamParams { instructions = "You are a helpful assistant." }
client.createResponse(params, history).collect { event ->
if (event is OutputTextDeltaEvent) print(event.delta)
}Return
A Flow of the events the API emits, in order
Parameters
Parameters controlling the model's behavior
The conversation so far, in the order the model should see it
Throws
from the returned Flow's collector if the API returns a non-2xx status
Streams a single user message through the Responses API with custom parameters.
Return
A Flow of the events the API emits, in order
Parameters
Parameters controlling the model's behavior
Text of the user's message
Throws
from the returned Flow's collector if the API returns a non-2xx status
Streams a single user message through the Responses API with default parameters.
Example:
client.createResponse("Write a haiku about Kotlin").collect { event ->
if (event is OutputTextDeltaEvent) print(event.delta)
}Return
A Flow of the events the API emits, in order
Parameters
Text of the user's message
Throws
from the returned Flow's collector if the API returns a non-2xx status
Streams a conversation through the Responses API with default parameters.
Return
A Flow of the events the API emits, in order
Parameters
The conversation so far, in the order the model should see it
Throws
from the returned Flow's collector if the API returns a non-2xx status
Streams a conversation built by a DSL, with custom parameters.
Return
A Flow of the events the API emits, in order
Parameters
Parameters controlling the model's behavior
A builder block for constructing the conversation
Throws
from the returned Flow's collector if the API returns a non-2xx status
Streams a fully customizable Responses API request.
Example:
client.createResponse {
params {
model = ChatModel.DEEPSEEK_V4_PRO
reasoning = ReasoningConfig(ReasoningEffort.LOW)
}
input { user("Write a haiku about Kotlin") }
}.collect { event ->
if (event is OutputTextDeltaEvent) print(event.delta)
}Return
A Flow of the events the API emits, in order
Parameters
A builder block for constructing the complete streaming request
Throws
from the returned Flow's collector if the API returns a non-2xx status