Class: ElevenlabsClient::Endpoints::AgentsPlatform::Agents

Inherits:
Object
  • Object
show all
Defined in:
lib/elevenlabs_client/endpoints/agents_platform/agents.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Agents

Returns a new instance of Agents.



7
8
9
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 7

def initialize(client)
  @client = client
end

Instance Method Details

#calculate_llm_usage(agent_id, **options) ⇒ Hash

POST /v1/convai/agent/agent_id/llm-usage/calculate Calculates expected number of LLM tokens needed for the specified agent Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/calculate-llm-usage

Parameters:

  • agent_id (String)

    The id of an agent

  • options (Hash)

    Calculation parameters

Options Hash (**options):

  • :prompt_length (Integer)

    Optional length of the prompt in characters

  • :number_of_pages (Integer)

    Optional pages of content in pdf documents OR urls in agent's Knowledge Base

  • :rag_enabled (Boolean)

    Optional whether RAG is enabled

Returns:

  • (Hash)

    LLM usage pricing information



157
158
159
160
161
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 157

def calculate_llm_usage(agent_id, **options)
  endpoint = "/v1/convai/agent/#{agent_id}/llm-usage/calculate"
  request_body = options.compact
  @client.post(endpoint, request_body)
end

#create(**options) ⇒ Hash

POST /v1/convai/agents/create Create an agent from a config object Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/create

Parameters:

  • options (Hash)

    Agent creation parameters

Options Hash (**options):

  • :conversation_config (Hash)

    Required conversation configuration for an agent

  • :platform_settings (Hash)

    Optional platform settings for the agent

  • :name (String)

    Optional name to make the agent easier to find

  • :tags (Array<String>)

    Optional tags to help classify and filter the agent

Returns:

  • (Hash)

    JSON response containing agent_id



21
22
23
24
25
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 21

def create(**options)
  endpoint = "/v1/convai/agents/create"
  request_body = options
  @client.post(endpoint, request_body)
end

#delete(agent_id) ⇒ Hash

DELETE /v1/convai/agents/agent_id Delete an agent Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/delete

Parameters:

  • agent_id (String)

    The id of an agent

Returns:

  • (Hash)

    Empty response on success



84
85
86
87
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 84

def delete(agent_id)
  endpoint = "/v1/convai/agents/#{agent_id}"
  @client.delete(endpoint)
end

#duplicate(agent_id, **options) ⇒ Hash

POST /v1/convai/agents/agent_id/duplicate Create a new agent by duplicating an existing one Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/duplicate

Parameters:

  • agent_id (String)

    The id of an agent to duplicate

  • options (Hash)

    Duplication parameters

Options Hash (**options):

  • :name (String)

    Optional name to make the agent easier to find

Returns:

  • (Hash)

    JSON response containing new agent_id



97
98
99
100
101
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 97

def duplicate(agent_id, **options)
  endpoint = "/v1/convai/agents/#{agent_id}/duplicate"
  request_body = options.compact
  @client.post(endpoint, request_body)
end

#get(agent_id) ⇒ Hash

GET /v1/convai/agents/agent_id Retrieve config for an agent Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/get

Parameters:

  • agent_id (String)

    The id of an agent

Returns:

  • (Hash)

    Agent configuration and metadata



33
34
35
36
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 33

def get(agent_id)
  endpoint = "/v1/convai/agents/#{agent_id}"
  @client.get(endpoint)
end

GET /v1/convai/agents/agent_id/link Get the current link used to share the agent with others Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/link

Parameters:

  • agent_id (String)

    The id of an agent

Returns:

  • (Hash)

    Agent link information including token data



109
110
111
112
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 109

def link(agent_id)
  endpoint = "/v1/convai/agents/#{agent_id}/link"
  @client.get(endpoint)
end

#list(**options) ⇒ Hash

GET /v1/convai/agents Returns a list of your agents and their metadata Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/list

Parameters:

  • options (Hash)

    Query parameters

Options Hash (**options):

  • :page_size (Integer)

    How many agents to return at maximum (1-100, default: 30)

  • :search (String)

    Search by agents name

  • :sort_direction (String)

    The direction to sort the results ("asc" or "desc")

  • :sort_by (String)

    The field to sort the results by ("name" or "created_at")

  • :cursor (String)

    Used for fetching next page

Returns:

  • (Hash)

    List of agents with pagination info



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 49

def list(**options)
  endpoint = "/v1/convai/agents"
  query_params = options.compact
  
  if query_params.any?
    query_string = URI.encode_www_form(query_params)
    endpoint = "#{endpoint}?#{query_string}"
  end
  
  @client.get(endpoint)
end

#simulate_conversation(agent_id, **options) ⇒ Hash

POST /v1/convai/agents/agent_id/simulate-conversation Run a conversation between the agent and a simulated user Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/simulate-conversation

Parameters:

  • agent_id (String)

    The id of an agent

  • options (Hash)

    Simulation parameters

Options Hash (**options):

  • :simulation_specification (Hash)

    Required specification detailing how the conversation should be simulated

  • :extra_evaluation_criteria (Array<Hash>)

    Optional list of evaluation criteria to test

  • :new_turns_limit (Integer)

    Optional maximum number of new turns to generate (default: 10000)

Returns:

  • (Hash)

    Simulated conversation and analysis



124
125
126
127
128
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 124

def simulate_conversation(agent_id, **options)
  endpoint = "/v1/convai/agents/#{agent_id}/simulate-conversation"
  request_body = options
  @client.post(endpoint, request_body)
end

#simulate_conversation_stream(agent_id, **options, &block) ⇒ Enumerator

POST /v1/convai/agents/agent_id/simulate-conversation/stream Run a conversation between the agent and a simulated user and stream back the response Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/simulate-conversation-stream

Parameters:

  • agent_id (String)

    The id of an agent

  • options (Hash)

    Simulation parameters

  • block (Proc)

    Block to handle streaming response chunks

Options Hash (**options):

  • :simulation_specification (Hash)

    Required specification detailing how the conversation should be simulated

  • :extra_evaluation_criteria (Array<Hash>)

    Optional list of evaluation criteria to test

  • :new_turns_limit (Integer)

    Optional maximum number of new turns to generate (default: 10000)

Returns:

  • (Enumerator)

    Streaming response enumerator if no block given



141
142
143
144
145
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 141

def simulate_conversation_stream(agent_id, **options, &block)
  endpoint = "/v1/convai/agents/#{agent_id}/simulate-conversation/stream"
  request_body = options
  @client.post_streaming(endpoint, request_body, &block)
end

#update(agent_id, **options) ⇒ Hash

PATCH /v1/convai/agents/agent_id Patches an Agent settings Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/update

Parameters:

  • agent_id (String)

    The id of an agent

  • options (Hash)

    Agent update parameters

Options Hash (**options):

  • :conversation_config (Hash)

    Optional conversation configuration for an agent

  • :platform_settings (Hash)

    Optional platform settings for the agent

  • :name (String)

    Optional name to make the agent easier to find

  • :tags (Array<String>)

    Optional tags to help classify and filter the agent

Returns:

  • (Hash)

    Updated agent configuration and metadata



72
73
74
75
76
# File 'lib/elevenlabs_client/endpoints/agents_platform/agents.rb', line 72

def update(agent_id, **options)
  endpoint = "/v1/convai/agents/#{agent_id}"
  request_body = options.compact
  @client.patch(endpoint, request_body)
end