-
Notifications
You must be signed in to change notification settings - Fork 360
v2 upgrade guide
v2 of the ElevenLabs introduces a variety of new features and breaking changes to the SDK.
The largest change is the renaming of many methods to simplify the API surface. Here's the complete list of method name changes:
Old Method (snake_case) | New Method (snake_case) |
---|---|
client.conversational_ai.create_agent | client.conversational_ai.agents.create |
client.conversational_ai.get_agent | client.conversational_ai.agents.get |
client.conversational_ai.update_agent | client.conversational_ai.agents.update |
client.conversational_ai.delete_agent | client.conversational_ai.agents.delete |
client.conversational_ai.get_agent_widget | client.conversational_ai.agents.widget.get |
client.conversational_ai.post_agent_avatar | client.conversational_ai.agents.widget.avatar.create |
client.conversational_ai.get_agent_link | client.conversational_ai.agents.link.get |
client.conversational_ai.post_agent_link | client.conversational_ai.agents.link.create |
client.conversational_ai.get_agents | client.conversational_ai.agents.list |
client.conversational_ai.count_agents | client.conversational_ai.agents.count |
client.conversational_ai.get_batch_call | client.conversational_ai.batch_calls.get |
client.conversational_ai.get_signed_url | client.conversational_ai.conversations.get_signed_url |
client.conversational_ai.twilio_outbound_call | client.conversational_ai.twilio.outbound_call |
client.conversational_ai.get_conversations | client.conversational_ai.conversations.list |
client.conversational_ai.get_conversation | client.conversational_ai.conversations.get |
client.conversational_ai.delete_conversation | client.conversational_ai.conversations.delete |
client.conversational_ai.get_conversation_audio | client.conversational_ai.conversations.audio.get |
client.conversational_ai.post_conversation_feedback | client.conversational_ai.conversations.feedback.create |
client.conversational_ai.create_knowledge_base_url_document | client.conversational_ai.knowledge_base.documents.create_from_url |
client.conversational_ai.create_knowledge_base_file_document | client.conversational_ai.knowledge_base.documents.create_from_file |
client.conversational_ai.create_knowledge_base_text_document | client.conversational_ai.knowledge_base.documents.create_from_text |
client.conversational_ai.get_knowledge_base_document_by_id | client.conversational_ai.knowledge_base.documents.get |
client.conversational_ai.get_knowledge_base_document_content | client.conversational_ai.knowledge_base.documents.get_content |
client.conversational_ai.delete_knowledge_base_document | client.conversational_ai.knowledge_base.documents.delete |
client.conversational_ai.get_knowledge_base_list | client.conversational_ai.knowledge_base.list |
client.conversational_ai.get_knowledge_base_document_part_by_id | client.conversational_ai.knowledge_base.documents.chunk.get |
client.conversational_ai.get_phone_number | client.conversational_ai.phone_numbers.get |
client.conversational_ai.get_phone_numbers | client.conversational_ai.phone_numbers.list |
client.conversational_ai.delete_phone_number | client.conversational_ai.phone_numbers.delete |
client.conversational_ai.update_phone_number | client.conversational_ai.phone_numbers.update |
client.conversational_ai.get_secrets | client.conversational_ai.secrets.list |
client.conversational_ai.create_secret | client.conversational_ai.secrets.create |
client.conversational_ai.delete_secret | client.conversational_ai.secrets.delete |
client.conversational_ai.get_settings | client.conversational_ai.settings.get |
client.conversational_ai.update_settings | client.conversational_ai.settings.update |
client.conversational_ai.get_dashboard_settings | client.conversational_ai.dashboard.settings.get |
client.conversational_ai.update_dashboard_settings | client.conversational_ai.dashboard.settings.update |
client.audio_isolation.audio_isolation | client.audio_isolation.convert |
client.audio_isolation.audio_isolation_stream | client.audio_isolation.stream |
client.audio_native.update_content | client.audio_native.update |
client.dubbing.dub_a_video_or_an_audio_file | client.dubbing.create |
client.dubbing.get_dubbing_project_metadata | client.dubbing.get |
client.dubbing.get_dubbed_file | client.dubbing.audio.get |
client.dubbing.get_transcript_for_dub | client.dubbing.transcript.get |
client.dubbing.delete_dubbing_project | client.dubbing.delete |
client.dubbing.get_dubbing_resource | client.dubbing.resource.get |
client.dubbing.add_language_to_resource | client.dubbing.resource.language.add |
client.dubbing.speaker.segment.create | client.dubbing.resource.speaker.segment.create |
client.dubbing.update_segment_language | client.dubbing.resource.segment.update |
client.dubbing.delete_segment | client.dubbing.resource.segment.delete |
client.dubbing.transcribe_segments | client.dubbing.resource.transcribe |
client.dubbing.translate_segments | client.dubbing.resource.translate |
client.dubbing.dub_segments | client.dubbing.resource.dub |
client.dubbing.speaker.update | client.dubbing.resource.speaker.update |
client.dubbing.speaker.similar_voices | client.dubbing.resource.speaker.find_similar_voices |
client.voices.get_similar_library_voices | client.voices.find_similar_voices |
client.speech_to_speech.convert_as_stream | client.speech_to_speech.stream |
client.text_to_speech.convert_as_stream | client.text_to_speech.stream |
client.voices.get_default_settings | client.voices.settings.get_default |
client.voices.edit_settings | client.voices.settings.update |
client.voices.add | client.voices.ivc.create |
client.voices.edit | client.voices.update |
client.models.get_all | client.models.list |
client.studio.projects.get_all | client.studio.projects.list |
client.studio.projects.add | client.studio.projects.create |
client.studio.projects.update_metadata | client.studio.projects.update |
client.studio.projects.update_content | client.studio.projects.content.update |
client.studio.projects.get_project_snapshot | client.studio.projects.snapshots.get |
client.studio.projects.stream_audio | client.studio.projects.snapshots.stream |
client.studio.projects.chapters.get_all | client.studio.projects.chapters.list |
client.studio.chapters.get | client.studio.projects.chapters.get |
client.studio.chapters.create | client.studio.projects.chapters.create |
client.studio.chapters.edit | client.studio.projects.chapters.update |
client.studio.chapters.convert | client.studio.projects.chapters.convert |
client.studio.chapters.get_all_snapshots | client.studio.projects.chapters.snapshots.list |
client.studio.chapters.stream_snapshot | client.studio.projects.chapters.snapshots.stream |
client.studio.projects.update_pronunciation_dictionaries | client.studio.projects.pronunciation_dictionaries.create |
client.pronunciation_dictionary.add_from_file | client.pronunciation_dictionaries.create_from_file |
client.pronunciation_dictionary.add_from_rules | client.pronunciation_dictionaries.create_from_rules |
client.pronunciation_dictionary.add_rules | client.pronunciation_dictionaries.rules.add |
client.pronunciation_dictionary.remove_rules | client.pronunciation_dictionaries.rules.remove |
client.pronunciation_dictionary.download | client.pronunciation_dictionaries.download |
client.pronunciation_dictionary.get | client.pronunciation_dictionaries.get |
client.pronunciation_dictionary.get_all | client.pronunciation_dictionaries.list |
client.samples.get_audio | client.voices.samples.audio.get |
client.history.get_all | client.history.list |
client.usage.get_characters_usage_metrics | client.usage.get |
client.user.get_subscription | client.user.subscription.get |
client.voices.add_sharing_voice | client.voices.share |
client.workspace.search_user_groups | client.workspace.groups.search |
client.workspace.delete_member_from_user_group | client.workspace.groups.members.remove |
client.workspace.add_member_to_user_group | client.workspace.groups.members.add |
client.workspace.invite_user | client.workspace.invites.create |
client.workspace.invite_multiple_users | client.workspace.invites.create_batch |
client.workspace.delete_existing_invitation | client.workspace.invites.delete |
client.workspace.update_member | client.workspace.members.update |
client.workspace.delete_member | client.workspace.members.delete |
client.workspace.get_resource | client.workspace.resources.get |
client.workspace.share_workspace_resource | client.workspace.resources.share |
client.workspace.unshare_workspace_resource | client.workspace.resources.unshare |
Request stitching is the process of providing request ID from previous generations to an audio generation endpoint. By providing these IDs the model can ensure that subsequent generations match the style and prosody of previous iterations. Here's a simple example using the elevenlabs-python SDK:
import os
from io import BytesIO
from elevenlabs.client import ElevenLabs
from elevenlabs import play
from dotenv import load_dotenv
load_dotenv()
ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY")
client = ElevenLabs(
api_key=ELEVENLABS_API_KEY,
)
paragraphs = [
"The first move is what sets everything in motion.",
"The second move is what sets everything in motion.",
"The third move is what sets everything in motion.",
]
request_ids = []
audio_buffers = []
for paragraph in paragraphs:
with client.text_to_speech.with_raw_response.convert(
text=paragraph,
voice_id="T7QGPtToiqH4S8VlIkMJ",
model_id="eleven_multilingual_v2",
previous_request_ids=request_ids
) as response:
request_ids.append(response._response.headers.get("request-id"))
audio_data = b''.join(chunk for chunk in response.data)
audio_buffers.append(BytesIO(audio_data))
combined_stream = BytesIO(b''.join(buffer.getvalue() for buffer in audio_buffers))
play(combined_stream)
By using the new withRawResponse()
method we can extract the request headers, which include the request ID.
The new helper method elevenlabs.webhooks.constructEvent
is used to confirm that the event was sent by ElevenLabs. Example usage:
import os
from elevenlabs.client import ElevenLabs
from dotenv import load_dotenv
load_dotenv()
ELEVENLABS_API_KEY = os.getenv("ELEVENLABS_API_KEY")
elevenlabs = ElevenLabs(
api_key=ELEVENLABS_API_KEY,
)
# req is the raw request to the webhook endpoint
sig_header = req.headers.get('ElevenLabs-Signature')
# Construct the event from the webhook payload
event = elevenlabs_client.webhooks.construct_event(
req.body,
sig_header,
os.environ.get('ELEVENLABS_WEBHOOK_SECRET')
)
# If the above succeeds, the event was confirmed to have come from ElevenLabs
generate
and clone
has been removed from the SDK. Instead use the elevenlabs.text_to_speech.convert
method to generate text-to-speech audio and elevenlabs.voices.ivc.create
to create an Instant Voice Clone.