streamResponse method

Future<ResponseStream> streamResponse({
  1. bool? background,
  2. List<String>? include,
  3. Input? input,
  4. String? instructions,
  5. int? maxOutputTokens,
  6. Map<String, dynamic>? metadata,
  7. ChatModel? model,
  8. bool? parallelToolCalls,
  9. String? previousResponseId,
  10. ReasoningOptions? reasoning,
  11. bool? store,
  12. num? temperature,
  13. TextFormat? text,
  14. ToolChoice? toolChoice,
  15. List<Tool>? tools,
  16. num? topP,
  17. Truncation? truncation,
  18. String? user,
})

Implementation

Future<ResponseStream> streamResponse({
  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 sse = streamJson("/responses", {
    "stream": true,
    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,
  });

  return ResponseStream(sse);
}