Contents

streamResponse(to:options:contextOptions:metadata:)

Produces a response stream to a prompt.

Declaration

final func streamResponse(to prompt: Prompt, options: GenerationOptions = GenerationOptions(), contextOptions: ContextOptions = ContextOptions(), metadata: [String : any Sendable & Codable & Equatable] = [:]) -> sending LanguageModelSession.ResponseStream<String>

Parameters

  • prompt:

    A prompt for the model to respond to.

  • options:

    Options that control how tokens are sampled from the distribution the model produces.

  • contextOptions:

    Settings that configure how the model is prompted.

  • metadata:

    Metadata to attach to the request.

Return Value

A response stream that produces aggregated tokens.

Discussion

See Also

Streaming a response with metadata