Strands Agents Typescript SDK
    Preparing search index...

    Interface Model<T>Abstract

    Base abstract class for model providers. Defines the contract that all model provider implementations must follow.

    Model providers handle communication with LLM APIs and implement streaming responses using async iterables.

    interface Model<T extends BaseModelConfig = BaseModelConfig> {
        updateConfig(modelConfig: T): void;
        getConfig(): T;
        stream(
            messages: Message[],
            options?: StreamOptions,
        ): AsyncIterable<ModelStreamEvent>;
        streamAggregated(
            messages: Message[],
            options?: StreamOptions,
        ): AsyncGenerator<
            ModelStreamEvent
            | ContentBlock,
            StreamAggregatedResult,
            undefined,
        >;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Methods

    • Updates the model configuration. Merges the provided configuration with existing settings.

      Parameters

      • modelConfig: T

        Configuration object with model-specific settings to update

      Returns void

    • Streams a conversation with aggregated content blocks and messages. Returns an async generator that yields streaming events and content blocks, and returns the final message with stop reason and optional metadata.

      This method enhances the basic stream() by collecting streaming events into complete ContentBlock and Message objects, which are needed by the agentic loop for tool execution and conversation management.

      The method yields:

      • ModelStreamEvent - Original streaming events (passed through)
      • ContentBlock - Complete content block (emitted when block completes)

      The method returns:

      • StreamAggregatedResult containing the complete message, stop reason, and optional metadata

      Parameters

      • messages: Message[]

        Array of conversation messages

      • Optionaloptions: StreamOptions

        Optional streaming configuration

      Returns AsyncGenerator<
          ModelStreamEvent
          | ContentBlock,
          StreamAggregatedResult,
          undefined,
      >

      Async generator yielding ModelStreamEvent | ContentBlock and returning a StreamAggregatedResult