Session API integration

更新时间:
复制 MD 格式

This document describes the integration process for the Chatbot streaming session API.

Integration steps

The following time series chart and steps describe how to integrate with the Large Language Model (LLM) session API.

image
  1. Call the ApplyForStreamAccessToken API to obtain security credentials. The API returns `AccessToken`, `ChannelId`, and `StreamSecret`. These credentials are valid for 2 hours. After they expire, you must call the API again to obtain new credentials. For more information, see Get connection information for streaming calls.

  2. Generate the signature (Sign) required to call the streaming session API. Calculate the signature using the current timestamp and the `StreamSecret` parameter returned in the previous step. For more information, see Session API signature.

  3. Construct the full URL by combining `AccessToken`, `ChannelId`, `Sign`, and `Timestamp`. Then, use Server-Sent Events (SSE) to make a streaming call to the session API. This lets you listen for SSE events and receive the streaming output from the LLM. The LLM streaming API returns data multiple times. Each response is a complete reply. Your rendering client must overwrite the previous reply with the new one. For more information, see Streaming session API.

Integration examples