- search - Search agents
- get - Get agent
- getSchemas - Get agent schemas
- createRun - Create agent run
Search agents available to the authenticated user 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.PlatformAgentsSearchRequest;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsSearchResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws PlatformProblemDetailException, Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
PlatformAgentsSearchRequest req = PlatformAgentsSearchRequest.builder()
.name("HR Policy Agent")
.build();
PlatformAgentsSearchResponse res = sdk.agents().search()
.request(req)
.call();
if (res.platformAgentsSearchResponse().isPresent()) {
System.out.println(res.platformAgentsSearchResponse().get());
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
request |
PlatformAgentsSearchRequest | ✔️ | The request object to use for the request. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/PlatformProblemDetailException | 400, 401, 403, 404, 408, 413, 429 | application/problem+json |
| models/errors/PlatformProblemDetailException | 500, 503 | application/problem+json |
| models/errors/APIException | 4XX, 5XX | */* |
Retrieve details for an agent available to the authenticated user.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsGetResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws PlatformProblemDetailException, Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
PlatformAgentsGetResponse res = sdk.agents().get()
.agentId("{agent_id}")
.call();
if (res.platformAgentGetResponse().isPresent()) {
System.out.println(res.platformAgentGetResponse().get());
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
agentId |
String | ✔️ | ID of the agent to retrieve. | {agent_id} |
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/PlatformProblemDetailException | 400, 401, 403, 404, 408, 429 | application/problem+json |
| models/errors/PlatformProblemDetailException | 500, 503 | application/problem+json |
| models/errors/APIException | 4XX, 5XX | */* |
Retrieve an agent's input and output JSON schemas.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsGetSchemasResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws PlatformProblemDetailException, Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
PlatformAgentsGetSchemasResponse res = sdk.agents().getSchemas()
.agentId("{agent_id}")
.includeTools(false)
.call();
if (res.platformAgentSchemasResponse().isPresent()) {
System.out.println(res.platformAgentSchemasResponse().get());
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
agentId |
String | ✔️ | ID of the agent whose schemas should be retrieved. | {agent_id} |
includeTools |
Optional<Boolean> | ➖ | Whether to include tool metadata in the response. |
PlatformAgentsGetSchemasResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/PlatformProblemDetailException | 400, 401, 403, 404, 408, 429 | application/problem+json |
| models/errors/PlatformProblemDetailException | 500, 503 | application/problem+json |
| models/errors/APIException | 4XX, 5XX | */* |
Execute an agent run. Set stream to true to receive server-sent events; otherwise the response contains the final agent messages.
package hello.world;
import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.*;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.errors.PlatformUnauthorizedAgentToolsProblemException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsCreateRunResponse;
import java.lang.Exception;
import java.util.List;
public class Application {
public static void main(String[] args) throws PlatformUnauthorizedAgentToolsProblemException, PlatformProblemDetailException, Exception {
Glean sdk = Glean.builder()
.apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
.build();
PlatformAgentsCreateRunResponse res = sdk.agents().createRun()
.agentId("{agent_id}")
.platformAgentRunCreateRequest(PlatformAgentRunCreateRequest.builder()
.messages(List.of(
PlatformMessage.builder()
.role(PlatformMessageRole.USER)
.content(List.of(
PlatformMessageTextBlock.builder()
.text("What is our parental leave policy?")
.type(PlatformContentType.TEXT)
.build()))
.build()))
.build())
.call();
if (res.platformAgentRunWaitResponse().isPresent()) {
System.out.println(res.platformAgentRunWaitResponse().get());
}
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
agentId |
String | ✔️ | ID of the agent to run. | {agent_id} |
platformAgentRunCreateRequest |
PlatformAgentRunCreateRequest | ✔️ | N/A | { "messages": [ { "role": "USER", "content": [ { "text": "What is our parental leave policy?", "type": "text" } ] } ] } |
PlatformAgentsCreateRunResponse
| Error Type | Status Code | Content Type |
|---|---|---|
| models/errors/PlatformUnauthorizedAgentToolsProblemException | 422 | application/problem+json |
| models/errors/PlatformProblemDetailException | 400, 401, 403, 404, 408, 409, 413, 429 | application/problem+json |
| models/errors/PlatformProblemDetailException | 500, 503 | application/problem+json |
| models/errors/APIException | 4XX, 5XX | */* |