POST
https://{instance}-be.glean.com
/
rest
/
api
/
v1
/
chat
from glean import Glean, models
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:

    res = g_client.client.chat.create(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
application/json

OK

A single response from the /chat backend.