Returns details of an agent created in the Agent Builder.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.agents.retrieve(agent_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
timezone_offset |
Optional[int] |
➖ |
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.Agent
| Error Type |
Status Code |
Content Type |
| errors.ErrorResponse |
404 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Return agent's input and output schemas. You can use these schemas to detect changes to an agent's input or output structure.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.agents.retrieve_schemas(agent_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
timezone_offset |
Optional[int] |
➖ |
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.AgentSchemas
| Error Type |
Status Code |
Content Type |
| errors.ErrorResponse |
404, 422 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Search for agents by agent name.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.agents.list(name="HR Policy Agent")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
Example |
name |
Optional[str] |
➖ |
Filters on the name of the agent. The keyword search is case-insensitive. If search string is ommited or empty, acts as no filter. |
HR Policy Agent |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
|
models.SearchAgentsResponse
| Error Type |
Status Code |
Content Type |
| errors.ErrorResponse |
404, 422 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Executes an agent run and returns the result as a stream of server-sent events (SSE). Note: If the agent uses an input form trigger, all form fields (including optional fields) must be included in the input object.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.agents.run_stream(agent_id="<id>", messages=[
{
"role": "USER",
},
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent to run. |
input |
Dict[str, Any] |
➖ |
The input to the agent. Required when the agent uses an input form trigger. |
messages |
List[models.Message] |
➖ |
The messages to pass an input to the agent. |
metadata |
Dict[str, Any] |
➖ |
The metadata to pass to the agent. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
str
| Error Type |
Status Code |
Content Type |
| errors.ErrorResponse |
404, 409, 422 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Executes an agent run and returns the final response. Note: If the agent uses an input form trigger, all form fields (including optional fields) must be included in the input object.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.agents.run(agent_id="<id>", messages=[
{
"role": "USER",
},
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent to run. |
input |
Dict[str, Any] |
➖ |
The input to the agent. Required when the agent uses an input form trigger. |
messages |
List[models.Message] |
➖ |
The messages to pass an input to the agent. |
metadata |
Dict[str, Any] |
➖ |
The metadata to pass to the agent. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.AgentRunWaitResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |