Class: ElevenlabsClient::Client
- Inherits:
-
Object
- Object
- ElevenlabsClient::Client
- Defined in:
- lib/elevenlabs_client/client.rb
Overview
Main client class for the ElevenLabs API Refactored for better maintainability and architecture
Instance Attribute Summary collapse
-
#agents ⇒ Object
readonly
Endpoint accessors.
-
#audio_isolation ⇒ Object
readonly
Endpoint accessors.
-
#audio_native ⇒ Object
readonly
Endpoint accessors.
-
#batch_calling ⇒ Object
readonly
Endpoint accessors.
-
#conversations ⇒ Object
readonly
Endpoint accessors.
-
#dubs ⇒ Object
readonly
Endpoint accessors.
-
#forced_alignment ⇒ Object
readonly
Endpoint accessors.
-
#history ⇒ Object
readonly
Endpoint accessors.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#knowledge_base ⇒ Object
readonly
Endpoint accessors.
-
#llm_usage ⇒ Object
readonly
Endpoint accessors.
-
#mcp_servers ⇒ Object
readonly
Endpoint accessors.
-
#models ⇒ Object
readonly
Endpoint accessors.
-
#music ⇒ Object
readonly
Endpoint accessors.
-
#outbound_calling ⇒ Object
readonly
Endpoint accessors.
-
#phone_numbers ⇒ Object
readonly
Endpoint accessors.
-
#pronunciation_dictionaries ⇒ Object
readonly
Endpoint accessors.
-
#samples ⇒ Object
readonly
Endpoint accessors.
-
#secrets ⇒ Object
readonly
Endpoint accessors.
-
#service_account_api_keys ⇒ Object
readonly
Endpoint accessors.
-
#service_accounts ⇒ Object
readonly
Endpoint accessors.
-
#sound_generation ⇒ Object
readonly
Endpoint accessors.
-
#speech_to_speech ⇒ Object
readonly
Endpoint accessors.
-
#speech_to_text ⇒ Object
readonly
Endpoint accessors.
-
#test_invocations ⇒ Object
readonly
Endpoint accessors.
-
#tests ⇒ Object
readonly
Endpoint accessors.
-
#text_to_dialogue ⇒ Object
readonly
Endpoint accessors.
-
#text_to_speech ⇒ Object
readonly
Endpoint accessors.
-
#text_to_voice ⇒ Object
readonly
Endpoint accessors.
-
#tools ⇒ Object
readonly
Endpoint accessors.
-
#usage ⇒ Object
readonly
Endpoint accessors.
-
#user ⇒ Object
readonly
Endpoint accessors.
-
#voice_library ⇒ Object
readonly
Endpoint accessors.
-
#voices ⇒ Object
readonly
Endpoint accessors.
-
#webhooks ⇒ Object
readonly
Endpoint accessors.
-
#websocket_text_to_speech ⇒ Object
readonly
Endpoint accessors.
-
#widgets ⇒ Object
readonly
Endpoint accessors.
-
#workspace ⇒ Object
readonly
Endpoint accessors.
-
#workspace_groups ⇒ Object
readonly
Endpoint accessors.
-
#workspace_invites ⇒ Object
readonly
Endpoint accessors.
-
#workspace_members ⇒ Object
readonly
Endpoint accessors.
-
#workspace_resources ⇒ Object
readonly
Endpoint accessors.
-
#workspace_webhooks ⇒ Object
readonly
Endpoint accessors.
Instance Method Summary collapse
- #api_key ⇒ Object
-
#base_url ⇒ Object
Convenience accessors for backward compatibility.
- #delete(path) ⇒ Object
- #delete_with_body(path, body = nil) ⇒ Object
- #file_part(file_io, filename) ⇒ Object
-
#get(path, params = {}) ⇒ Object
Delegate HTTP methods to http_client for backward compatibility.
- #get_binary(path) ⇒ Object
- #get_streaming(path, &block) ⇒ Object
-
#health_check ⇒ Object
Health check method.
-
#initialize(api_key: nil, base_url: nil, **options) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ Object
Debug information.
- #patch(path, body = nil) ⇒ Object
- #post(path, body = nil) ⇒ Object
- #post_binary(path, body = nil) ⇒ Object
- #post_multipart(path, payload) ⇒ Object
- #post_streaming(path, body = nil, &block) ⇒ Object
- #post_streaming_with_timestamps(path, body = nil, &block) ⇒ Object
- #post_with_custom_headers(path, body = nil, custom_headers = {}) ⇒ Object
Constructor Details
#initialize(api_key: nil, base_url: nil, **options) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elevenlabs_client/client.rb', line 9 def initialize(api_key: nil, base_url: nil, **) # Create configuration configuration = Configuration.new configuration.api_key = api_key if api_key configuration.base_url = base_url if base_url # Apply any additional options .each do |key, value| configuration.public_send("#{key}=", value) if configuration.respond_to?("#{key}=") end # Validate configuration configuration.validate! # Create HTTP client @http_client = HttpClient.new( api_key: configuration.resolved_api_key, base_url: configuration.resolved_base_url ) # Initialize endpoints directly for now (simpler approach) initialize_endpoints end |
Instance Attribute Details
#agents ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def agents @agents end |
#audio_isolation ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def audio_isolation @audio_isolation end |
#audio_native ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def audio_native @audio_native end |
#batch_calling ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def batch_calling @batch_calling end |
#conversations ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def conversations @conversations end |
#dubs ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def dubs @dubs end |
#forced_alignment ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def forced_alignment @forced_alignment end |
#history ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def history @history end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
7 8 9 |
# File 'lib/elevenlabs_client/client.rb', line 7 def http_client @http_client end |
#knowledge_base ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def knowledge_base @knowledge_base end |
#llm_usage ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def llm_usage @llm_usage end |
#mcp_servers ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def mcp_servers @mcp_servers end |
#models ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def models @models end |
#music ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def music @music end |
#outbound_calling ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def outbound_calling @outbound_calling end |
#phone_numbers ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def phone_numbers @phone_numbers end |
#pronunciation_dictionaries ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def pronunciation_dictionaries @pronunciation_dictionaries end |
#samples ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def samples @samples end |
#secrets ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def secrets @secrets end |
#service_account_api_keys ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def service_account_api_keys @service_account_api_keys end |
#service_accounts ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def service_accounts @service_accounts end |
#sound_generation ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def sound_generation @sound_generation end |
#speech_to_speech ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def speech_to_speech @speech_to_speech end |
#speech_to_text ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def speech_to_text @speech_to_text end |
#test_invocations ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def test_invocations @test_invocations end |
#tests ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def tests @tests end |
#text_to_dialogue ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def text_to_dialogue @text_to_dialogue end |
#text_to_speech ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def text_to_speech @text_to_speech end |
#text_to_voice ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def text_to_voice @text_to_voice end |
#tools ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def tools @tools end |
#usage ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def usage @usage end |
#user ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def user @user end |
#voice_library ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def voice_library @voice_library end |
#voices ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def voices @voices end |
#webhooks ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def webhooks @webhooks end |
#websocket_text_to_speech ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def websocket_text_to_speech @websocket_text_to_speech end |
#widgets ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def @widgets end |
#workspace ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def workspace @workspace end |
#workspace_groups ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def workspace_groups @workspace_groups end |
#workspace_invites ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def workspace_invites @workspace_invites end |
#workspace_members ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def workspace_members @workspace_members end |
#workspace_resources ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def workspace_resources @workspace_resources end |
#workspace_webhooks ⇒ Object (readonly)
Endpoint accessors
88 89 90 |
# File 'lib/elevenlabs_client/client.rb', line 88 def workspace_webhooks @workspace_webhooks end |
Instance Method Details
#api_key ⇒ Object
157 158 159 |
# File 'lib/elevenlabs_client/client.rb', line 157 def api_key http_client.api_key end |
#base_url ⇒ Object
Convenience accessors for backward compatibility
153 154 155 |
# File 'lib/elevenlabs_client/client.rb', line 153 def base_url http_client.base_url end |
#delete(path) ⇒ Object
112 113 114 |
# File 'lib/elevenlabs_client/client.rb', line 112 def delete(path) http_client.delete(path) end |
#delete_with_body(path, body = nil) ⇒ Object
116 117 118 |
# File 'lib/elevenlabs_client/client.rb', line 116 def delete_with_body(path, body = nil) http_client.delete_with_body(path, body) end |
#file_part(file_io, filename) ⇒ Object
148 149 150 |
# File 'lib/elevenlabs_client/client.rb', line 148 def file_part(file_io, filename) http_client.file_part(file_io, filename) end |
#get(path, params = {}) ⇒ Object
Delegate HTTP methods to http_client for backward compatibility
100 101 102 |
# File 'lib/elevenlabs_client/client.rb', line 100 def get(path, params = {}) http_client.get(path, params) end |
#get_binary(path) ⇒ Object
124 125 126 |
# File 'lib/elevenlabs_client/client.rb', line 124 def get_binary(path) http_client.get_binary(path) end |
#get_streaming(path, &block) ⇒ Object
140 141 142 |
# File 'lib/elevenlabs_client/client.rb', line 140 def get_streaming(path, &block) http_client.get_streaming(path, &block) end |
#health_check ⇒ Object
Health check method
168 169 170 171 172 173 174 175 176 |
# File 'lib/elevenlabs_client/client.rb', line 168 def health_check begin # Try a simple API call to verify connectivity get("/v1/models") { status: :ok, message: "Client is healthy" } rescue => e { status: :error, message: e., error_class: e.class.name } end end |
#inspect ⇒ Object
Debug information
162 163 164 165 |
# File 'lib/elevenlabs_client/client.rb', line 162 def inspect "#<#{self.class.name}:0x#{object_id.to_s(16)} " \ "base_url=#{base_url.inspect}>" end |
#patch(path, body = nil) ⇒ Object
108 109 110 |
# File 'lib/elevenlabs_client/client.rb', line 108 def patch(path, body = nil) http_client.patch(path, body) end |
#post(path, body = nil) ⇒ Object
104 105 106 |
# File 'lib/elevenlabs_client/client.rb', line 104 def post(path, body = nil) http_client.post(path, body) end |
#post_binary(path, body = nil) ⇒ Object
128 129 130 |
# File 'lib/elevenlabs_client/client.rb', line 128 def post_binary(path, body = nil) http_client.post_binary(path, body) end |
#post_multipart(path, payload) ⇒ Object
120 121 122 |
# File 'lib/elevenlabs_client/client.rb', line 120 def post_multipart(path, payload) http_client.post_multipart(path, payload) end |
#post_streaming(path, body = nil, &block) ⇒ Object
136 137 138 |
# File 'lib/elevenlabs_client/client.rb', line 136 def post_streaming(path, body = nil, &block) http_client.post_streaming(path, body, &block) end |
#post_streaming_with_timestamps(path, body = nil, &block) ⇒ Object
144 145 146 |
# File 'lib/elevenlabs_client/client.rb', line 144 def (path, body = nil, &block) http_client.(path, body, &block) end |
#post_with_custom_headers(path, body = nil, custom_headers = {}) ⇒ Object
132 133 134 |
# File 'lib/elevenlabs_client/client.rb', line 132 def post_with_custom_headers(path, body = nil, custom_headers = {}) http_client.post_with_custom_headers(path, body, custom_headers) end |