sampleWithResponseStream method

Future<SampleWithResponseStreamResponse> sampleWithResponseStream({
  1. required Uint8List body,
  2. required String jobArn,
  3. required String trajectoryId,
})

Sends a streaming inference request to the model during a job execution. Returns the response as a stream of payload chunks. Each turn is captured for later use.

May throw AccessDeniedException. May throw InternalServiceError. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter body : The raw inference request body in OpenAI-compatible JSON format.

Parameter jobArn : The job ARN that identifies which model session to route the inference request to.

Parameter trajectoryId : The trajectory ID for grouping turns into a single rollout. Each turn is captured for later use.

Implementation

Future<SampleWithResponseStreamResponse> sampleWithResponseStream({
  required Uint8List body,
  required String jobArn,
  required String trajectoryId,
}) async {
  final headers = <String, String>{
    'X-Amzn-SageMaker-Job-Arn': jobArn.toString(),
    'X-Amzn-SageMaker-Trajectory-Id': trajectoryId.toString(),
  };
  final response = await _protocol.sendRaw(
    payload: body,
    method: 'POST',
    requestUri: '/sample-with-response-stream',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return SampleWithResponseStreamResponse(
    body: await response.stream.toBytes(),
    contentType:
        _s.extractHeaderStringValue(response.headers, 'Content-Type'),
  );
}