Simple Chatbot
The Glean Chat API is a powerful tool for integrating conversational AI into your products. It allows you to create custom conversational interfaces that leverage Glean’s AI capabilities. This page provides examples of how to use the Chat API to integrate conversational AI into your products.
Example Conversational Flow Diagram
The following diagram illustrates a multi-message conversation flow between an end user, a custom client, and the Glean server.
cURL Example
Python Example
Note: The following example streams the output as it becomes available, whenever possible. To turn off streaming outputs, please set the stream
field in the request body to False
As of 04/24/2025, the /chat API response has been changed. The previous way of
processing the response message stream has been deprecated. As in-line
citations (citations inside the fragments) do not contain startIndex
or
endIndex
, you might still find this deprecated function useful as a way to
get the endIndex
of each citation (startIndex
is no longer populated).
Please also note that this function may return the same citation multiple
times, although each duplicated citation should have a different endIndex
.