- create - Create an agent
retrieve - Retrieve an agent ⚠️ Deprecated
- update - Edit an agent
retrieve_schemas - List an agent's schemas ⚠️ Deprecated
- import_ - Import an agent
list - Search agents ⚠️ Deprecated
run_stream - Create an agent run and stream the response ⚠️ Deprecated
run - Create an agent run and wait for the response ⚠️ Deprecated
Create an agent.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:
res = glean.client.agents.create()
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
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. |
name |
Optional[str] |
➖ |
The name of the workflow. |
transient |
Optional[bool] |
➖ |
Used to create a transient workflow. |
parent_workflow_id |
Optional[str] |
➖ |
id of the parent workflow for transient workflows |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.WorkflowResult
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Returns details of an agent created in the Agent Builder.
⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use GET /api/agents/{agent_id} instead..
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 |
*/* |
Creates a draft or publishes an agent. Use isDraft=true to save a draft, or isDraft=false (or omit) to publish immediately. Only draft and publish modes are supported.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:
glean.client.agents.update(agent_id="<id>")
# Use the SDK ...
| 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. |
name |
Optional[str] |
➖ |
The name of the workflow. |
id |
Optional[str] |
➖ |
The workflow ID we want to update. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| 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.
⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use GET /api/agents/{agent_id}/schemas instead..
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 |
*/* |
Imports an agent from its on-disk folder representation (spec.yaml, instructions.md, skills/, subagents/) packaged as a zip, and creates or updates the agent. Inverse of the export flow: the folder-to-schema conversion runs server-side. The bundle must contain only regular files; symlinks are resolved by the caller at packaging time.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:
res = glean.client.agents.import_(agent_id="<id>", bundle={
"file_name": "example.file",
"content": open("example.file", "rb"),
}, version_source=models.VersionSource.USER)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent to create or update. |
bundle |
models.Bundle |
✔️ |
Zip of the agent folder (spec.yaml, instructions.md, skills/, subagents/) with symlinks dereferenced.
|
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. |
git_commit_sha |
Optional[str] |
➖ |
Optional Git commit SHA to associate with this import. |
git_author_id |
Optional[str] |
➖ |
Optional VCS commit author ID to associate with this import. |
commit_message |
Optional[str] |
➖ |
Optional commit message for the imported version. |
sync_mode |
Optional[models.ImportAgentSyncMode] |
➖ |
Whether the imported version is staged (saved without updating the live version) or published directly to the live version.
|
version_source |
Optional[models.VersionSource] |
➖ |
Provenance recorded on the staged commit or published version this import produces. Doesn't change the agent's management mode (workflowSource). GIT: synced from a Git repository. USER: uploaded by a user. Defaults to USER when omitted. Ignored for transient imports.
|
published_baseline_hash |
Optional[str] |
➖ |
Optional baseline hash of the currently published agent definition. When publish hash validation is enabled, an import updating an existing agent with syncMode PUBLISHED is rejected with HTTP 409 if the current published definition hash is nonempty and does not match this baseline. Leading and trailing whitespace is trimmed; omitted or blank values skip validation. Ignored for STAGED imports, new agents, and transient previews.
|
is_draft |
Optional[bool] |
➖ |
Deprecated. Draft mutation semantics are not supported for transient previews. Use transient and parentWorkflowId instead.
|
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ImportAgentResponse
| Error Type |
Status Code |
Content Type |
| errors.ErrorResponse |
404 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Search for agents by agent name.
⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use POST /api/agents/search instead..
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.
⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use POST /api/agents/{agent_id}/runs with stream=true instead..
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.MessageInput] |
➖ |
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 |
application/json |
| errors.UnauthorizedAgentToolsError |
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.
⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use POST /api/agents/{agent_id}/runs instead..
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.MessageInput] |
➖ |
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.UnauthorizedAgentToolsError |
422 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |