- retrieve - Retrieve an agent
- retrieveSchemas - List an agent's schemas
- list - Search agents
- runStream - Create an agent run and stream the response
- run - Create an agent run and wait for the response
Returns details of an agent created in the Agent Builder.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.operations.GetAgentResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
GetAgentResponse res = sdk.client().agents().retrieve()
.agentId("<id>")
.call();
if (res.agent().isPresent()) {
// handle response
}
}
}
| Parameter |
Type |
Required |
Description |
locale |
Optional<String> |
➖ |
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. |
timezoneOffset |
Optional<Long> |
➖ |
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
agentId |
String |
✔️ |
The ID of the agent. |
GetAgentResponse
| Error Type |
Status Code |
Content Type |
| models/errors/APIException |
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.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.operations.GetAgentSchemasResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
GetAgentSchemasResponse res = sdk.client().agents().retrieveSchemas()
.agentId("<id>")
.call();
if (res.agentSchemas().isPresent()) {
// handle response
}
}
}
| Parameter |
Type |
Required |
Description |
locale |
Optional<String> |
➖ |
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. |
timezoneOffset |
Optional<Long> |
➖ |
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
agentId |
String |
✔️ |
The ID of the agent. |
GetAgentSchemasResponse
| Error Type |
Status Code |
Content Type |
| models/errors/APIException |
4XX, 5XX |
*/* |
Search for agents by agent name.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.SearchAgentsRequest;
import com.glean.api_client.glean_api_client.models.operations.SearchAgentsResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
SearchAgentsRequest req = SearchAgentsRequest.builder()
.name("HR Policy Agent")
.build();
SearchAgentsResponse res = sdk.client().agents().list()
.request(req)
.call();
if (res.searchAgentsResponse().isPresent()) {
// handle response
}
}
}
| Parameter |
Type |
Required |
Description |
request |
SearchAgentsRequest |
✔️ |
The request object to use for the request. |
SearchAgentsResponse
| Error Type |
Status Code |
Content Type |
| models/errors/APIException |
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.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.AgentRunCreate;
import com.glean.api_client.glean_api_client.models.components.Message;
import com.glean.api_client.glean_api_client.models.operations.CreateAndStreamRunResponse;
import java.lang.Exception;
import java.util.List;
public class Application {
public static void main(String[] args) throws Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
AgentRunCreate req = AgentRunCreate.builder()
.agentId("<id>")
.messages(List.of(
Message.builder()
.role("USER")
.build()))
.build();
CreateAndStreamRunResponse res = sdk.client().agents().runStream()
.request(req)
.call();
if (res.res().isPresent()) {
// handle response
}
}
}
| Parameter |
Type |
Required |
Description |
request |
AgentRunCreate |
✔️ |
The request object to use for the request. |
CreateAndStreamRunResponse
| Error Type |
Status Code |
Content Type |
| models/errors/APIException |
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.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.AgentRunCreate;
import com.glean.api_client.glean_api_client.models.components.Message;
import com.glean.api_client.glean_api_client.models.operations.CreateAndWaitRunResponse;
import java.lang.Exception;
import java.util.List;
public class Application {
public static void main(String[] args) throws Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
AgentRunCreate req = AgentRunCreate.builder()
.agentId("<id>")
.messages(List.of(
Message.builder()
.role("USER")
.build()))
.build();
CreateAndWaitRunResponse res = sdk.client().agents().run()
.request(req)
.call();
if (res.agentRunWaitResponse().isPresent()) {
// handle response
}
}
}
| Parameter |
Type |
Required |
Description |
request |
AgentRunCreate |
✔️ |
The request object to use for the request. |
CreateAndWaitRunResponse
| Error Type |
Status Code |
Content Type |
| models/errors/APIException |
4XX, 5XX |
*/* |