POST
/
rest
/
api
/
v1
/
chat#stream
from glean.api_client import Glean, models
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
    instance=os.getenv("GLEAN_INSTANCE", ""),
) as glean:

    res = glean.client.chat.create_stream(messages=[
        {
            "fragments": [
                models.ChatMessageFragment(
                    text="What are the company holidays this year?",
                ),
            ],
        },
    ], timeout_millis=30000)

    # Handle response
    print(res)
{
"messages": [
{
"author": "GLEAN_AI",
"messageType": "CONTENT",
"hasMoreFragments": false,
"agentConfig": {
"agent": "DEFAULT",
"mode": "DEFAULT"
},
"fragments": [
{
"text": "There are no holidays!"
}
]
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

timezoneOffset
integer

The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.

Body

application/json

Includes chat history for Glean AI to respond to.

The body is of type object.

Response

200
text/plain

OK

The response is of type object.