elevenlabs_client 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +220 -0
  3. data/README.md +181 -58
  4. data/lib/elevenlabs_client/client.rb +110 -269
  5. data/lib/elevenlabs_client/configuration.rb +119 -0
  6. data/lib/elevenlabs_client/endpoints/admin/history.rb +1 -1
  7. data/lib/elevenlabs_client/endpoints/admin/pronunciation_dictionaries.rb +103 -0
  8. data/lib/elevenlabs_client/endpoints/admin/samples.rb +30 -0
  9. data/lib/elevenlabs_client/endpoints/admin/service_account_api_keys.rb +77 -0
  10. data/lib/elevenlabs_client/endpoints/admin/service_accounts.rb +29 -0
  11. data/lib/elevenlabs_client/endpoints/admin/user.rb +12 -0
  12. data/lib/elevenlabs_client/endpoints/admin/webhooks.rb +33 -0
  13. data/lib/elevenlabs_client/endpoints/admin/workspace_groups.rb +56 -0
  14. data/lib/elevenlabs_client/endpoints/admin/workspace_invites.rb +52 -0
  15. data/lib/elevenlabs_client/endpoints/admin/workspace_members.rb +31 -0
  16. data/lib/elevenlabs_client/endpoints/admin/workspace_resources.rb +53 -0
  17. data/lib/elevenlabs_client/endpoints/admin/workspace_webhooks.rb +30 -0
  18. data/lib/elevenlabs_client/endpoints/agents_platform/agents.rb +165 -0
  19. data/lib/elevenlabs_client/endpoints/agents_platform/batch_calling.rb +89 -0
  20. data/lib/elevenlabs_client/endpoints/agents_platform/conversations.rb +121 -0
  21. data/lib/elevenlabs_client/endpoints/agents_platform/knowledge_base.rb +234 -0
  22. data/lib/elevenlabs_client/endpoints/agents_platform/llm_usage.rb +50 -0
  23. data/lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb +139 -0
  24. data/lib/elevenlabs_client/endpoints/agents_platform/outbound_calling.rb +55 -0
  25. data/lib/elevenlabs_client/endpoints/agents_platform/phone_numbers.rb +86 -0
  26. data/lib/elevenlabs_client/endpoints/agents_platform/test_invocations.rb +44 -0
  27. data/lib/elevenlabs_client/endpoints/agents_platform/tests.rb +138 -0
  28. data/lib/elevenlabs_client/endpoints/agents_platform/tools.rb +107 -0
  29. data/lib/elevenlabs_client/endpoints/agents_platform/widgets.rb +52 -0
  30. data/lib/elevenlabs_client/endpoints/agents_platform/workspace.rb +130 -0
  31. data/lib/elevenlabs_client/errors.rb +4 -0
  32. data/lib/elevenlabs_client/http_client.rb +325 -0
  33. data/lib/elevenlabs_client/version.rb +1 -1
  34. data/lib/elevenlabs_client.rb +99 -15
  35. metadata +27 -2
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class Samples
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # DELETE /v1/voices/:voice_id/samples/:sample_id
11
+ # Delete voice sample
12
+ # Documentation: https://elevenlabs.io/docs/api-reference/samples/delete-voice-sample
13
+ #
14
+ # @param voice_id [String] ID of the voice to be used. You can use the Get voices endpoint to list all the available voices.
15
+ # @param sample_id [String] ID of the sample to be used. You can use the Get voices endpoint to list all the available samples for a voice.
16
+ # @return [Hash] The JSON response containing the status of the deletion request.
17
+ def delete_sample(voice_id:, sample_id:)
18
+ endpoint = "/v1/voices/#{voice_id}/samples/#{sample_id}"
19
+ @client.delete(endpoint)
20
+ end
21
+
22
+ alias_method :delete_voice_sample, :delete_sample
23
+ alias_method :remove_sample, :delete_sample
24
+
25
+ private
26
+
27
+ attr_reader :client
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class ServiceAccountApiKeys
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # GET /v1/service-accounts/{service_account_user_id}/api-keys
11
+ # Get all API keys for a service account
12
+ # Documentation: https://elevenlabs.io/docs/api-reference/service-accounts/api-keys/list
13
+ #
14
+ # @param service_account_user_id [String] The service account user ID
15
+ # @return [Hash] JSON response containing list of API keys
16
+ def list(service_account_user_id)
17
+ endpoint = "/v1/service-accounts/#{service_account_user_id}/api-keys"
18
+ @client.get(endpoint)
19
+ end
20
+
21
+ # POST /v1/service-accounts/{service_account_user_id}/api-keys
22
+ # Create a new API key for a service account
23
+ # Documentation: https://elevenlabs.io/docs/api-reference/service-accounts/api-keys/create
24
+ #
25
+ # @param service_account_user_id [String] The service account user ID
26
+ # @param name [String] The name of the API key
27
+ # @param permissions [Array<String>, String] The permissions for the API key or "all"
28
+ # @param options [Hash] Optional parameters
29
+ # @option options [Integer, nil] :character_limit Monthly character limit for the API key
30
+ # @return [Hash] JSON response containing the new API key
31
+ def create(service_account_user_id, name:, permissions:, **options)
32
+ endpoint = "/v1/service-accounts/#{service_account_user_id}/api-keys"
33
+ request_body = {
34
+ name: name,
35
+ permissions: permissions
36
+ }.merge(options)
37
+
38
+ @client.post(endpoint, request_body)
39
+ end
40
+
41
+ # PATCH /v1/service-accounts/{service_account_user_id}/api-keys/{api_key_id}
42
+ # Update an existing API key for a service account
43
+ # Documentation: https://elevenlabs.io/docs/api-reference/service-accounts/api-keys/update
44
+ #
45
+ # @param service_account_user_id [String] The service account user ID
46
+ # @param api_key_id [String] The API key ID
47
+ # @param is_enabled [Boolean] Whether to enable or disable the API key
48
+ # @param name [String] The name of the API key
49
+ # @param permissions [Array<String>, String] The permissions for the API key or "all"
50
+ # @param options [Hash] Optional parameters
51
+ # @option options [Integer, nil] :character_limit Monthly character limit for the API key
52
+ # @return [Hash] JSON response with update confirmation
53
+ def update(service_account_user_id, api_key_id, is_enabled:, name:, permissions:, **options)
54
+ endpoint = "/v1/service-accounts/#{service_account_user_id}/api-keys/#{api_key_id}"
55
+ request_body = {
56
+ is_enabled: is_enabled,
57
+ name: name,
58
+ permissions: permissions
59
+ }.merge(options)
60
+
61
+ @client.patch(endpoint, request_body)
62
+ end
63
+
64
+ # DELETE /v1/service-accounts/{service_account_user_id}/api-keys/{api_key_id}
65
+ # Delete an existing API key for a service account
66
+ # Documentation: https://elevenlabs.io/docs/api-reference/service-accounts/api-keys/delete
67
+ #
68
+ # @param service_account_user_id [String] The service account user ID
69
+ # @param api_key_id [String] The API key ID
70
+ # @return [Hash] JSON response with deletion confirmation
71
+ def delete(service_account_user_id, api_key_id)
72
+ endpoint = "/v1/service-accounts/#{service_account_user_id}/api-keys/#{api_key_id}"
73
+ @client.delete(endpoint)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class ServiceAccounts
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # GET /v1/service-accounts
11
+ # Get service accounts
12
+ # Documentation: https://elevenlabs.io/docs/api-reference/service-accounts/get-service-accounts
13
+ #
14
+ # @return [Hash] The JSON response containing all service accounts in the workspace.
15
+ def get_service_accounts
16
+ endpoint = "/v1/service-accounts"
17
+ @client.get(endpoint)
18
+ end
19
+
20
+ alias_method :list, :get_service_accounts
21
+ alias_method :all, :get_service_accounts
22
+ alias_method :service_accounts, :get_service_accounts
23
+
24
+ private
25
+
26
+ attr_reader :client
27
+ end
28
+ end
29
+ end
@@ -20,6 +20,18 @@ module ElevenlabsClient
20
20
  alias_method :user, :get_user
21
21
  alias_method :info, :get_user
22
22
 
23
+ # GET /v1/user/subscription
24
+ # Gets extended information about the user's subscription
25
+ # Documentation: https://elevenlabs.io/docs/api-reference/user/get-user-subscription
26
+ #
27
+ # @return [Hash] The JSON response containing subscription info
28
+ def get_subscription
29
+ endpoint = "/v1/user/subscription"
30
+ @client.get(endpoint)
31
+ end
32
+
33
+ alias_method :subscription, :get_subscription
34
+
23
35
  private
24
36
 
25
37
  attr_reader :client
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class Webhooks
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # GET /v1/workspace/webhooks
11
+ # List workspace webhooks
12
+ # Documentation: https://elevenlabs.io/docs/api-reference/workspace/list-workspace-webhooks
13
+ #
14
+ # @param include_usages [Boolean] Whether to include active usages of the webhook, only usable by admins. Defaults to false.
15
+ # @return [Hash] The JSON response containing all webhooks for the workspace.
16
+ def list_webhooks(include_usages: nil)
17
+ endpoint = "/v1/workspace/webhooks"
18
+ params = {
19
+ include_usages: include_usages
20
+ }.compact
21
+ @client.get(endpoint, params)
22
+ end
23
+
24
+ alias_method :get_webhooks, :list_webhooks
25
+ alias_method :all, :list_webhooks
26
+ alias_method :webhooks, :list_webhooks
27
+
28
+ private
29
+
30
+ attr_reader :client
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class WorkspaceGroups
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # GET /v1/workspace/groups/search
11
+ # Searches for user groups in the workspace by name
12
+ # @param name [String] Group name to search
13
+ # @return [Array<Hash>] List of matching groups
14
+ def search(name:)
15
+ raise ArgumentError, "name is required" if name.nil? || name.to_s.strip.empty?
16
+
17
+ @client.get("/v1/workspace/groups/search", { name: name })
18
+ end
19
+
20
+ # POST /v1/workspace/groups/:group_id/members
21
+ # Adds a member to the specified group
22
+ # @param group_id [String] The group ID
23
+ # @param email [String] The member email to add
24
+ # @return [Hash] { "status" => "ok" }
25
+ def add_member(group_id:, email:)
26
+ validate_group_and_email!(group_id, email)
27
+
28
+ endpoint = "/v1/workspace/groups/#{group_id}/members"
29
+ @client.post(endpoint, { email: email })
30
+ end
31
+
32
+ # POST /v1/workspace/groups/:group_id/members/remove
33
+ # Removes a member from the specified group
34
+ # @param group_id [String] The group ID
35
+ # @param email [String] The member email to remove
36
+ # @return [Hash] { "status" => "ok" }
37
+ def remove_member(group_id:, email:)
38
+ validate_group_and_email!(group_id, email)
39
+
40
+ endpoint = "/v1/workspace/groups/#{group_id}/members/remove"
41
+ @client.post(endpoint, { email: email })
42
+ end
43
+
44
+ private
45
+
46
+ attr_reader :client
47
+
48
+ def validate_group_and_email!(group_id, email)
49
+ raise ArgumentError, "group_id is required" if group_id.nil? || group_id.to_s.strip.empty?
50
+ raise ArgumentError, "email is required" if email.nil? || email.to_s.strip.empty?
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class WorkspaceInvites
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # POST /v1/workspace/invites/add
11
+ # Invite a single user
12
+ # @param email [String]
13
+ # @param group_ids [Array<String>, nil]
14
+ # @param workspace_permission [String, nil]
15
+ def invite(email:, group_ids: nil, workspace_permission: nil)
16
+ validate_email!(email)
17
+ body = { email: email }
18
+ body[:group_ids] = group_ids if group_ids
19
+ body[:workspace_permission] = workspace_permission if workspace_permission
20
+ @client.post("/v1/workspace/invites/add", body)
21
+ end
22
+
23
+ # POST /v1/workspace/invites/add-bulk
24
+ # Invite multiple users
25
+ # @param emails [Array<String>]
26
+ # @param group_ids [Array<String>, nil]
27
+ def invite_bulk(emails:, group_ids: nil)
28
+ raise ArgumentError, "emails must be a non-empty Array" unless emails.is_a?(Array) && !emails.empty?
29
+ body = { emails: emails }
30
+ body[:group_ids] = group_ids if group_ids
31
+ @client.post("/v1/workspace/invites/add-bulk", body)
32
+ end
33
+
34
+ # DELETE /v1/workspace/invites (with body)
35
+ # Delete an invitation by email
36
+ def delete_invite(email:)
37
+ validate_email!(email)
38
+ @client.delete_with_body("/v1/workspace/invites", { email: email })
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :client
44
+
45
+ def validate_email!(email)
46
+ raise ArgumentError, "email is required" if email.nil? || email.to_s.strip.empty?
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class WorkspaceMembers
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # POST /v1/workspace/members
11
+ # Updates attributes of a workspace member
12
+ # Required: email
13
+ # Optional: is_locked, workspace_role
14
+ def update_member(email:, is_locked: nil, workspace_role: nil)
15
+ raise ArgumentError, "email is required" if email.nil? || email.to_s.strip.empty?
16
+ body = { email: email }
17
+ body[:is_locked] = is_locked unless is_locked.nil?
18
+ body[:workspace_role] = workspace_role if workspace_role
19
+ @client.post("/v1/workspace/members", body)
20
+ end
21
+
22
+ alias_method :update, :update_member
23
+
24
+ private
25
+
26
+ attr_reader :client
27
+ end
28
+ end
29
+ end
30
+
31
+
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class WorkspaceResources
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # GET /v1/workspace/resources/:resource_id
11
+ # params: resource_type (required)
12
+ def get_resource(resource_id:, resource_type:)
13
+ raise ArgumentError, "resource_id is required" if resource_id.nil? || resource_id.to_s.strip.empty?
14
+ raise ArgumentError, "resource_type is required" if resource_type.nil? || resource_type.to_s.strip.empty?
15
+ @client.get("/v1/workspace/resources/#{resource_id}", { resource_type: resource_type })
16
+ end
17
+
18
+ # POST /v1/workspace/resources/:resource_id/share
19
+ # body: role (required), resource_type (required), optional: user_email, group_id, workspace_api_key_id
20
+ def share(resource_id:, role:, resource_type:, user_email: nil, group_id: nil, workspace_api_key_id: nil)
21
+ validate_resource!(resource_id, resource_type)
22
+ raise ArgumentError, "role is required" if role.nil? || role.to_s.strip.empty?
23
+ body = { role: role, resource_type: resource_type }
24
+ body[:user_email] = user_email if user_email
25
+ body[:group_id] = group_id if group_id
26
+ body[:workspace_api_key_id] = workspace_api_key_id if workspace_api_key_id
27
+ @client.post("/v1/workspace/resources/#{resource_id}/share", body)
28
+ end
29
+
30
+ # POST /v1/workspace/resources/:resource_id/unshare
31
+ # body: resource_type (required), optional: user_email, group_id, workspace_api_key_id
32
+ def unshare(resource_id:, resource_type:, user_email: nil, group_id: nil, workspace_api_key_id: nil)
33
+ validate_resource!(resource_id, resource_type)
34
+ body = { resource_type: resource_type }
35
+ body[:user_email] = user_email if user_email
36
+ body[:group_id] = group_id if group_id
37
+ body[:workspace_api_key_id] = workspace_api_key_id if workspace_api_key_id
38
+ @client.post("/v1/workspace/resources/#{resource_id}/unshare", body)
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :client
44
+
45
+ def validate_resource!(resource_id, resource_type)
46
+ raise ArgumentError, "resource_id is required" if resource_id.nil? || resource_id.to_s.strip.empty?
47
+ raise ArgumentError, "resource_type is required" if resource_type.nil? || resource_type.to_s.strip.empty?
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Admin
5
+ class WorkspaceWebhooks
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # GET /v1/workspace/webhooks
11
+ # List all webhooks for a workspace
12
+ # Documentation: https://elevenlabs.io/docs/api-reference/workspace/webhooks/list
13
+ #
14
+ # @param options [Hash] Optional parameters
15
+ # @option options [Boolean] :include_usages Whether to include active usages of the webhook (admin only)
16
+ # @return [Hash] JSON response containing list of webhooks
17
+ def list(**options)
18
+ endpoint = "/v1/workspace/webhooks"
19
+ query_params = options.compact
20
+
21
+ if query_params.any?
22
+ query_string = URI.encode_www_form(query_params)
23
+ endpoint = "#{endpoint}?#{query_string}"
24
+ end
25
+
26
+ @client.get(endpoint)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,165 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Endpoints
5
+ module AgentsPlatform
6
+ class Agents
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # POST /v1/convai/agents/create
12
+ # Create an agent from a config object
13
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/create
14
+ #
15
+ # @param options [Hash] Agent creation parameters
16
+ # @option options [Hash] :conversation_config Required conversation configuration for an agent
17
+ # @option options [Hash] :platform_settings Optional platform settings for the agent
18
+ # @option options [String] :name Optional name to make the agent easier to find
19
+ # @option options [Array<String>] :tags Optional tags to help classify and filter the agent
20
+ # @return [Hash] JSON response containing agent_id
21
+ def create(**options)
22
+ endpoint = "/v1/convai/agents/create"
23
+ request_body = options
24
+ @client.post(endpoint, request_body)
25
+ end
26
+
27
+ # GET /v1/convai/agents/{agent_id}
28
+ # Retrieve config for an agent
29
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/get
30
+ #
31
+ # @param agent_id [String] The id of an agent
32
+ # @return [Hash] Agent configuration and metadata
33
+ def get(agent_id)
34
+ endpoint = "/v1/convai/agents/#{agent_id}"
35
+ @client.get(endpoint)
36
+ end
37
+
38
+ # GET /v1/convai/agents
39
+ # Returns a list of your agents and their metadata
40
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/list
41
+ #
42
+ # @param options [Hash] Query parameters
43
+ # @option options [Integer] :page_size How many agents to return at maximum (1-100, default: 30)
44
+ # @option options [String] :search Search by agents name
45
+ # @option options [String] :sort_direction The direction to sort the results ("asc" or "desc")
46
+ # @option options [String] :sort_by The field to sort the results by ("name" or "created_at")
47
+ # @option options [String] :cursor Used for fetching next page
48
+ # @return [Hash] List of agents with pagination info
49
+ def list(**options)
50
+ endpoint = "/v1/convai/agents"
51
+ query_params = options.compact
52
+
53
+ if query_params.any?
54
+ query_string = URI.encode_www_form(query_params)
55
+ endpoint = "#{endpoint}?#{query_string}"
56
+ end
57
+
58
+ @client.get(endpoint)
59
+ end
60
+
61
+ # PATCH /v1/convai/agents/{agent_id}
62
+ # Patches an Agent settings
63
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/update
64
+ #
65
+ # @param agent_id [String] The id of an agent
66
+ # @param options [Hash] Agent update parameters
67
+ # @option options [Hash] :conversation_config Optional conversation configuration for an agent
68
+ # @option options [Hash] :platform_settings Optional platform settings for the agent
69
+ # @option options [String] :name Optional name to make the agent easier to find
70
+ # @option options [Array<String>] :tags Optional tags to help classify and filter the agent
71
+ # @return [Hash] Updated agent configuration and metadata
72
+ def update(agent_id, **options)
73
+ endpoint = "/v1/convai/agents/#{agent_id}"
74
+ request_body = options.compact
75
+ @client.patch(endpoint, request_body)
76
+ end
77
+
78
+ # DELETE /v1/convai/agents/{agent_id}
79
+ # Delete an agent
80
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/delete
81
+ #
82
+ # @param agent_id [String] The id of an agent
83
+ # @return [Hash] Empty response on success
84
+ def delete(agent_id)
85
+ endpoint = "/v1/convai/agents/#{agent_id}"
86
+ @client.delete(endpoint)
87
+ end
88
+
89
+ # POST /v1/convai/agents/{agent_id}/duplicate
90
+ # Create a new agent by duplicating an existing one
91
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/duplicate
92
+ #
93
+ # @param agent_id [String] The id of an agent to duplicate
94
+ # @param options [Hash] Duplication parameters
95
+ # @option options [String] :name Optional name to make the agent easier to find
96
+ # @return [Hash] JSON response containing new agent_id
97
+ def duplicate(agent_id, **options)
98
+ endpoint = "/v1/convai/agents/#{agent_id}/duplicate"
99
+ request_body = options.compact
100
+ @client.post(endpoint, request_body)
101
+ end
102
+
103
+ # GET /v1/convai/agents/{agent_id}/link
104
+ # Get the current link used to share the agent with others
105
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/link
106
+ #
107
+ # @param agent_id [String] The id of an agent
108
+ # @return [Hash] Agent link information including token data
109
+ def link(agent_id)
110
+ endpoint = "/v1/convai/agents/#{agent_id}/link"
111
+ @client.get(endpoint)
112
+ end
113
+
114
+ # POST /v1/convai/agents/{agent_id}/simulate-conversation
115
+ # Run a conversation between the agent and a simulated user
116
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/simulate-conversation
117
+ #
118
+ # @param agent_id [String] The id of an agent
119
+ # @param options [Hash] Simulation parameters
120
+ # @option options [Hash] :simulation_specification Required specification detailing how the conversation should be simulated
121
+ # @option options [Array<Hash>] :extra_evaluation_criteria Optional list of evaluation criteria to test
122
+ # @option options [Integer] :new_turns_limit Optional maximum number of new turns to generate (default: 10000)
123
+ # @return [Hash] Simulated conversation and analysis
124
+ def simulate_conversation(agent_id, **options)
125
+ endpoint = "/v1/convai/agents/#{agent_id}/simulate-conversation"
126
+ request_body = options
127
+ @client.post(endpoint, request_body)
128
+ end
129
+
130
+ # POST /v1/convai/agents/{agent_id}/simulate-conversation/stream
131
+ # Run a conversation between the agent and a simulated user and stream back the response
132
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/simulate-conversation-stream
133
+ #
134
+ # @param agent_id [String] The id of an agent
135
+ # @param options [Hash] Simulation parameters
136
+ # @option options [Hash] :simulation_specification Required specification detailing how the conversation should be simulated
137
+ # @option options [Array<Hash>] :extra_evaluation_criteria Optional list of evaluation criteria to test
138
+ # @option options [Integer] :new_turns_limit Optional maximum number of new turns to generate (default: 10000)
139
+ # @param block [Proc] Block to handle streaming response chunks
140
+ # @return [Enumerator] Streaming response enumerator if no block given
141
+ def simulate_conversation_stream(agent_id, **options, &block)
142
+ endpoint = "/v1/convai/agents/#{agent_id}/simulate-conversation/stream"
143
+ request_body = options
144
+ @client.post_streaming(endpoint, request_body, &block)
145
+ end
146
+
147
+ # POST /v1/convai/agent/{agent_id}/llm-usage/calculate
148
+ # Calculates expected number of LLM tokens needed for the specified agent
149
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/agents/calculate-llm-usage
150
+ #
151
+ # @param agent_id [String] The id of an agent
152
+ # @param options [Hash] Calculation parameters
153
+ # @option options [Integer] :prompt_length Optional length of the prompt in characters
154
+ # @option options [Integer] :number_of_pages Optional pages of content in pdf documents OR urls in agent's Knowledge Base
155
+ # @option options [Boolean] :rag_enabled Optional whether RAG is enabled
156
+ # @return [Hash] LLM usage pricing information
157
+ def calculate_llm_usage(agent_id, **options)
158
+ endpoint = "/v1/convai/agent/#{agent_id}/llm-usage/calculate"
159
+ request_body = options.compact
160
+ @client.post(endpoint, request_body)
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElevenlabsClient
4
+ module Endpoints
5
+ module AgentsPlatform
6
+ class BatchCalling
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # POST /v1/convai/batch-calling/submit
12
+ # Submit a batch call request to schedule calls for multiple recipients
13
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/batch-calling/submit
14
+ #
15
+ # @param call_name [String] Name for the batch call job
16
+ # @param agent_id [String] The agent ID to use for all calls
17
+ # @param agent_phone_number_id [String] The phone number ID to call from
18
+ # @param scheduled_time_unix [Integer] Unix timestamp for when to schedule the calls
19
+ # @param recipients [Array<Hash>] Array of recipient objects with phone numbers
20
+ # @return [Hash] JSON response containing batch call job details
21
+ def submit(call_name:, agent_id:, agent_phone_number_id:, scheduled_time_unix:, recipients:)
22
+ endpoint = "/v1/convai/batch-calling/submit"
23
+ request_body = {
24
+ call_name: call_name,
25
+ agent_id: agent_id,
26
+ agent_phone_number_id: agent_phone_number_id,
27
+ scheduled_time_unix: scheduled_time_unix,
28
+ recipients: recipients
29
+ }
30
+
31
+ @client.post(endpoint, request_body)
32
+ end
33
+
34
+ # GET /v1/convai/batch-calling/workspace
35
+ # Get all batch calls for the current workspace
36
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/batch-calling/list
37
+ #
38
+ # @param options [Hash] Optional parameters
39
+ # @option options [Integer] :limit Maximum number of results to return (default: 100)
40
+ # @option options [String] :last_doc Last document ID for pagination
41
+ # @return [Hash] JSON response containing batch calls list with pagination info
42
+ def list(**options)
43
+ endpoint = "/v1/convai/batch-calling/workspace"
44
+ query_params = options.compact
45
+
46
+ if query_params.any?
47
+ query_string = URI.encode_www_form(query_params)
48
+ endpoint = "#{endpoint}?#{query_string}"
49
+ end
50
+
51
+ @client.get(endpoint)
52
+ end
53
+
54
+ # GET /v1/convai/batch-calling/{batch_id}
55
+ # Get detailed information about a batch call including all recipients
56
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/batch-calling/get
57
+ #
58
+ # @param batch_id [String] The ID of the batch call job
59
+ # @return [Hash] JSON response containing detailed batch call information including recipients
60
+ def get(batch_id)
61
+ endpoint = "/v1/convai/batch-calling/#{batch_id}"
62
+ @client.get(endpoint)
63
+ end
64
+
65
+ # POST /v1/convai/batch-calling/{batch_id}/cancel
66
+ # Cancel a running batch call and set all recipients to cancelled status
67
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/batch-calling/cancel
68
+ #
69
+ # @param batch_id [String] The ID of the batch call job to cancel
70
+ # @return [Hash] JSON response containing updated batch call information
71
+ def cancel(batch_id)
72
+ endpoint = "/v1/convai/batch-calling/#{batch_id}/cancel"
73
+ @client.post(endpoint, {})
74
+ end
75
+
76
+ # POST /v1/convai/batch-calling/{batch_id}/retry
77
+ # Retry a batch call, calling failed and no-response recipients again
78
+ # Documentation: https://elevenlabs.io/docs/api-reference/convai/batch-calling/retry
79
+ #
80
+ # @param batch_id [String] The ID of the batch call job to retry
81
+ # @return [Hash] JSON response containing updated batch call information
82
+ def retry(batch_id)
83
+ endpoint = "/v1/convai/batch-calling/#{batch_id}/retry"
84
+ @client.post(endpoint, {})
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end