Glean API Client

raw JSON →
0.12.24 verified Fri May 01 auth: no python

Python SDK for Glean's enterprise search and AI assistant APIs, generated by Speakeasy. Current version: 0.12.24. Rapidly evolving; release cadence is weekly or upon spec changes.

pip install glean-api-client
error ModuleNotFoundError: No module named 'glean_api_client'
cause Package name in PyPI is `glean-api-client`, but import uses underscores.
fix
Install: pip install glean-api-client. Import: from glean_api_client import Glean
error glean_api_client.errors.ServerValidationError: 'access_token' is a required property
cause The access_token keyword argument not provided or empty string.
fix
Set valid token: Glean(access_token=os.environ.get('GLEAN_ACCESS_TOKEN'))
error TypeError: Glean.__init__() missing 1 required positional argument: 'security'
cause Using positional argument instead of keyword argument for old API.
fix
Use keyword arguments: Glean(access_token='...', server_url='...')
breaking In 0.11.x, the client initialization changed from positional arguments to keyword-only. Using `Glean('token')` will fail.
fix Use keyword argument: `Glean(access_token='token')`.
deprecated All 'deep' search and advanced filter parameters are deprecated in favor of the new `Facet` and `Filter` objects.
fix Use `shared.Facet` and `shared.Filter` in search requests.
gotcha The SDK uses `snake_case` for Python, but the Glean API spec uses `camelCase`. Models auto-convert, but raw response dicts from `resp.raw()` return camelCase fields.
fix Always use dot notation on response objects; avoid direct dict access unless calling `.raw()`.

Initialize the client with an API token and perform a basic search.

import os
from glean_api_client import Glean
from glean_api_client.models import shared

client = Glean(
    access_token=os.environ.get('GLEAN_ACCESS_TOKEN', ''),
    server_url='https://my-glean-instance.glean.com'
)

search_req = shared.SearchRequest(
    query='sales report 2025',
    page_size=10
)
resp = client.search.search(search_req)
print(resp.dict() if resp else 'No results')