Session API integration

Updated at:

This document explains how to integrate the streaming session API of the intelligent conversation bot.

Procedure

The following steps and diagram show the integration process for the large model session API:

image
  1. First, call the ApplyForStreamAccessToken API to obtain security authentication information. The API returns AccessToken, ChannelId, and StreamSecret for subsequent use. This information is valid for 2 hours, after which you must call the API again to obtain a new set. For more information, see Get connection information for streaming calls.

  2. Next, generate the signature (Sign) required to call the streaming session API. You calculate the signature using the current timestamp (Timestamp) and the StreamSecret parameter from 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, which allows you to listen for SSE events and receive the streaming output from the large model. The streaming API returns multiple responses, and each response contains the complete reply. Therefore, the frontend must replace the previous reply with the new one. For more information, see Streaming session API.

Integration examples