@archastro/sdk
    Preparing search index...

    Class StreamResource

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Stream a chat completion Streams a chat completion over Server-Sent Events. Emits thinking_delta for supported reasoning models, message_delta, message_complete, tool_call_*, tool_result, and a terminal done (or error) event. Same request shape as the non-streaming completion endpoint; the app must have the llm_calls entitlement.

      Parameters

      • input: {
            context?: Record<string, unknown>;
            messages: {
                content?: string;
                content_parts?: Record<string, unknown>[];
                resume_token?: string;
                role: string;
                structured_output?: unknown;
                tool_calls?: {
                    arguments: Record<string, unknown>;
                    id: string;
                    name: string;
                    thought_signature?: string;
                }[];
                tool_results?: {
                    content?: string;
                    id: string;
                    name: string;
                    resolution?: unknown;
                }[];
            }[];
            opts: {
                max_tokens?: number;
                model: string;
                server_tools?: Record<string, unknown>[];
                temperature?: number;
                tool_choice?: string;
                tools?: {
                    function: {
                        description?: string;
                        name: string;
                        parameters: Record<string, unknown>;
                    };
                    type: string;
                }[];
            };
            session_id?: string;
        }

        Request body.

        • Optionalcontext?: Record<string, unknown>

          Key-value map used to resolve template variables in message content. Omit if messages contain no templates.

        • messages: {
              content?: string;
              content_parts?: Record<string, unknown>[];
              resume_token?: string;
              role: string;
              structured_output?: unknown;
              tool_calls?: {
                  arguments: Record<string, unknown>;
                  id: string;
                  name: string;
                  thought_signature?: string;
              }[];
              tool_results?: {
                  content?: string;
                  id: string;
                  name: string;
                  resolution?: unknown;
              }[];
          }[]

          Ordered list of conversation messages to send to the model.

        • opts: {
              max_tokens?: number;
              model: string;
              server_tools?: Record<string, unknown>[];
              temperature?: number;
              tool_choice?: string;
              tools?: {
                  function: {
                      description?: string;
                      name: string;
                      parameters: Record<string, unknown>;
                  };
                  type: string;
              }[];
          }

          Model and sampling configuration for this request.

        • Optionalsession_id?: string

          Optional UUID grouping this and other completions under one session in the Developers dashboard. Pass the same value across requests to link them; omit to auto-generate a per-request session.

      Returns AsyncIterable<
          | { data: AIChatStreamDone; event: "done" }
          | { data: AIChatStreamError; event: "error" }
          | { data: AIChatStreamMessageComplete; event: "message_complete" }
          | { data: AIChatStreamMessageDelta; event: "message_delta" }
          | { data: AIChatStreamThinkingDelta; event: "thinking_delta" }
          | { data: AIChatStreamToolCallDelta; event: "tool_call_delta" }
          | { data: AIChatStreamToolResult; event: "tool_result" },
      >

      Server-Sent Events stream