createResponse method
Future<Response>
createResponse({
- bool? background,
- List<
String> ? include, - Input? input,
- String? instructions,
- int? maxOutputTokens,
- Map<
String, dynamic> ? metadata, - ChatModel? model,
- bool? parallelToolCalls,
- String? previousResponseId,
- ReasoningOptions? reasoning,
- bool? store,
- num? temperature,
- TextFormat? text,
- ToolChoice? toolChoice,
- List<
Tool> ? tools, - num? topP,
- Truncation? truncation,
- String? user,
Implementation
Future<Response> createResponse({
bool? background,
List<String>? include,
Input? input,
String? instructions,
int? maxOutputTokens,
Map<String, dynamic>? metadata,
ChatModel? model,
bool? parallelToolCalls,
String? previousResponseId,
ReasoningOptions? reasoning,
bool? store,
num? temperature,
TextFormat? text,
ToolChoice? toolChoice,
List<Tool>? tools,
num? topP,
Truncation? truncation,
String? user,
}) async {
final resp = await postJson("/responses", {
if (background != null) 'background': background,
if (include != null) 'include': include,
if (input != null) 'input': input.toJson(),
if (instructions != null) 'instructions': instructions,
if (maxOutputTokens != null) 'max_output_tokens': maxOutputTokens,
if (metadata != null) 'metadata': metadata,
if (model != null) 'model': model.toJson(),
if (parallelToolCalls != null) 'parallel_tool_calls': parallelToolCalls,
if (previousResponseId != null) 'previous_response_id': previousResponseId,
if (reasoning != null) 'reasoning': reasoning.toJson(),
if (store != null) 'store': store,
if (temperature != null) 'temperature': temperature,
if (text != null) 'text': text.toJson(),
if (toolChoice != null) 'tool_choice': toolChoice.toJson(),
if (tools != null) 'tools': tools.map((t) => t.toJson()).toList(),
if (topP != null) 'top_p': topP,
if (truncation != null) 'truncation': truncation.toJson(),
if (user != null) 'user': user,
});
if (resp.statusCode == 200) {
return Response.fromJson(jsonDecode(resp.body));
} else {
throw OpenAIRequestException.fromHttpResponse(resp);
}
}