Overview
The Agents client provides methods for creating, managing, and testing conversational AI agents. Access it via client.conversational_ai.agents.
Methods
create
client.conversational_ai.agents.create(
conversation_config: ConversationalConfig,
platform_settings: Optional[AgentPlatformSettingsRequestModel] = None,
workflow: Optional[AgentWorkflowRequestModel] = None,
name: Optional[str] = None,
tags: Optional[Sequence[str]] = None,
coaching_settings: Optional[dict] = None,
request_options: Optional[RequestOptions] = None,
) -> CreateAgentResponseModel
Create an agent from a config object.
conversation_config
ConversationalConfig
required
Conversation configuration for an agent.
platform_settings
AgentPlatformSettingsRequestModel
Platform settings for the agent that aren’t related to the conversation orchestration and content.
workflow
AgentWorkflowRequestModel
Workflow for the agent. This defines the flow of the conversation and how the agent interacts with tools.
A name to make the agent easier to find.
Tags to help classify and filter the agent.
Coaching settings for the agent.
Request-specific configuration.
Returns: CreateAgentResponseModel with the created agent details.
Example:
from elevenlabs import ElevenLabs, ConversationalConfig
client = ElevenLabs(api_key="YOUR_API_KEY")
agent = client.conversational_ai.agents.create(
conversation_config=ConversationalConfig(),
name="Customer Support Agent",
tags=["support", "customer-service"]
)
print(f"Created agent: {agent.agent_id}")
get
client.conversational_ai.agents.get(
agent_id: str,
version_id: Optional[str] = None,
branch_id: Optional[str] = None,
request_options: Optional[RequestOptions] = None,
) -> GetAgentResponseModel
Retrieve config for an agent.
The ID of an agent. This is returned on agent creation.
The ID of the agent version to use.
The ID of the branch to use.
Request-specific configuration.
Returns: GetAgentResponseModel with the agent configuration.
Example:
agent = client.conversational_ai.agents.get(
agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz"
)
print(f"Agent name: {agent.name}")
delete
client.conversational_ai.agents.delete(
agent_id: str,
request_options: Optional[RequestOptions] = None,
) -> None
Delete an agent.
The ID of an agent. This is returned on agent creation.
Request-specific configuration.
Example:
client.conversational_ai.agents.delete(
agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz"
)
update
client.conversational_ai.agents.update(
agent_id: str,
branch_id: Optional[str] = None,
conversation_config: Optional[ConversationalConfig] = None,
platform_settings: Optional[AgentPlatformSettingsRequestModel] = None,
workflow: Optional[AgentWorkflowRequestModel] = None,
name: Optional[str] = None,
tags: Optional[Sequence[str]] = None,
coaching_settings: Optional[dict] = None,
version_description: Optional[str] = None,
request_options: Optional[RequestOptions] = None,
) -> GetAgentResponseModel
Patches an agent settings.
The ID of an agent. This is returned on agent creation.
The ID of the branch to use.
Conversation configuration for an agent.
platform_settings
AgentPlatformSettingsRequestModel
Platform settings for the agent.
workflow
AgentWorkflowRequestModel
Workflow for the agent.
A name to make the agent easier to find.
Tags to help classify and filter the agent.
Coaching settings for the agent.
Description for this version when publishing changes (only applicable for versioned agents).
Request-specific configuration.
Returns: GetAgentResponseModel with the updated agent configuration.
Example:
updated_agent = client.conversational_ai.agents.update(
agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
name="Updated Support Agent",
tags=["support", "v2"]
)
list
client.conversational_ai.agents.list(
page_size: Optional[int] = None,
search: Optional[str] = None,
archived: Optional[bool] = None,
show_only_owned_agents: Optional[bool] = None,
sort_direction: Optional[SortDirection] = None,
sort_by: Optional[AgentSortBy] = None,
cursor: Optional[str] = None,
request_options: Optional[RequestOptions] = None,
) -> GetAgentsPageResponseModel
Returns a list of your agents and their metadata.
How many agents to return at maximum. Cannot exceed 100, defaults to 30.
Filter agents by archived status.
If set to true, omit agents shared by others and include only the ones you own.
The direction to sort the results (“asc” or “desc”).
The field to sort the results by (e.g., “name”, “created_at”).
Used for fetching next page. Cursor is returned in the response.
Request-specific configuration.
Returns: GetAgentsPageResponseModel with paginated agent list.
Example:
response = client.conversational_ai.agents.list(
page_size=10,
search="support",
show_only_owned_agents=True,
sort_by="name",
sort_direction="asc"
)
for agent in response.agents:
print(f"{agent.name}: {agent.agent_id}")
duplicate
client.conversational_ai.agents.duplicate(
agent_id: str,
name: Optional[str] = None,
request_options: Optional[RequestOptions] = None,
) -> CreateAgentResponseModel
Create a new agent by duplicating an existing one.
The ID of an agent. This is returned on agent creation.
A name to make the agent easier to find.
Request-specific configuration.
Returns: CreateAgentResponseModel with the duplicated agent details.
Example:
cloned_agent = client.conversational_ai.agents.duplicate(
agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
name="Support Agent Copy"
)
simulate_conversation
client.conversational_ai.agents.simulate_conversation(
agent_id: str,
simulation_specification: ConversationSimulationSpecification,
extra_evaluation_criteria: Optional[Sequence[PromptEvaluationCriteria]] = None,
new_turns_limit: Optional[int] = None,
request_options: Optional[RequestOptions] = None,
) -> AgentSimulatedChatTestResponseModel
Run a conversation between the agent and a simulated user.
The ID of an agent. This is returned on agent creation.
simulation_specification
ConversationSimulationSpecification
required
A specification detailing how the conversation should be simulated.
A list of evaluation criteria to test.
Maximum number of new turns to generate in the conversation simulation.
Request-specific configuration.
Returns: AgentSimulatedChatTestResponseModel with simulation results.
Example:
from elevenlabs import AgentConfig, ConversationSimulationSpecification
result = client.conversational_ai.agents.simulate_conversation(
agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
simulation_specification=ConversationSimulationSpecification(
simulated_user_config=AgentConfig(
first_message="Hello, I need help with my order",
language="en",
),
),
new_turns_limit=10
)
simulate_conversation_stream
client.conversational_ai.agents.simulate_conversation_stream(
agent_id: str,
simulation_specification: ConversationSimulationSpecification,
extra_evaluation_criteria: Optional[Sequence[PromptEvaluationCriteria]] = None,
new_turns_limit: Optional[int] = None,
request_options: Optional[RequestOptions] = None,
) -> None
Run a conversation between the agent and a simulated user and stream back the response. Response is streamed back as partial lists of messages that should be concatenated. Once the conversation is complete, a single final message with the conversation analysis will be sent.
simulation_specification
ConversationSimulationSpecification
required
A specification detailing how the conversation should be simulated.
A list of evaluation criteria to test.
Maximum number of new turns to generate in the conversation simulation.
Request-specific configuration.
run_tests
client.conversational_ai.agents.run_tests(
agent_id: str,
tests: Sequence[SingleTestRunRequestModel],
agent_config_override: Optional[AdhocAgentConfigOverrideForTestRequestModel] = None,
branch_id: Optional[str] = None,
request_options: Optional[RequestOptions] = None,
) -> GetTestSuiteInvocationResponseModel
Run selected tests on the agent with provided configuration. If the agent configuration is provided, it will be used to override default agent configuration.
The ID of an agent. This is returned on agent creation.
tests
Sequence[SingleTestRunRequestModel]
required
List of tests to run on the agent.
agent_config_override
AdhocAgentConfigOverrideForTestRequestModel
Configuration overrides to use for testing. If not provided, the agent’s default configuration will be used.
ID of the branch to run the tests on. If not provided, the tests will be run on the agent default configuration.
Request-specific configuration.
Returns: GetTestSuiteInvocationResponseModel with test results.
Example:
from elevenlabs import SingleTestRunRequestModel
test_results = client.conversational_ai.agents.run_tests(
agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
tests=[
SingleTestRunRequestModel(test_id="test_123"),
SingleTestRunRequestModel(test_id="test_456"),
]
)
Async Usage
All methods are available on AsyncElevenLabs client with async/await syntax:
import asyncio
from elevenlabs import AsyncElevenLabs
async def main():
client = AsyncElevenLabs(api_key="YOUR_API_KEY")
# List agents
agents = await client.conversational_ai.agents.list(page_size=10)
# Get specific agent
agent = await client.conversational_ai.agents.get(
agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz"
)
asyncio.run(main())