Create and manage agent response tests for quality assurance.
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
const client = new ElevenLabsClient({ apiKey: "your-api-key" });
// Access this API via: client.conversationalAi.tests/**
* Create a new agent response test
*/
client.conversationalAi.tests.create(
request: CreateUnitTestRequest,
requestOptions?: RequestOptions
): HttpResponsePromise<CreateUnitTestResponseModel>;
/**
* Get a test by ID
*/
client.conversationalAi.tests.get(
test_id: string,
requestOptions?: RequestOptions
): HttpResponsePromise<GetUnitTestResponseModel>;
/**
* Update a test
*/
client.conversationalAi.tests.update(
test_id: string,
request: UpdateUnitTestRequest,
requestOptions?: RequestOptions
): HttpResponsePromise<GetUnitTestResponseModel>;
/**
* Delete a test
*/
client.conversationalAi.tests.delete(
test_id: string,
requestOptions?: RequestOptions
): HttpResponsePromise<unknown>;
/**
* List tests with pagination and search
*/
client.conversationalAi.tests.list(
request?: TestsListRequest,
requestOptions?: RequestOptions
): HttpResponsePromise<GetTestsPageResponseModel>;
/**
* Get summaries for multiple tests by IDs
* Returns a dictionary mapping test IDs to test summaries
*/
client.conversationalAi.tests.summaries(
request: ListTestsByIdsRequestModel,
requestOptions?: RequestOptions
): HttpResponsePromise<GetTestsSummariesByIdsResponseModel>;
interface CreateUnitTestRequest {
/** Chat history for the test */
chatHistory: Array<{
role: string;
timeInCallSecs: number;
}>;
/** Success condition description */
successCondition: string;
/** Examples of successful responses */
successExamples: Array<{
response: string;
type: "success";
}>;
/** Examples of failed responses */
failureExamples: Array<{
response: string;
type: "failure";
}>;
/** Test name */
name: string;
}
interface UpdateUnitTestRequest {
/** Chat history for the test */
chatHistory: Array<{
role: string;
timeInCallSecs: number;
}>;
/** Success condition description */
successCondition: string;
/** Examples of successful responses */
successExamples: Array<{
response: string;
type: "success";
}>;
/** Examples of failed responses */
failureExamples: Array<{
response: string;
type: "failure";
}>;
/** Test name */
name: string;
}
interface TestsListRequest {
/** Pagination cursor */
cursor?: string;
/** Number of items per page */
pageSize?: number;
/** Search query string */
search?: string;
}
interface ListTestsByIdsRequestModel {
/** Array of test IDs to retrieve */
testIds: string[];
}Manage test invocation results and resubmit tests.
/**
* List test invocations with pagination
*/
client.conversationalAi.tests.invocations.list(
request: InvocationsListRequest,
requestOptions?: RequestOptions
): HttpResponsePromise<GetTestInvocationsPageResponseModel>;
/**
* Get a test invocation by ID
*/
client.conversationalAi.tests.invocations.get(
test_invocation_id: string,
requestOptions?: RequestOptions
): HttpResponsePromise<GetTestSuiteInvocationResponseModel>;
/**
* Resubmit specific test runs from an invocation
*/
client.conversationalAi.tests.invocations.resubmit(
test_invocation_id: string,
request: ResubmitTestsRequestModel,
requestOptions?: RequestOptions
): HttpResponsePromise<unknown>;
interface InvocationsListRequest {
/** Agent ID to filter invocations */
agentId: string;
/** Number of items per page */
pageSize?: number;
/** Pagination cursor */
cursor?: string;
}
interface ResubmitTestsRequestModel {
/** IDs of test runs to resubmit */
testRunIds: string[];
/** Agent ID to test against */
agentId: string;
}import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";
const client = new ElevenLabsClient({ apiKey: "your-api-key" });
// Simulate a conversation
const result = await client.conversationalAi.agents.simulateConversation(
agent.agent_id,
{
messages: [
{
role: "user",
content: "How do I reset my password?",
},
],
}
);
console.log("Agent response:", result.messages);