- search - Search agents
- get - Get agent
- get_schemas - Get agent schemas
- create_run - Create agent run
Search agents available to the authenticated user by agent name.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.agents.search(name="HR Policy Agent")
# Handle response
print(res)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
name |
Optional[str] | ➖ | Case-insensitive substring to match against agent names. If omitted or empty, no name filter is applied. | HR Policy Agent |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.PlatformAgentsSearchResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.PlatformProblemDetailError | 400, 401, 403, 404, 408, 413, 429 | application/problem+json |
| errors.PlatformProblemDetailError | 500, 503 | application/problem+json |
| errors.GleanError | 4XX, 5XX | */* |
Retrieve details for an agent available to the authenticated user.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.agents.get(agent_id="<id>")
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id |
str | ✔️ | ID of the agent to retrieve. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.PlatformAgentGetResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.PlatformProblemDetailError | 400, 401, 403, 404, 408, 429 | application/problem+json |
| errors.PlatformProblemDetailError | 500, 503 | application/problem+json |
| errors.GleanError | 4XX, 5XX | */* |
Retrieve an agent's input and output JSON schemas.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.agents.get_schemas(agent_id="<id>", include_tools=False)
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id |
str | ✔️ | ID of the agent whose schemas should be retrieved. |
include_tools |
Optional[bool] | ➖ | Whether to include tool metadata in the response. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.PlatformAgentSchemasResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.PlatformProblemDetailError | 400, 401, 403, 404, 408, 429 | application/problem+json |
| errors.PlatformProblemDetailError | 500, 503 | application/problem+json |
| errors.GleanError | 4XX, 5XX | */* |
Execute an agent run. Set stream to true to receive server-sent events; otherwise the response contains the final agent messages.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.agents.create_run(agent_id="<id>", messages=[
{
"role": models.PlatformMessageRole.USER,
"content": [],
},
], stream=False)
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id |
str | ✔️ | ID of the agent to run. |
input |
Dict[str, Any] | ➖ | Input fields for an input-form triggered agent. |
messages |
List[models.PlatformMessage] | ➖ | Messages to pass to the agent. When provided, the array MUST contain at least one message and each message MUST specify a valid role and non-empty content. |
metadata |
Dict[str, Any] | ➖ | Metadata to pass to the agent. |
stream |
Optional[bool] | ➖ | Whether to stream the run response as server-sent events. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.PlatformAgentsCreateRunResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.PlatformProblemDetailError | 400, 401, 403, 404, 408, 409, 413, 429 | application/problem+json |
| errors.PlatformProblemDetailError | 500, 503 | application/problem+json |
| errors.GleanError | 4XX, 5XX | */* |