Glean offers official API clients for several popular programming languages to help developers integrate Glean’s powerful search and knowledge capabilities into their applications. These clients provide language-specific interfaces to Glean’s APIs, making it easier to build custom solutions without having to handle the low-level HTTP requests.

This page provides information about our official API clients and instructions for installing and using them in your preferred programming language.

Official API Clients

Glean provides official API clients for the following languages:

Installing the API Clients

1

Install the Python client

pip install glean-api-client

Or using Poetry:

poetry add glean-api-client
2

Initialize the client

from glean import Glean
import os

# Initialize with API token
with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as client:
    # Use the client...
    pass
3

Example usage

from glean import Glean, models
import os

with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as client:
    # Send a chat message to Glean
    res = client.client.chat.create(messages=[
        {
            "fragments": [
                models.ChatMessageFragment(
                    text="What are the company holidays this year?",
                ),
            ],
        },
    ], timeout_millis=30000)

    # Handle response
    print(res)

Additional Resources

For more detailed information about using these API clients, please refer to the documentation in their respective GitHub repositories: