diff --git a/pyproject.toml b/pyproject.toml index b43643b6..13440487 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "elevenlabs" [tool.poetry] name = "elevenlabs" -version = "v2.12.0" +version = "v2.12.1" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index d81be1e2..5868a149 100644 --- a/reference.md +++ b/reference.md @@ -1,5 +1,5 @@ # Reference -
client.create_agent_response_test_route(...) +
client.save_a_voice_preview()
@@ -11,7 +11,7 @@
-Creates a new agent response test. +Add a generated voice to the voice library.
@@ -26,36 +26,12 @@ Creates a new agent response test.
```python -from elevenlabs import ( - AgentFailureResponseExample, - AgentSuccessfulResponseExample, - ConversationHistoryTranscriptCommonModelInput, - ElevenLabs, -) +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.create_agent_response_test_route( - chat_history=[ - ConversationHistoryTranscriptCommonModelInput( - role="user", - time_in_call_secs=1, - ) - ], - success_condition="success_condition", - success_examples=[ - AgentSuccessfulResponseExample( - response="response", - ) - ], - failure_examples=[ - AgentFailureResponseExample( - response="response", - ) - ], - name="name", -) +client.save_a_voice_preview() ```
@@ -71,23 +47,68 @@ client.create_agent_response_test_route(
-**chat_history:** `typing.Sequence[ConversationHistoryTranscriptCommonModelInput]` +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
+ + + + +
+ +## History +
client.history.list(...) +
+
+ +#### 📝 Description
-**success_condition:** `str` — A prompt that evaluates whether the agent's response is successful. Should return True or False. - +
+
+ +Returns a list of your generated audio.
+
+
+ +#### 🔌 Usage
-**success_examples:** `typing.Sequence[AgentSuccessfulResponseExample]` — Non-empty list of example responses that should be considered successful +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.history.list() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — How many history items to return at maximum. Can not exceed 1000, defaults to 100.
@@ -95,7 +116,7 @@ client.create_agent_response_test_route(
-**failure_examples:** `typing.Sequence[AgentFailureResponseExample]` — Non-empty list of example responses that should be considered failures +**start_after_history_item_id:** `typing.Optional[str]` — After which ID to start fetching, use this parameter to paginate across a large collection of history items. In case this parameter is not provided history items will be fetched starting from the most recently created one ordered descending by their creation date.
@@ -103,7 +124,7 @@ client.create_agent_response_test_route(
-**name:** `str` +**voice_id:** `typing.Optional[str]` — ID of the voice to be filtered for. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -111,7 +132,7 @@ client.create_agent_response_test_route(
-**tool_call_parameters:** `typing.Optional[UnitTestToolCallEvaluationModelInput]` — How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. +**search:** `typing.Optional[str]` — Search term used for filtering history items. If provided, source becomes required.
@@ -119,11 +140,7 @@ client.create_agent_response_test_route(
-**dynamic_variables:** `typing.Optional[ - typing.Dict[ - str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue] - ] -]` — Dynamic variables to replace in the agent config during testing +**source:** `typing.Optional[HistoryListRequestSource]` — Source of the generated history item
@@ -143,7 +160,7 @@ client.create_agent_response_test_route(
-
client.get_agent_response_test_route(...) +
client.history.get(...)
@@ -155,7 +172,7 @@ client.create_agent_response_test_route(
-Gets an agent response test by ID. +Retrieves a history item.
@@ -175,8 +192,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.get_agent_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", +client.history.get( + history_item_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -193,7 +210,7 @@ client.get_agent_response_test_route(
-**test_id:** `str` — The id of a chat response test. This is returned on test creation. +**history_item_id:** `str` — ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.
@@ -213,7 +230,7 @@ client.get_agent_response_test_route(
-
client.update_agent_response_test_route(...) +
client.history.delete(...)
@@ -225,7 +242,7 @@ client.get_agent_response_test_route(
-Updates an agent response test by ID. +Delete a history item by its ID
@@ -240,36 +257,13 @@ Updates an agent response test by ID.
```python -from elevenlabs import ( - AgentFailureResponseExample, - AgentSuccessfulResponseExample, - ConversationHistoryTranscriptCommonModelInput, - ElevenLabs, -) +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.update_agent_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", - chat_history=[ - ConversationHistoryTranscriptCommonModelInput( - role="user", - time_in_call_secs=1, - ) - ], - success_condition="success_condition", - success_examples=[ - AgentSuccessfulResponseExample( - response="response", - ) - ], - failure_examples=[ - AgentFailureResponseExample( - response="response", - ) - ], - name="name", +client.history.delete( + history_item_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -286,7 +280,7 @@ client.update_agent_response_test_route(
-**test_id:** `str` — The id of a chat response test. This is returned on test creation. +**history_item_id:** `str` — ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items.
@@ -294,31 +288,70 @@ client.update_agent_response_test_route(
-**chat_history:** `typing.Sequence[ConversationHistoryTranscriptCommonModelInput]` +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+
+
+ + + + +
+## TextToSoundEffects +
client.text_to_sound_effects.convert(...)
-**success_condition:** `str` — A prompt that evaluates whether the agent's response is successful. Should return True or False. - +#### 📝 Description + +
+
+ +
+
+ +Turn text into sound effects for your videos, voice-overs or video games using the most advanced sound effects model in the world. +
+
+#### 🔌 Usage +
-**success_examples:** `typing.Sequence[AgentSuccessfulResponseExample]` — Non-empty list of example responses that should be considered successful - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.text_to_sound_effects.convert( + text="Spacious braam suitable for high-impact movie trailer moments", +) + +``` +
+
+#### ⚙️ Parameters +
-**failure_examples:** `typing.Sequence[AgentFailureResponseExample]` — Non-empty list of example responses that should be considered failures +
+
+ +**text:** `str` — The text that will get converted into a sound effect.
@@ -326,7 +359,7 @@ client.update_agent_response_test_route(
-**name:** `str` +**output_format:** `typing.Optional[TextToSoundEffectsConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -334,7 +367,7 @@ client.update_agent_response_test_route(
-**tool_call_parameters:** `typing.Optional[UnitTestToolCallEvaluationModelInput]` — How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. +**duration_seconds:** `typing.Optional[float]` — The duration of the sound which will be generated in seconds. Must be at least 0.5 and at most 30. If set to None we will guess the optimal duration using the prompt. Defaults to None.
@@ -342,11 +375,7 @@ client.update_agent_response_test_route(
-**dynamic_variables:** `typing.Optional[ - typing.Dict[ - str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue] - ] -]` — Dynamic variables to replace in the agent config during testing +**prompt_influence:** `typing.Optional[float]` — A higher prompt influence makes your generation follow the prompt more closely while also making generations less variable. Must be a value between 0 and 1. Defaults to 0.3.
@@ -354,7 +383,7 @@ client.update_agent_response_test_route(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -366,7 +395,9 @@ client.update_agent_response_test_route(
-
client.delete_chat_response_test_route(...) +## AudioIsolation +## Samples +
client.samples.delete(...)
@@ -378,7 +409,7 @@ client.update_agent_response_test_route(
-Deletes an agent response test by ID. +Removes a sample by its ID.
@@ -398,8 +429,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.delete_chat_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", +client.samples.delete( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -416,7 +448,15 @@ client.delete_chat_response_test_route(
-**test_id:** `str` — The id of a chat response test. This is returned on test creation. +**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + +
+
+ +
+
+ +**sample_id:** `str` — ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice.
@@ -436,7 +476,8 @@ client.delete_chat_response_test_route(
-
client.get_agent_response_tests_summaries_route(...) +## TextToSpeech +
client.text_to_speech.convert(...)
@@ -448,7 +489,7 @@ client.delete_chat_response_test_route(
-Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. +Converts text into speech using a voice of your choice and returns audio.
@@ -468,8 +509,11 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.get_agent_response_tests_summaries_route( - test_ids=["test_id_1", "test_id_2"], +client.text_to_speech.convert( + voice_id="JBFqnCBsd6RMkjVDRZzb", + output_format="mp3_44100_128", + text="The first move is what sets everything in motion.", + model_id="eleven_multilingual_v2", ) ``` @@ -486,7 +530,7 @@ client.get_agent_response_tests_summaries_route(
-**test_ids:** `typing.Sequence[str]` — List of test IDs to fetch. No duplicates allowed. +**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -494,67 +538,56 @@ client.get_agent_response_tests_summaries_route(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**text:** `str` — The text that will get converted into speech.
- -
+
+
+**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +
-
-
client.list_chat_response_tests_route(...)
-#### 📝 Description +**optimize_streaming_latency:** `typing.Optional[int]` -
-
+You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: +0 - default mode (no latency optimizations) +1 - normal latency optimizations (about 50% of possible latency improvement of option 3) +2 - strong latency optimizations (about 75% of possible latency improvement of option 3) +3 - max latency optimizations +4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + +Defaults to None. + +
+
-Lists all agent response tests with pagination support and optional search filtering. -
-
+**output_format:** `typing.Optional[TextToSpeechConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +
-#### 🔌 Usage - -
-
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.list_chat_response_tests_route() - -``` -
-
+**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. +
-#### ⚙️ Parameters - -
-
-
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. +**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided.
@@ -562,7 +595,7 @@ client.list_chat_response_tests_route()
-**page_size:** `typing.Optional[int]` — How many Tests to return at maximum. Can not exceed 100, defaults to 30. +**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request.
@@ -570,7 +603,7 @@ client.list_chat_response_tests_route()
-**search:** `typing.Optional[str]` — Search query to filter tests by name. +**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request
@@ -578,74 +611,47 @@ client.list_chat_response_tests_route()
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295.
-
-
+
+
+**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +
-
-
client.run_agent_test_suite_route(...)
-#### 📝 Description - -
-
+**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + +
+
-Run selected tests on the agent with provided configuration. If the agent configuration is provided, it will be used to override default agent configuration. -
-
+**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. +
-#### 🔌 Usage - -
-
-
-```python -from elevenlabs import ElevenLabs, SingleTestRunRequestModel - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.run_agent_test_suite_route( - agent_id="21m00Tcm4TlvDq8ikWAM", - tests=[ - SingleTestRunRequestModel( - test_id="test_id", - ) - ], -) - -``` -
-
+**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. +
-#### ⚙️ Parameters - -
-
-
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions.
@@ -653,7 +659,7 @@ client.run_agent_test_suite_route(
-**tests:** `typing.Sequence[SingleTestRunRequestModel]` — List of tests to run on the agent +**apply_text_normalization:** `typing.Optional[BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans.
@@ -661,7 +667,7 @@ client.run_agent_test_suite_route(
-**agent_config_override:** `typing.Optional[AdhocAgentConfigOverrideForTestRequestModel]` — Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. +**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese.
@@ -669,7 +675,7 @@ client.run_agent_test_suite_route(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -681,7 +687,7 @@ client.run_agent_test_suite_route(
-
client.get_test_invocation_route(...) +
client.text_to_speech.convert_with_timestamps(...)
@@ -693,7 +699,7 @@ client.run_agent_test_suite_route(
-Gets a test invocation by ID. +Generate speech from text with precise character-level timing information for audio-text synchronization.
@@ -713,8 +719,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.get_test_invocation_route( - test_invocation_id="test_invocation_id", +client.text_to_speech.convert_with_timestamps( + voice_id="21m00Tcm4TlvDq8ikWAM", + text="This is a test for the API of ElevenLabs.", ) ``` @@ -731,7 +738,7 @@ client.get_test_invocation_route(
-**test_invocation_id:** `str` — The id of a test invocation. This is returned when tests are run. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -739,71 +746,48 @@ client.get_test_invocation_route(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**text:** `str` — The text that will get converted into speech.
- -
+
+
+**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +
-
-
client.resubmit_tests_route(...)
-#### 📝 Description - -
-
+**optimize_streaming_latency:** `typing.Optional[int]` -
-
+You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: +0 - default mode (no latency optimizations) +1 - normal latency optimizations (about 50% of possible latency improvement of option 3) +2 - strong latency optimizations (about 75% of possible latency improvement of option 3) +3 - max latency optimizations +4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). -Resubmits specific test runs from a test invocation. -
-
+Defaults to None. +
-#### 🔌 Usage -
-
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.resubmit_tests_route( - test_invocation_id="test_invocation_id", - test_run_ids=["test_run_ids"], - agent_id="agent_id", -) - -``` -
-
+**output_format:** `typing.Optional[TextToSpeechConvertWithTimestampsRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +
-#### ⚙️ Parameters - -
-
-
-**test_invocation_id:** `str` — The id of a test invocation. This is returned when tests are run. +**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property.
@@ -811,7 +795,7 @@ client.resubmit_tests_route(
-**test_run_ids:** `typing.Sequence[str]` — List of test run IDs to resubmit +**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided.
@@ -819,7 +803,7 @@ client.resubmit_tests_route(
-**agent_id:** `str` — Agent ID to resubmit tests for +**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request.
@@ -827,7 +811,7 @@ client.resubmit_tests_route(
-**agent_config_override:** `typing.Optional[AdhocAgentConfigOverrideForTestRequestModel]` — Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. +**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request
@@ -835,63 +819,69 @@ client.resubmit_tests_route(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295.
-
-
+
+
+**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +
-
-
client.save_a_voice_preview()
-#### 📝 Description +**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + +
+
+**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + +
+
+
-Add a generated voice to the voice library. -
-
+**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + -#### 🔌 Usage -
+**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + +
+
+
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.save_a_voice_preview() - -``` -
-
+**apply_text_normalization:** `typing.Optional[ + BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization +]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans. + -#### ⚙️ Parameters -
+**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + +
+
+
@@ -907,8 +897,7 @@ client.save_a_voice_preview()
-## History -
client.history.list(...) +
client.text_to_speech.stream(...)
@@ -920,7 +909,7 @@ client.save_a_voice_preview()
-Returns a list of your generated audio. +Converts text into speech using a voice of your choice and returns audio as an audio stream.
@@ -940,7 +929,12 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.history.list() +client.text_to_speech.stream( + voice_id="JBFqnCBsd6RMkjVDRZzb", + output_format="mp3_44100_128", + text="The first move is what sets everything in motion.", + model_id="eleven_multilingual_v2", +) ``` @@ -956,7 +950,7 @@ client.history.list()
-**page_size:** `typing.Optional[int]` — How many history items to return at maximum. Can not exceed 1000, defaults to 100. +**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -964,7 +958,7 @@ client.history.list()
-**start_after_history_item_id:** `typing.Optional[str]` — After which ID to start fetching, use this parameter to paginate across a large collection of history items. In case this parameter is not provided history items will be fetched starting from the most recently created one ordered descending by their creation date. +**text:** `str` — The text that will get converted into speech.
@@ -972,7 +966,7 @@ client.history.list()
-**voice_id:** `typing.Optional[str]` — ID of the voice to be filtered for. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.
@@ -980,7 +974,16 @@ client.history.list()
-**search:** `typing.Optional[str]` — Search term used for filtering history items. If provided, source becomes required. +**optimize_streaming_latency:** `typing.Optional[int]` + +You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: +0 - default mode (no latency optimizations) +1 - normal latency optimizations (about 50% of possible latency improvement of option 3) +2 - strong latency optimizations (about 75% of possible latency improvement of option 3) +3 - max latency optimizations +4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + +Defaults to None.
@@ -988,7 +991,7 @@ client.history.list()
-**source:** `typing.Optional[HistoryListRequestSource]` — Source of the generated history item +**output_format:** `typing.Optional[TextToSpeechStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -996,69 +999,97 @@ client.history.list()
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property.
- -
+
+
+**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. +
-
-
client.history.get(...)
-#### 📝 Description +**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. + +
+
+**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + +
+
+
-Retrieves a history item. +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +
+ +
+
+ +**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +
-#### 🔌 Usage -
+**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + +
+
+
-```python -from elevenlabs import ElevenLabs +**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + +
+
-client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.history.get( - history_item_id="VW7YKqPnjY4h39yTbx2L", -) +
+
-``` +**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. +
+ +
+
+ +**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. +
-#### ⚙️ Parameters -
+**apply_text_normalization:** `typing.Optional[ + BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization +]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans. + +
+
+
-**history_item_id:** `str` — ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. +**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese.
@@ -1066,7 +1097,7 @@ client.history.get(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -1078,7 +1109,7 @@ client.history.get(
-
client.history.delete(...) +
client.text_to_speech.stream_with_timestamps(...)
@@ -1090,7 +1121,7 @@ client.history.get(
-Delete a history item by its ID +Converts text into speech using a voice of your choice and returns a stream of JSONs containing audio as a base64 encoded string together with information on when which character was spoken.
@@ -1110,9 +1141,14 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.history.delete( - history_item_id="VW7YKqPnjY4h39yTbx2L", +response = client.text_to_speech.stream_with_timestamps( + voice_id="JBFqnCBsd6RMkjVDRZzb", + output_format="mp3_44100_128", + text="The first move is what sets everything in motion.", + model_id="eleven_multilingual_v2", ) +for chunk in response.data: + yield chunk ``` @@ -1128,7 +1164,7 @@ client.history.delete(
-**history_item_id:** `str` — ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. +**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -1136,70 +1172,112 @@ client.history.delete(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**text:** `str` — The text that will get converted into speech.
+ +
+
+ +**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +
+
+
+ +**optimize_streaming_latency:** `typing.Optional[int]` + +You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: +0 - default mode (no latency optimizations) +1 - normal latency optimizations (about 50% of possible latency improvement of option 3) +2 - strong latency optimizations (about 75% of possible latency improvement of option 3) +3 - max latency optimizations +4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). +Defaults to None. +
-
-## TextToSoundEffects -
client.text_to_sound_effects.convert(...)
-#### 📝 Description +**output_format:** `typing.Optional[TextToSpeechStreamWithTimestampsRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + +
+
+**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + +
+
+
-Turn text into sound effects for your videos, voice-overs or video games using the most advanced sound effects model in the world. +**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. +
+ +
+
+ +**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. +
-#### 🔌 Usage -
+**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + +
+
+
-```python -from elevenlabs import ElevenLabs +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + +
+
-client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.text_to_sound_effects.convert( - text="Spacious braam suitable for high-impact movie trailer moments", -) +
+
-``` +**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +
+ +
+
+ +**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +
-#### ⚙️ Parameters -
+**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + +
+
+
-**text:** `str` — The text that will get converted into a sound effect. +**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send.
@@ -1207,7 +1285,7 @@ client.text_to_sound_effects.convert(
-**output_format:** `typing.Optional[TextToSoundEffectsConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions.
@@ -1215,7 +1293,9 @@ client.text_to_sound_effects.convert(
-**duration_seconds:** `typing.Optional[float]` — The duration of the sound which will be generated in seconds. Must be at least 0.5 and at most 30. If set to None we will guess the optimal duration using the prompt. Defaults to None. +**apply_text_normalization:** `typing.Optional[ + BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization +]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans.
@@ -1223,7 +1303,7 @@ client.text_to_sound_effects.convert(
-**prompt_influence:** `typing.Optional[float]` — A higher prompt influence makes your generation follow the prompt more closely while also making generations less variable. Must be a value between 0 and 1. Defaults to 0.3. +**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese.
@@ -1231,7 +1311,7 @@ client.text_to_sound_effects.convert(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -1243,9 +1323,8 @@ client.text_to_sound_effects.convert(
-## AudioIsolation -## Samples -
client.samples.delete(...) +## TextToDialogue +
client.text_to_dialogue.convert(...)
@@ -1257,7 +1336,7 @@ client.text_to_sound_effects.convert(
-Removes a sample by its ID. +Converts a list of text and voice ID pairs into speech (dialogue) and returns audio.
@@ -1272,14 +1351,22 @@ Removes a sample by its ID.
```python -from elevenlabs import ElevenLabs +from elevenlabs import DialogueInput, ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.samples.delete( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", +client.text_to_dialogue.convert( + inputs=[ + DialogueInput( + text="Knock knock", + voice_id="JBFqnCBsd6RMkjVDRZzb", + ), + DialogueInput( + text="Who is there?", + voice_id="Aw4FAjKCGjjNkVhN1Xmq", + ), + ], ) ``` @@ -1296,7 +1383,7 @@ client.samples.delete(
-**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**inputs:** `typing.Sequence[DialogueInput]` — A list of dialogue inputs, each containing text and a voice ID which will be converted into speech.
@@ -1304,7 +1391,7 @@ client.samples.delete(
-**sample_id:** `str` — ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. +**output_format:** `typing.Optional[TextToDialogueConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -1312,7 +1399,39 @@ client.samples.delete(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + +
+
+ +
+
+ +**settings:** `typing.Optional[ModelSettingsResponseModel]` — Settings controlling the dialogue generation. + +
+
+ +
+
+ +**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + +
+
+ +
+
+ +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
@@ -1324,8 +1443,7 @@ client.samples.delete(
-## TextToSpeech -
client.text_to_speech.convert(...) +
client.text_to_dialogue.stream(...)
@@ -1337,7 +1455,7 @@ client.samples.delete(
-Converts text into speech using a voice of your choice and returns audio. +Converts a list of text and voice ID pairs into speech (dialogue) and returns an audio stream.
@@ -1352,16 +1470,22 @@ Converts text into speech using a voice of your choice and returns audio.
```python -from elevenlabs import ElevenLabs +from elevenlabs import DialogueInput, ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_speech.convert( - voice_id="JBFqnCBsd6RMkjVDRZzb", - output_format="mp3_44100_128", - text="The first move is what sets everything in motion.", - model_id="eleven_multilingual_v2", +client.text_to_dialogue.stream( + inputs=[ + DialogueInput( + text="Knock knock", + voice_id="JBFqnCBsd6RMkjVDRZzb", + ), + DialogueInput( + text="Who is there?", + voice_id="Aw4FAjKCGjjNkVhN1Xmq", + ), + ], ) ``` @@ -1378,7 +1502,7 @@ client.text_to_speech.convert(
-**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**inputs:** `typing.Sequence[DialogueInput]` — A list of dialogue inputs, each containing text and a voice ID which will be converted into speech.
@@ -1386,7 +1510,7 @@ client.text_to_speech.convert(
-**text:** `str` — The text that will get converted into speech. +**output_format:** `typing.Optional[TextToDialogueStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -1394,7 +1518,7 @@ client.text_to_speech.convert(
-**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property.
@@ -1402,16 +1526,15 @@ client.text_to_speech.convert(
-**optimize_streaming_latency:** `typing.Optional[int]` +**settings:** `typing.Optional[ModelSettingsResponseModel]` — Settings controlling the dialogue generation. + +
+
-You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: -0 - default mode (no latency optimizations) -1 - normal latency optimizations (about 50% of possible latency improvement of option 3) -2 - strong latency optimizations (about 75% of possible latency improvement of option 3) -3 - max latency optimizations -4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). +
+
-Defaults to None. +**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request
@@ -1419,7 +1542,7 @@ Defaults to None.
-**output_format:** `typing.Optional[TextToSpeechConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295.
@@ -1427,23 +1550,72 @@ Defaults to None.
-**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
+
+
+ + + + +
+## SpeechToSpeech +
client.speech_to_speech.convert(...)
-**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. - +#### 📝 Description + +
+
+ +
+
+ +Transform audio from one voice to another. Maintain full control over emotion, timing and delivery. +
+
+#### 🔌 Usage +
-**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.speech_to_speech.convert( + voice_id="JBFqnCBsd6RMkjVDRZzb", + output_format="mp3_44100_128", + model_id="eleven_multilingual_sts_v2", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -1451,7 +1623,9 @@ Defaults to None.
-**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request +**audio:** `from __future__ import annotations + +core.File` — See core.File for more documentation
@@ -1459,7 +1633,7 @@ Defaults to None.
-**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.
@@ -1467,7 +1641,16 @@ Defaults to None.
-**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +**optimize_streaming_latency:** `typing.Optional[int]` + +You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: +0 - default mode (no latency optimizations) +1 - normal latency optimizations (about 50% of possible latency improvement of option 3) +2 - strong latency optimizations (about 75% of possible latency improvement of option 3) +3 - max latency optimizations +4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + +Defaults to None.
@@ -1475,7 +1658,7 @@ Defaults to None.
-**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +**output_format:** `typing.Optional[SpeechToSpeechConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -1483,7 +1666,7 @@ Defaults to None.
-**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. +**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property.
@@ -1491,7 +1674,7 @@ Defaults to None.
-**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. +**voice_settings:** `typing.Optional[str]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string.
@@ -1499,7 +1682,7 @@ Defaults to None.
-**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295.
@@ -1507,7 +1690,7 @@ Defaults to None.
-**apply_text_normalization:** `typing.Optional[BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans. +**remove_background_noise:** `typing.Optional[bool]` — If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer.
@@ -1515,7 +1698,7 @@ Defaults to None.
-**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. +**file_format:** `typing.Optional[SpeechToSpeechConvertRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.
@@ -1535,7 +1718,7 @@ Defaults to None.
-
client.text_to_speech.convert_with_timestamps(...) +
client.speech_to_speech.stream(...)
@@ -1547,7 +1730,7 @@ Defaults to None.
-Generate speech from text with precise character-level timing information for audio-text synchronization. +Stream audio from one voice to another. Maintain full control over emotion, timing and delivery.
@@ -1567,9 +1750,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_speech.convert_with_timestamps( - voice_id="21m00Tcm4TlvDq8ikWAM", - text="This is a test for the API of ElevenLabs.", +client.speech_to_speech.stream( + voice_id="JBFqnCBsd6RMkjVDRZzb", + output_format="mp3_44100_128", + model_id="eleven_multilingual_sts_v2", ) ``` @@ -1586,7 +1770,7 @@ client.text_to_speech.convert_with_timestamps(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -1594,7 +1778,9 @@ client.text_to_speech.convert_with_timestamps(
-**text:** `str` — The text that will get converted into speech. +**audio:** `from __future__ import annotations + +core.File` — See core.File for more documentation
@@ -1627,7 +1813,7 @@ Defaults to None.
-**output_format:** `typing.Optional[TextToSpeechConvertWithTimestampsRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**output_format:** `typing.Optional[SpeechToSpeechStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -1635,7 +1821,7 @@ Defaults to None.
-**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. +**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property.
@@ -1643,7 +1829,7 @@ Defaults to None.
-**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. +**voice_settings:** `typing.Optional[str]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string.
@@ -1651,7 +1837,7 @@ Defaults to None.
-**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295.
@@ -1659,7 +1845,7 @@ Defaults to None.
-**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request +**remove_background_noise:** `typing.Optional[bool]` — If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer.
@@ -1667,7 +1853,7 @@ Defaults to None.
-**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +**file_format:** `typing.Optional[SpeechToSpeechStreamRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.
@@ -1675,15 +1861,70 @@ Defaults to None.
-**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
+ +
+ + + + +
+ +## TextToVoice +
client.text_to_voice.create_previews(...) +
+
+ +#### 📝 Description
-**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +
+
+ +Create a voice from a text prompt. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.text_to_voice.create_previews( + voice_description="A sassy squeaky mouse", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**voice_description:** `str` — Description to use for the created voice.
@@ -1691,7 +1932,7 @@ Defaults to None.
-**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. +**output_format:** `typing.Optional[TextToVoiceCreatePreviewsRequestOutputFormat]` — The output format of the generated audio.
@@ -1699,7 +1940,7 @@ Defaults to None.
-**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. +**text:** `typing.Optional[str]` — Text to generate, text length has to be between 100 and 1000.
@@ -1707,7 +1948,7 @@ Defaults to None.
-**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. +**auto_generate_text:** `typing.Optional[bool]` — Whether to automatically generate a text suitable for the voice description.
@@ -1715,9 +1956,7 @@ Defaults to None.
-**apply_text_normalization:** `typing.Optional[ - BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization -]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans. +**loudness:** `typing.Optional[float]` — Controls the volume level of the generated voice. -1 is quietest, 1 is loudest, 0 corresponds to roughly -24 LUFS.
@@ -1725,7 +1964,23 @@ Defaults to None.
-**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. +**quality:** `typing.Optional[float]` — Higher quality results in better voice output but less variety. + +
+
+ +
+
+ +**seed:** `typing.Optional[int]` — Random number that controls the voice generation. Same seed with same inputs produces same voice. + +
+
+ +
+
+ +**guidance_scale:** `typing.Optional[float]` — Controls how closely the AI follows the prompt. Lower numbers give the AI more freedom to be creative, while higher numbers force it to stick more to the prompt. High numbers can cause voice to sound artificial or robotic. We recommend to use longer, more detailed prompts at lower Guidance Scale.
@@ -1745,7 +2000,7 @@ Defaults to None.
-
client.text_to_speech.stream(...) +
client.text_to_voice.create(...)
@@ -1757,7 +2012,7 @@ Defaults to None.
-Converts text into speech using a voice of your choice and returns audio as an audio stream. +Create a voice from previously generated voice preview. This endpoint should be called after you fetched a generated_voice_id using POST /v1/text-to-voice/design or POST /v1/text-to-voice/:voice_id/remix.
@@ -1777,11 +2032,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_speech.stream( - voice_id="JBFqnCBsd6RMkjVDRZzb", - output_format="mp3_44100_128", - text="The first move is what sets everything in motion.", - model_id="eleven_multilingual_v2", +client.text_to_voice.create( + voice_name="Sassy squeaky mouse", + voice_description="A sassy squeaky mouse", + generated_voice_id="37HceQefKmEi3bGovXjL", ) ``` @@ -1798,7 +2052,7 @@ client.text_to_speech.stream(
-**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**voice_name:** `str` — Name to use for the created voice.
@@ -1806,7 +2060,7 @@ client.text_to_speech.stream(
-**text:** `str` — The text that will get converted into speech. +**voice_description:** `str` — Description to use for the created voice.
@@ -1814,7 +2068,7 @@ client.text_to_speech.stream(
-**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +**generated_voice_id:** `str` — The generated_voice_id to create, call POST /v1/text-to-voice/create-previews and fetch the generated_voice_id from the response header if don't have one yet.
@@ -1822,16 +2076,7 @@ client.text_to_speech.stream(
-**optimize_streaming_latency:** `typing.Optional[int]` - -You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: -0 - default mode (no latency optimizations) -1 - normal latency optimizations (about 50% of possible latency improvement of option 3) -2 - strong latency optimizations (about 75% of possible latency improvement of option 3) -3 - max latency optimizations -4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). - -Defaults to None. +**labels:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` — Optional, metadata to add to the created voice. Defaults to None.
@@ -1839,7 +2084,7 @@ Defaults to None.
-**output_format:** `typing.Optional[TextToSpeechStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**played_not_selected_voice_ids:** `typing.Optional[typing.Sequence[str]]` — List of voice ids that the user has played but not selected. Used for RLHF.
@@ -1847,15 +2092,69 @@ Defaults to None.
-**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
- + +
+ + + + +
+ +
client.text_to_voice.design(...)
-**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. +#### 📝 Description + +
+
+ +
+
+ +Design a voice via a prompt. This method returns a list of voice previews. Each preview has a generated_voice_id and a sample of the voice as base64 encoded mp3 audio. To create a voice use the generated_voice_id of the preferred preview with the /v1/text-to-voice endpoint. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.text_to_voice.design( + voice_description="A sassy squeaky mouse", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**voice_description:** `str` — Description to use for the created voice.
@@ -1863,7 +2162,7 @@ Defaults to None.
-**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. +**output_format:** `typing.Optional[TextToVoiceDesignRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -1871,7 +2170,7 @@ Defaults to None.
-**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request +**model_id:** `typing.Optional[VoiceDesignRequestModelModelId]` — Model to use for the voice generation. Possible values: eleven_multilingual_ttv_v2, eleven_ttv_v3.
@@ -1879,7 +2178,7 @@ Defaults to None.
-**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +**text:** `typing.Optional[str]` — Text to generate, text length has to be between 100 and 1000.
@@ -1887,7 +2186,7 @@ Defaults to None.
-**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +**auto_generate_text:** `typing.Optional[bool]` — Whether to automatically generate a text suitable for the voice description.
@@ -1895,7 +2194,7 @@ Defaults to None.
-**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +**loudness:** `typing.Optional[float]` — Controls the volume level of the generated voice. -1 is quietest, 1 is loudest, 0 corresponds to roughly -24 LUFS.
@@ -1903,7 +2202,7 @@ Defaults to None.
-**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. +**seed:** `typing.Optional[int]` — Random number that controls the voice generation. Same seed with same inputs produces same voice.
@@ -1911,7 +2210,7 @@ Defaults to None.
-**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. +**guidance_scale:** `typing.Optional[float]` — Controls how closely the AI follows the prompt. Lower numbers give the AI more freedom to be creative, while higher numbers force it to stick more to the prompt. High numbers can cause voice to sound artificial or robotic. We recommend to use longer, more detailed prompts at lower Guidance Scale.
@@ -1919,7 +2218,7 @@ Defaults to None.
-**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. +**stream_previews:** `typing.Optional[bool]` — Determines whether the Text to Voice previews should be included in the response. If true, only the generated IDs will be returned which can then be streamed via the /v1/text-to-voice/:generated_voice_id/stream endpoint.
@@ -1927,9 +2226,7 @@ Defaults to None.
-**apply_text_normalization:** `typing.Optional[ - BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization -]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans. +**remixing_session_id:** `typing.Optional[str]` — The remixing session id.
@@ -1937,7 +2234,7 @@ Defaults to None.
-**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. +**remixing_session_iteration_id:** `typing.Optional[str]` — The id of the remixing session iteration where these generations should be attached to. If not provided, a new iteration will be created.
@@ -1945,7 +2242,31 @@ Defaults to None.
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. +**quality:** `typing.Optional[float]` — Higher quality results in better voice output but less variety. + +
+
+ +
+
+ +**reference_audio_base_64:** `typing.Optional[str]` — Reference audio to use for the voice generation. The audio should be base64 encoded. Only supported when using the eleven_ttv_v3 model. + +
+
+ +
+
+ +**prompt_strength:** `typing.Optional[float]` — Controls the balance of prompt versus reference audio when generating voice samples. 0 means almost no prompt influence, 1 means almost no reference audio influence. Only supported when using the eleven_ttv_v3 model and providing reference audio. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -1957,7 +2278,8 @@ Defaults to None.
-
client.text_to_speech.stream_with_timestamps(...) +## user +
client.user.get()
@@ -1969,7 +2291,7 @@ Defaults to None.
-Converts text into speech using a voice of your choice and returns a stream of JSONs containing audio as a base64 encoded string together with information on when which character was spoken. +Gets information about the user
@@ -1989,14 +2311,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -response = client.text_to_speech.stream_with_timestamps( - voice_id="JBFqnCBsd6RMkjVDRZzb", - output_format="mp3_44100_128", - text="The first move is what sets everything in motion.", - model_id="eleven_multilingual_v2", -) -for chunk in response.data: - yield chunk +client.user.get() ``` @@ -2012,23 +2327,68 @@ for chunk in response.data:
-**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
+ + + + +
+ +## Voices +
client.voices.get_all(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of all available voices for a user. +
+
+
+
+ +#### 🔌 Usage
-**text:** `str` — The text that will get converted into speech. - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.voices.get_all() + +``` +
+
+#### ⚙️ Parameters +
-**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +
+
+ +**show_legacy:** `typing.Optional[bool]` — If set to true, legacy premade voices will be included in responses from /v1/voices
@@ -2036,40 +2396,69 @@ for chunk in response.data:
-**optimize_streaming_latency:** `typing.Optional[int]` +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
-You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: -0 - default mode (no latency optimizations) -1 - normal latency optimizations (about 50% of possible latency improvement of option 3) -2 - strong latency optimizations (about 75% of possible latency improvement of option 3) -3 - max latency optimizations -4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). -Defaults to None. -
+
+
client.voices.search(...)
-**output_format:** `typing.Optional[TextToSpeechStreamWithTimestampsRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. - +#### 📝 Description + +
+
+ +
+
+ +Gets a list of all available voices for a user with search, filtering and pagination.
+
+
+ +#### 🔌 Usage
-**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.voices.search( + include_total_count=True, +) + +```
+
+
+ +#### ⚙️ Parameters
-**language_code:** `typing.Optional[str]` — Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. +
+
+ +**next_page_token:** `typing.Optional[str]` — The next page token to use for pagination. Returned from the previous request.
@@ -2077,7 +2466,7 @@ Defaults to None.
-**voice_settings:** `typing.Optional[VoiceSettings]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. +**page_size:** `typing.Optional[int]` — How many voices to return at maximum. Can not exceed 100, defaults to 10. Page 0 may include more voices due to default voices being included.
@@ -2085,7 +2474,7 @@ Defaults to None.
-**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request +**search:** `typing.Optional[str]` — Search term to filter voices by. Searches in name, description, labels, category.
@@ -2093,7 +2482,7 @@ Defaults to None.
-**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +**sort:** `typing.Optional[str]` — Which field to sort by, one of 'created_at_unix' or 'name'. 'created_at_unix' may not be available for older voices.
@@ -2101,7 +2490,7 @@ Defaults to None.
-**previous_text:** `typing.Optional[str]` — The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +**sort_direction:** `typing.Optional[str]` — Which direction to sort the voices in. 'asc' or 'desc'.
@@ -2109,7 +2498,7 @@ Defaults to None.
-**next_text:** `typing.Optional[str]` — The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. +**voice_type:** `typing.Optional[str]` — Type of the voice to filter by. One of 'personal', 'community', 'default', 'workspace', 'non-default'. 'non-default' is equal to all but 'default'.
@@ -2117,7 +2506,7 @@ Defaults to None.
-**previous_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. +**category:** `typing.Optional[str]` — Category of the voice to filter by. One of 'premade', 'cloned', 'generated', 'professional'
@@ -2125,7 +2514,7 @@ Defaults to None.
-**next_request_ids:** `typing.Optional[typing.Sequence[str]]` — A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. +**fine_tuning_state:** `typing.Optional[str]` — State of the voice's fine tuning to filter by. Applicable only to professional voices clones. One of 'draft', 'not_verified', 'not_started', 'queued', 'fine_tuning', 'fine_tuned', 'failed', 'delayed'
@@ -2133,7 +2522,7 @@ Defaults to None.
-**use_pvc_as_ivc:** `typing.Optional[bool]` — If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. +**collection_id:** `typing.Optional[str]` — Collection ID to filter voices by.
@@ -2141,9 +2530,7 @@ Defaults to None.
-**apply_text_normalization:** `typing.Optional[ - BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization -]` — This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. For 'eleven_turbo_v2_5' and 'eleven_flash_v2_5' models, text normalization can only be enabled with Enterprise plans. +**include_total_count:** `typing.Optional[bool]` — Whether to include the total count of voices found in the response. Incurs a performance cost.
@@ -2151,7 +2538,7 @@ Defaults to None.
-**apply_language_text_normalization:** `typing.Optional[bool]` — This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. +**voice_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Voice IDs to lookup by. Maximum 100 voice IDs.
@@ -2171,8 +2558,7 @@ Defaults to None.
-## TextToDialogue -
client.text_to_dialogue.convert(...) +
client.voices.get(...)
@@ -2184,7 +2570,7 @@ Defaults to None.
-Converts a list of text and voice ID pairs into speech (dialogue) and returns audio. +Returns metadata about a specific voice.
@@ -2199,22 +2585,13 @@ Converts a list of text and voice ID pairs into speech (dialogue) and returns au
```python -from elevenlabs import DialogueInput, ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_dialogue.convert( - inputs=[ - DialogueInput( - text="Knock knock", - voice_id="JBFqnCBsd6RMkjVDRZzb", - ), - DialogueInput( - text="Who is there?", - voice_id="Aw4FAjKCGjjNkVhN1Xmq", - ), - ], +client.voices.get( + voice_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -2231,7 +2608,7 @@ client.text_to_dialogue.convert(
-**inputs:** `typing.Sequence[DialogueInput]` — A list of dialogue inputs, each containing text and a voice ID which will be converted into speech. +**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -2239,7 +2616,7 @@ client.text_to_dialogue.convert(
-**output_format:** `typing.Optional[TextToDialogueConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**with_settings:** `typing.Optional[bool]` — This parameter is now deprecated. It is ignored and will be removed in a future version.
@@ -2247,31 +2624,69 @@ client.text_to_dialogue.convert(
-**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+
+
+ + + + +
+
client.voices.delete(...)
-**settings:** `typing.Optional[ModelSettingsResponseModel]` — Settings controlling the dialogue generation. - +#### 📝 Description + +
+
+ +
+
+ +Deletes a voice by its ID.
+
+
+ +#### 🔌 Usage
-**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.voices.delete( + voice_id="21m00Tcm4TlvDq8ikWAM", +) + +```
+
+
+ +#### ⚙️ Parameters
-**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +
+
+ +**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -2279,7 +2694,7 @@ client.text_to_dialogue.convert(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -2291,7 +2706,7 @@ client.text_to_dialogue.convert(
-
client.text_to_dialogue.stream(...) +
client.voices.update(...)
@@ -2303,7 +2718,7 @@ client.text_to_dialogue.convert(
-Converts a list of text and voice ID pairs into speech (dialogue) and returns an audio stream. +Edit a voice created by you.
@@ -2318,22 +2733,14 @@ Converts a list of text and voice ID pairs into speech (dialogue) and returns an
```python -from elevenlabs import DialogueInput, ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_dialogue.stream( - inputs=[ - DialogueInput( - text="Knock knock", - voice_id="JBFqnCBsd6RMkjVDRZzb", - ), - DialogueInput( - text="Who is there?", - voice_id="Aw4FAjKCGjjNkVhN1Xmq", - ), - ], +client.voices.update( + voice_id="21m00Tcm4TlvDq8ikWAM", + name="name", ) ``` @@ -2350,7 +2757,7 @@ client.text_to_dialogue.stream(
-**inputs:** `typing.Sequence[DialogueInput]` — A list of dialogue inputs, each containing text and a voice ID which will be converted into speech. +**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -2358,7 +2765,7 @@ client.text_to_dialogue.stream(
-**output_format:** `typing.Optional[TextToDialogueStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website.
@@ -2366,7 +2773,9 @@ client.text_to_dialogue.stream(
-**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. +**files:** `from __future__ import annotations + +typing.Optional[typing.List[core.File]]` — See core.File for more documentation
@@ -2374,7 +2783,7 @@ client.text_to_dialogue.stream(
-**settings:** `typing.Optional[ModelSettingsResponseModel]` — Settings controlling the dialogue generation. +**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse.
@@ -2382,7 +2791,7 @@ client.text_to_dialogue.stream(
-**pronunciation_dictionary_locators:** `typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]]` — A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request +**description:** `typing.Optional[str]` — A description of the voice.
@@ -2390,7 +2799,7 @@ client.text_to_dialogue.stream(
-**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +**labels:** `typing.Optional[str]` — Serialized labels dictionary for the voice.
@@ -2398,7 +2807,7 @@ client.text_to_dialogue.stream(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -2410,8 +2819,7 @@ client.text_to_dialogue.stream(
-## SpeechToSpeech -
client.speech_to_speech.convert(...) +
client.voices.share(...)
@@ -2423,7 +2831,7 @@ client.text_to_dialogue.stream(
-Transform audio from one voice to another. Maintain full control over emotion, timing and delivery. +Add a shared voice to your collection of Voices
@@ -2443,10 +2851,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.speech_to_speech.convert( - voice_id="JBFqnCBsd6RMkjVDRZzb", - output_format="mp3_44100_128", - model_id="eleven_multilingual_sts_v2", +client.voices.share( + public_user_id="63e06b7e7cafdc46be4d2e0b3f045940231ae058d508589653d74d1265a574ca", + voice_id="21m00Tcm4TlvDq8ikWAM", + new_name="John Smith", ) ``` @@ -2463,74 +2871,7 @@ client.speech_to_speech.convert(
-**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. - -
-
- -
-
- -**audio:** `from __future__ import annotations - -core.File` — See core.File for more documentation - -
-
- -
-
- -**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. - -
-
- -
-
- -**optimize_streaming_latency:** `typing.Optional[int]` - -You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: -0 - default mode (no latency optimizations) -1 - normal latency optimizations (about 50% of possible latency improvement of option 3) -2 - strong latency optimizations (about 75% of possible latency improvement of option 3) -3 - max latency optimizations -4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). - -Defaults to None. - -
-
- -
-
- -**output_format:** `typing.Optional[SpeechToSpeechConvertRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. - -
-
- -
-
- -**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property. - -
-
- -
-
- -**voice_settings:** `typing.Optional[str]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string. - -
-
- -
-
- -**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +**public_user_id:** `str` — Public user ID used to publicly identify ElevenLabs users.
@@ -2538,7 +2879,7 @@ Defaults to None.
-**remove_background_noise:** `typing.Optional[bool]` — If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. +**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -2546,7 +2887,7 @@ Defaults to None.
-**file_format:** `typing.Optional[SpeechToSpeechConvertRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. +**new_name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website.
@@ -2554,7 +2895,7 @@ Defaults to None.
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -2566,7 +2907,7 @@ Defaults to None.
-
client.speech_to_speech.stream(...) +
client.voices.get_shared(...)
@@ -2578,7 +2919,7 @@ Defaults to None.
-Stream audio from one voice to another. Maintain full control over emotion, timing and delivery. +Retrieves a list of shared voices.
@@ -2598,10 +2939,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.speech_to_speech.stream( - voice_id="JBFqnCBsd6RMkjVDRZzb", - output_format="mp3_44100_128", - model_id="eleven_multilingual_sts_v2", +client.voices.get_shared( + featured=True, + reader_app_enabled=True, ) ``` @@ -2618,7 +2958,7 @@ client.speech_to_speech.stream(
-**voice_id:** `str` — ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**page_size:** `typing.Optional[int]` — How many shared voices to return at maximum. Can not exceed 100, defaults to 30.
@@ -2626,9 +2966,7 @@ client.speech_to_speech.stream(
-**audio:** `from __future__ import annotations - -core.File` — See core.File for more documentation +**category:** `typing.Optional[VoicesGetSharedRequestCategory]` — Voice category used for filtering
@@ -2636,7 +2974,7 @@ core.File` — See core.File for more documentation
-**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +**gender:** `typing.Optional[str]` — Gender used for filtering
@@ -2644,16 +2982,7 @@ core.File` — See core.File for more documentation
-**optimize_streaming_latency:** `typing.Optional[int]` - -You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: -0 - default mode (no latency optimizations) -1 - normal latency optimizations (about 50% of possible latency improvement of option 3) -2 - strong latency optimizations (about 75% of possible latency improvement of option 3) -3 - max latency optimizations -4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). - -Defaults to None. +**age:** `typing.Optional[str]` — Age used for filtering
@@ -2661,7 +2990,7 @@ Defaults to None.
-**output_format:** `typing.Optional[SpeechToSpeechStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**accent:** `typing.Optional[str]` — Accent used for filtering
@@ -2669,7 +2998,7 @@ Defaults to None.
-**model_id:** `typing.Optional[str]` — Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property. +**language:** `typing.Optional[str]` — Language used for filtering
@@ -2677,7 +3006,7 @@ Defaults to None.
-**voice_settings:** `typing.Optional[str]` — Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string. +**locale:** `typing.Optional[str]` — Locale used for filtering
@@ -2685,7 +3014,7 @@ Defaults to None.
-**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. +**search:** `typing.Optional[str]` — Search term used for filtering
@@ -2693,7 +3022,7 @@ Defaults to None.
-**remove_background_noise:** `typing.Optional[bool]` — If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. +**use_cases:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Use-case used for filtering
@@ -2701,7 +3030,7 @@ Defaults to None.
-**file_format:** `typing.Optional[SpeechToSpeechStreamRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. +**descriptives:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Search term used for filtering
@@ -2709,94 +3038,31 @@ Defaults to None.
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. +**featured:** `typing.Optional[bool]` — Filter featured voices
- -
+
+
+**min_notice_period_days:** `typing.Optional[int]` — Filter voices with a minimum notice period of the given number of days. +
-
-## TextToVoice -
client.text_to_voice.create_previews(...)
-#### 📝 Description - -
-
+**include_custom_rates:** `typing.Optional[bool]` — Include/exclude voices with custom rates + +
+
-Create a voice from a text prompt. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.text_to_voice.create_previews( - voice_description="A sassy squeaky mouse", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**voice_description:** `str` — Description to use for the created voice. - -
-
- -
-
- -**output_format:** `typing.Optional[TextToVoiceCreatePreviewsRequestOutputFormat]` — The output format of the generated audio. - -
-
- -
-
- -**text:** `typing.Optional[str]` — Text to generate, text length has to be between 100 and 1000. - -
-
- -
-
- -**auto_generate_text:** `typing.Optional[bool]` — Whether to automatically generate a text suitable for the voice description. +**include_live_moderated:** `typing.Optional[bool]` — Include/exclude voices that are live moderated
@@ -2804,7 +3070,7 @@ client.text_to_voice.create_previews(
-**loudness:** `typing.Optional[float]` — Controls the volume level of the generated voice. -1 is quietest, 1 is loudest, 0 corresponds to roughly -24 LUFS. +**reader_app_enabled:** `typing.Optional[bool]` — Filter voices that are enabled for the reader app
@@ -2812,7 +3078,7 @@ client.text_to_voice.create_previews(
-**quality:** `typing.Optional[float]` — Higher quality results in better voice output but less variety. +**owner_id:** `typing.Optional[str]` — Filter voices by public owner ID
@@ -2820,7 +3086,7 @@ client.text_to_voice.create_previews(
-**seed:** `typing.Optional[int]` — Random number that controls the voice generation. Same seed with same inputs produces same voice. +**sort:** `typing.Optional[str]` — Sort criteria
@@ -2828,7 +3094,7 @@ client.text_to_voice.create_previews(
-**guidance_scale:** `typing.Optional[float]` — Controls how closely the AI follows the prompt. Lower numbers give the AI more freedom to be creative, while higher numbers force it to stick more to the prompt. High numbers can cause voice to sound artificial or robotic. We recommend to use longer, more detailed prompts at lower Guidance Scale. +**page:** `typing.Optional[int]`
@@ -2848,7 +3114,7 @@ client.text_to_voice.create_previews(
-
client.text_to_voice.create(...) +
client.voices.find_similar_voices(...)
@@ -2860,7 +3126,7 @@ client.text_to_voice.create_previews(
-Create a voice from previously generated voice preview. This endpoint should be called after you fetched a generated_voice_id using POST /v1/text-to-voice/design or POST /v1/text-to-voice/:voice_id/remix. +Returns a list of shared voices similar to the provided audio sample. If neither similarity_threshold nor top_k is provided, we will apply default values.
@@ -2880,11 +3146,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_voice.create( - voice_name="Sassy squeaky mouse", - voice_description="A sassy squeaky mouse", - generated_voice_id="37HceQefKmEi3bGovXjL", -) +client.voices.find_similar_voices() ``` @@ -2900,23 +3162,9 @@ client.text_to_voice.create(
-**voice_name:** `str` — Name to use for the created voice. - -
-
- -
-
- -**voice_description:** `str` — Description to use for the created voice. - -
-
- -
-
+**audio_file:** `from __future__ import annotations -**generated_voice_id:** `str` — The generated_voice_id to create, call POST /v1/text-to-voice/create-previews and fetch the generated_voice_id from the response header if don't have one yet. +typing.Optional[core.File]` — See core.File for more documentation
@@ -2924,7 +3172,7 @@ client.text_to_voice.create(
-**labels:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` — Optional, metadata to add to the created voice. Defaults to None. +**similarity_threshold:** `typing.Optional[float]` — Threshold for voice similarity between provided sample and library voices. Values range from 0 to 2. The smaller the value the more similar voices will be returned.
@@ -2932,7 +3180,7 @@ client.text_to_voice.create(
-**played_not_selected_voice_ids:** `typing.Optional[typing.Sequence[str]]` — List of voice ids that the user has played but not selected. Used for RLHF. +**top_k:** `typing.Optional[int]` — Number of most similar voices to return. If similarity_threshold is provided, less than this number of voices may be returned. Values range from 1 to 100.
@@ -2952,7 +3200,8 @@ client.text_to_voice.create(
-
client.text_to_voice.design(...) +## Studio +
client.studio.create_podcast(...)
@@ -2964,7 +3213,7 @@ client.text_to_voice.create(
-Design a voice via a prompt. This method returns a list of voice previews. Each preview has a generated_voice_id and a sample of the voice as base64 encoded mp3 audio. To create a voice use the generated_voice_id of the preferred preview with the /v1/text-to-voice endpoint. +Create and auto-convert a podcast project. Currently, the LLM cost is covered by us but you will still be charged for the audio generation. In the future, you will be charged for both the LLM and audio generation costs.
@@ -2979,13 +3228,29 @@ Design a voice via a prompt. This method returns a list of voice previews. Each
```python -from elevenlabs import ElevenLabs +from elevenlabs import ( + ElevenLabs, + PodcastConversationModeData, + PodcastTextSource, +) +from elevenlabs.studio import ( + BodyCreatePodcastV1StudioPodcastsPostMode_Conversation, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_voice.design( - voice_description="A sassy squeaky mouse", +client.studio.create_podcast( + model_id="eleven_multilingual_v2", + mode=BodyCreatePodcastV1StudioPodcastsPostMode_Conversation( + conversation=PodcastConversationModeData( + host_voice_id="aw1NgEzBg83R7vgmiJt6", + guest_voice_id="aw1NgEzBg83R7vgmiJt7", + ), + ), + source=PodcastTextSource( + text="This is a test podcast.", + ), ) ``` @@ -3002,7 +3267,7 @@ client.text_to_voice.design(
-**voice_description:** `str` — Description to use for the created voice. +**model_id:** `str` — The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models.
@@ -3010,7 +3275,7 @@ client.text_to_voice.design(
-**output_format:** `typing.Optional[TextToVoiceDesignRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**mode:** `BodyCreatePodcastV1StudioPodcastsPostMode` — The type of podcast to generate. Can be 'conversation', an interaction between two voices, or 'bulletin', a monologue.
@@ -3018,7 +3283,7 @@ client.text_to_voice.design(
-**model_id:** `typing.Optional[VoiceDesignRequestModelModelId]` — Model to use for the voice generation. Possible values: eleven_multilingual_ttv_v2, eleven_ttv_v3. +**source:** `BodyCreatePodcastV1StudioPodcastsPostSource` — The source content for the Podcast.
@@ -3026,15 +3291,13 @@ client.text_to_voice.design(
-**text:** `typing.Optional[str]` — Text to generate, text length has to be between 100 and 1000. - -
-
- -
-
+**quality_preset:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset]` -**auto_generate_text:** `typing.Optional[bool]` — Whether to automatically generate a text suitable for the voice description. +Output quality of the generated audio. Must be one of: +standard - standard output format, 128kbps with 44.1kHz sample rate. +high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. +ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. +ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%.
@@ -3042,15 +3305,12 @@ client.text_to_voice.design(
-**loudness:** `typing.Optional[float]` — Controls the volume level of the generated voice. -1 is quietest, 1 is loudest, 0 corresponds to roughly -24 LUFS. - -
-
- -
-
+**duration_scale:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale]` -**seed:** `typing.Optional[int]` — Random number that controls the voice generation. Same seed with same inputs produces same voice. +Duration of the generated podcast. Must be one of: +short - produces podcasts shorter than 3 minutes. +default - produces podcasts roughly between 3-7 minutes. +long - produces podcasts longer than 7 minutes.
@@ -3058,7 +3318,7 @@ client.text_to_voice.design(
-**guidance_scale:** `typing.Optional[float]` — Controls how closely the AI follows the prompt. Lower numbers give the AI more freedom to be creative, while higher numbers force it to stick more to the prompt. High numbers can cause voice to sound artificial or robotic. We recommend to use longer, more detailed prompts at lower Guidance Scale. +**language:** `typing.Optional[str]` — An optional language of the Studio project. Two-letter language code (ISO 639-1).
@@ -3066,7 +3326,7 @@ client.text_to_voice.design(
-**stream_previews:** `typing.Optional[bool]` — Determines whether the Text to Voice previews should be included in the response. If true, only the generated IDs will be returned which can then be streamed via the /v1/text-to-voice/:generated_voice_id/stream endpoint. +**intro:** `typing.Optional[str]` — The intro text that will always be added to the beginning of the podcast.
@@ -3074,7 +3334,7 @@ client.text_to_voice.design(
-**remixing_session_id:** `typing.Optional[str]` — The remixing session id. +**outro:** `typing.Optional[str]` — The outro text that will always be added to the end of the podcast.
@@ -3082,7 +3342,7 @@ client.text_to_voice.design(
-**remixing_session_iteration_id:** `typing.Optional[str]` — The id of the remixing session iteration where these generations should be attached to. If not provided, a new iteration will be created. +**instructions_prompt:** `typing.Optional[str]` — Additional instructions prompt for the podcast generation used to adjust the podcast's style and tone.
@@ -3090,7 +3350,7 @@ client.text_to_voice.design(
-**quality:** `typing.Optional[float]` — Higher quality results in better voice output but less variety. +**highlights:** `typing.Optional[typing.Sequence[str]]` — A brief summary or highlights of the Studio project's content, providing key points or themes. This should be between 10 and 70 characters.
@@ -3098,15 +3358,63 @@ client.text_to_voice.design(
-**reference_audio_base_64:** `typing.Optional[str]` — Reference audio to use for the voice generation. The audio should be base64 encoded. Only supported when using the eleven_ttv_v3 model. - -
-
+**callback_url:** `typing.Optional[str]` -
-
-**prompt_strength:** `typing.Optional[float]` — Controls the balance of prompt versus reference audio when generating voice samples. 0 means almost no prompt influence, 1 means almost no reference audio influence. Only supported when using the eleven_ttv_v3 model and providing reference audio. + A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion + Messages: + 1. When project was converted successfully: + { + type: "project_conversion_status", + event_timestamp: 1234567890, + data: { + request_id: "1234567890", + project_id: "21m00Tcm4TlvDq8ikWAM", + conversion_status: "success", + project_snapshot_id: "22m00Tcm4TlvDq8ikMAT", + error_details: None, + } + } + 2. When project conversion failed: + { + type: "project_conversion_status", + event_timestamp: 1234567890, + data: { + request_id: "1234567890", + project_id: "21m00Tcm4TlvDq8ikWAM", + conversion_status: "error", + project_snapshot_id: None, + error_details: "Error details if conversion failed" + } + } + + 3. When chapter was converted successfully: + { + type: "chapter_conversion_status", + event_timestamp: 1234567890, + data: { + request_id: "1234567890", + project_id: "21m00Tcm4TlvDq8ikWAM", + chapter_id: "22m00Tcm4TlvDq8ikMAT", + conversion_status: "success", + chapter_snapshot_id: "23m00Tcm4TlvDq8ikMAV", + error_details: None, + } + } + 4. When chapter conversion failed: + { + type: "chapter_conversion_status", + event_timestamp: 1234567890, + data: { + request_id: "1234567890", + project_id: "21m00Tcm4TlvDq8ikWAM", + chapter_id: "22m00Tcm4TlvDq8ikMAT", + conversion_status: "error", + chapter_snapshot_id: None, + error_details: "Error details if conversion failed" + } + } +
@@ -3126,8 +3434,8 @@ client.text_to_voice.design(
-## user -
client.user.get() +## Dubbing +
client.dubbing.list(...)
@@ -3139,7 +3447,7 @@ client.text_to_voice.design(
-Gets information about the user +List the dubs you have access to.
@@ -3159,7 +3467,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.user.get() +client.dubbing.list() ``` @@ -3175,68 +3483,31 @@ client.user.get()
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
- -
+
+
+**page_size:** `typing.Optional[int]` — How many dubs to return at maximum. Can not exceed 200, defaults to 100. +
-
-## Voices -
client.voices.get_all(...)
-#### 📝 Description - -
-
- -
-
- -Returns a list of all available voices for a user. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.get_all() - -``` -
-
+**dubbing_status:** `typing.Optional[DubbingListRequestDubbingStatus]` — What state the dub is currently in. +
-#### ⚙️ Parameters -
-
-
- -**show_legacy:** `typing.Optional[bool]` — If set to true, legacy premade voices will be included in responses from /v1/voices +**filter_by_creator:** `typing.Optional[DubbingListRequestFilterByCreator]` — Filters who created the resources being listed, whether it was the user running the request or someone else that shared the resource with them.
@@ -3256,7 +3527,7 @@ client.voices.get_all()
-
client.voices.search(...) +
client.dubbing.create(...)
@@ -3268,7 +3539,7 @@ client.voices.get_all()
-Gets a list of all available voices for a user with search, filtering and pagination. +Dubs a provided audio or video file into given language.
@@ -3288,9 +3559,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.search( - include_total_count=True, -) +client.dubbing.create() ``` @@ -3306,7 +3575,9 @@ client.voices.search(
-**next_page_token:** `typing.Optional[str]` — The next page token to use for pagination. Returned from the previous request. +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -3314,7 +3585,9 @@ client.voices.search(
-**page_size:** `typing.Optional[int]` — How many voices to return at maximum. Can not exceed 100, defaults to 10. Page 0 may include more voices due to default voices being included. +**csv_file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -3322,7 +3595,9 @@ client.voices.search(
-**search:** `typing.Optional[str]` — Search term to filter voices by. Searches in name, description, labels, category. +**foreground_audio_file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -3330,7 +3605,9 @@ client.voices.search(
-**sort:** `typing.Optional[str]` — Which field to sort by, one of 'created_at_unix' or 'name'. 'created_at_unix' may not be available for older voices. +**background_audio_file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -3338,7 +3615,7 @@ client.voices.search(
-**sort_direction:** `typing.Optional[str]` — Which direction to sort the voices in. 'asc' or 'desc'. +**name:** `typing.Optional[str]` — Name of the dubbing project.
@@ -3346,7 +3623,7 @@ client.voices.search(
-**voice_type:** `typing.Optional[str]` — Type of the voice to filter by. One of 'personal', 'community', 'default', 'workspace', 'non-default'. 'non-default' is equal to all but 'default'. +**source_url:** `typing.Optional[str]` — URL of the source video/audio file.
@@ -3354,7 +3631,7 @@ client.voices.search(
-**category:** `typing.Optional[str]` — Category of the voice to filter by. One of 'premade', 'cloned', 'generated', 'professional' +**source_lang:** `typing.Optional[str]` — Source language.
@@ -3362,7 +3639,7 @@ client.voices.search(
-**fine_tuning_state:** `typing.Optional[str]` — State of the voice's fine tuning to filter by. Applicable only to professional voices clones. One of 'draft', 'not_verified', 'not_started', 'queued', 'fine_tuning', 'fine_tuned', 'failed', 'delayed' +**target_lang:** `typing.Optional[str]` — The Target language to dub the content into.
@@ -3370,7 +3647,7 @@ client.voices.search(
-**collection_id:** `typing.Optional[str]` — Collection ID to filter voices by. +**target_accent:** `typing.Optional[str]` — [Experimental] An accent to apply when selecting voices from the library and to use to inform translation of the dialect to prefer.
@@ -3378,7 +3655,7 @@ client.voices.search(
-**include_total_count:** `typing.Optional[bool]` — Whether to include the total count of voices found in the response. Incurs a performance cost. +**num_speakers:** `typing.Optional[int]` — Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers
@@ -3386,7 +3663,7 @@ client.voices.search(
-**voice_ids:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Voice IDs to lookup by. Maximum 100 voice IDs. +**watermark:** `typing.Optional[bool]` — Whether to apply watermark to the output video.
@@ -3394,69 +3671,31 @@ client.voices.search(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**start_time:** `typing.Optional[int]` — Start time of the source video/audio file.
- -
- - - - -
- -
client.voices.get(...) -
-
- -#### 📝 Description - -
-
-Returns metadata about a specific voice. -
-
+**end_time:** `typing.Optional[int]` — End time of the source video/audio file. +
-#### 🔌 Usage -
-
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.get( - voice_id="21m00Tcm4TlvDq8ikWAM", -) - -``` -
-
+**highest_resolution:** `typing.Optional[bool]` — Whether to use the highest resolution available. +
-#### ⚙️ Parameters -
-
-
- -**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**drop_background_audio:** `typing.Optional[bool]` — An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues.
@@ -3464,7 +3703,7 @@ client.voices.get(
-**with_settings:** `typing.Optional[bool]` — This parameter is now deprecated. It is ignored and will be removed in a future version. +**use_profanity_filter:** `typing.Optional[bool]` — [BETA] Whether transcripts should have profanities censored with the words '[censored]'
@@ -3472,69 +3711,31 @@ client.voices.get(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**dubbing_studio:** `typing.Optional[bool]` — Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource.
-
-
- - -
-
-
- -
client.voices.delete(...) -
-
- -#### 📝 Description - -
-
-Deletes a voice by its ID. -
-
+**disable_voice_cloning:** `typing.Optional[bool]` — [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. +
-#### 🔌 Usage -
-
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.delete( - voice_id="21m00Tcm4TlvDq8ikWAM", -) - -``` -
-
+**mode:** `typing.Optional[str]` — automatic or manual. Manual mode is only supported when creating a dubbing studio project +
-#### ⚙️ Parameters -
-
-
- -**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**csv_fps:** `typing.Optional[float]` — Frames per second to use when parsing a CSV file for dubbing. If not provided, FPS will be inferred from timecodes.
@@ -3554,7 +3755,7 @@ client.voices.delete(
-
client.voices.update(...) +
client.dubbing.get(...)
@@ -3566,7 +3767,7 @@ client.voices.delete(
-Edit a voice created by you. +Returns metadata about a dubbing project, including whether it's still in progress or not
@@ -3586,9 +3787,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.update( - voice_id="21m00Tcm4TlvDq8ikWAM", - name="name", +client.dubbing.get( + dubbing_id="dubbing_id", ) ``` @@ -3605,49 +3805,7 @@ client.voices.update(
-**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. - -
-
- -
-
- -**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. - -
-
- -
-
- -**files:** `from __future__ import annotations - -typing.Optional[typing.List[core.File]]` — See core.File for more documentation - -
-
- -
-
- -**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. - -
-
- -
-
- -**description:** `typing.Optional[str]` — A description of the voice. - -
-
- -
-
- -**labels:** `typing.Optional[str]` — Serialized labels dictionary for the voice. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -3667,7 +3825,7 @@ typing.Optional[typing.List[core.File]]` — See core.File for more documentatio
-
client.voices.share(...) +
client.dubbing.delete(...)
@@ -3679,7 +3837,7 @@ typing.Optional[typing.List[core.File]]` — See core.File for more documentatio
-Add a shared voice to your collection of Voices +Deletes a dubbing project.
@@ -3699,10 +3857,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.share( - public_user_id="63e06b7e7cafdc46be4d2e0b3f045940231ae058d508589653d74d1265a574ca", - voice_id="21m00Tcm4TlvDq8ikWAM", - new_name="John Smith", +client.dubbing.delete( + dubbing_id="dubbing_id", ) ``` @@ -3715,554 +3871,11 @@ client.voices.share(
- -
-
- -**public_user_id:** `str` — Public user ID used to publicly identify ElevenLabs users. - -
-
- -
-
- -**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. - -
-
- -
-
- -**new_name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- - - -
-
- -
client.voices.get_shared(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieves a list of shared voices. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.get_shared( - featured=True, - reader_app_enabled=True, -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**page_size:** `typing.Optional[int]` — How many shared voices to return at maximum. Can not exceed 100, defaults to 30. - -
-
- -
-
- -**category:** `typing.Optional[VoicesGetSharedRequestCategory]` — Voice category used for filtering - -
-
- -
-
- -**gender:** `typing.Optional[str]` — Gender used for filtering - -
-
- -
-
- -**age:** `typing.Optional[str]` — Age used for filtering - -
-
- -
-
- -**accent:** `typing.Optional[str]` — Accent used for filtering - -
-
- -
-
- -**language:** `typing.Optional[str]` — Language used for filtering - -
-
- -
-
- -**locale:** `typing.Optional[str]` — Locale used for filtering - -
-
- -
-
- -**search:** `typing.Optional[str]` — Search term used for filtering - -
-
- -
-
- -**use_cases:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Use-case used for filtering - -
-
- -
-
- -**descriptives:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Search term used for filtering - -
-
- -
-
- -**featured:** `typing.Optional[bool]` — Filter featured voices - -
-
- -
-
- -**min_notice_period_days:** `typing.Optional[int]` — Filter voices with a minimum notice period of the given number of days. - -
-
- -
-
- -**include_custom_rates:** `typing.Optional[bool]` — Include/exclude voices with custom rates - -
-
- -
-
- -**include_live_moderated:** `typing.Optional[bool]` — Include/exclude voices that are live moderated - -
-
- -
-
- -**reader_app_enabled:** `typing.Optional[bool]` — Filter voices that are enabled for the reader app - -
-
- -
-
- -**owner_id:** `typing.Optional[str]` — Filter voices by public owner ID - -
-
- -
-
- -**sort:** `typing.Optional[str]` — Sort criteria - -
-
- -
-
- -**page:** `typing.Optional[int]` - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- - -
-
-
- -
client.voices.find_similar_voices(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Returns a list of shared voices similar to the provided audio sample. If neither similarity_threshold nor top_k is provided, we will apply default values. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.find_similar_voices() - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**audio_file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation - -
-
- -
-
- -**similarity_threshold:** `typing.Optional[float]` — Threshold for voice similarity between provided sample and library voices. Values range from 0 to 2. The smaller the value the more similar voices will be returned. - -
-
- -
-
- -**top_k:** `typing.Optional[int]` — Number of most similar voices to return. If similarity_threshold is provided, less than this number of voices may be returned. Values range from 1 to 100. - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- - -
-
-
- -## Studio -
client.studio.create_podcast(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Create and auto-convert a podcast project. Currently, the LLM cost is covered by us but you will still be charged for the audio generation. In the future, you will be charged for both the LLM and audio generation costs. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ( - ElevenLabs, - PodcastConversationModeData, - PodcastTextSource, -) -from elevenlabs.studio import ( - BodyCreatePodcastV1StudioPodcastsPostMode_Conversation, -) - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.studio.create_podcast( - model_id="eleven_multilingual_v2", - mode=BodyCreatePodcastV1StudioPodcastsPostMode_Conversation( - conversation=PodcastConversationModeData( - host_voice_id="aw1NgEzBg83R7vgmiJt6", - guest_voice_id="aw1NgEzBg83R7vgmiJt7", - ), - ), - source=PodcastTextSource( - text="This is a test podcast.", - ), -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**model_id:** `str` — The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. - -
-
- -
-
- -**mode:** `BodyCreatePodcastV1StudioPodcastsPostMode` — The type of podcast to generate. Can be 'conversation', an interaction between two voices, or 'bulletin', a monologue. - -
-
- -
-
- -**source:** `BodyCreatePodcastV1StudioPodcastsPostSource` — The source content for the Podcast. - -
-
- -
-
- -**quality_preset:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset]` - -Output quality of the generated audio. Must be one of: -standard - standard output format, 128kbps with 44.1kHz sample rate. -high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. -ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. -ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. - -
-
- -
-
- -**duration_scale:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale]` - -Duration of the generated podcast. Must be one of: -short - produces podcasts shorter than 3 minutes. -default - produces podcasts roughly between 3-7 minutes. -long - produces podcasts longer than 7 minutes. - -
-
- -
-
- -**language:** `typing.Optional[str]` — An optional language of the Studio project. Two-letter language code (ISO 639-1). - -
-
- -
-
- -**intro:** `typing.Optional[str]` — The intro text that will always be added to the beginning of the podcast. - -
-
- -
-
- -**outro:** `typing.Optional[str]` — The outro text that will always be added to the end of the podcast. - -
-
- -
-
- -**instructions_prompt:** `typing.Optional[str]` — Additional instructions prompt for the podcast generation used to adjust the podcast's style and tone. - -
-
- -
-
- -**highlights:** `typing.Optional[typing.Sequence[str]]` — A brief summary or highlights of the Studio project's content, providing key points or themes. This should be between 10 and 70 characters. - -
-
- -
-
- -**callback_url:** `typing.Optional[str]` - - - A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion - Messages: - 1. When project was converted successfully: - { - type: "project_conversion_status", - event_timestamp: 1234567890, - data: { - request_id: "1234567890", - project_id: "21m00Tcm4TlvDq8ikWAM", - conversion_status: "success", - project_snapshot_id: "22m00Tcm4TlvDq8ikMAT", - error_details: None, - } - } - 2. When project conversion failed: - { - type: "project_conversion_status", - event_timestamp: 1234567890, - data: { - request_id: "1234567890", - project_id: "21m00Tcm4TlvDq8ikWAM", - conversion_status: "error", - project_snapshot_id: None, - error_details: "Error details if conversion failed" - } - } - - 3. When chapter was converted successfully: - { - type: "chapter_conversion_status", - event_timestamp: 1234567890, - data: { - request_id: "1234567890", - project_id: "21m00Tcm4TlvDq8ikWAM", - chapter_id: "22m00Tcm4TlvDq8ikMAT", - conversion_status: "success", - chapter_snapshot_id: "23m00Tcm4TlvDq8ikMAV", - error_details: None, - } - } - 4. When chapter conversion failed: - { - type: "chapter_conversion_status", - event_timestamp: 1234567890, - data: { - request_id: "1234567890", - project_id: "21m00Tcm4TlvDq8ikWAM", - chapter_id: "22m00Tcm4TlvDq8ikMAT", - conversion_status: "error", - chapter_snapshot_id: None, - error_details: "Error details if conversion failed" - } - } - + +
+
+ +**dubbing_id:** `str` — ID of the dubbing project.
@@ -4282,8 +3895,8 @@ long - produces podcasts longer than 7 minutes.
-## Dubbing -
client.dubbing.list(...) +## Models +
client.models.list()
@@ -4295,7 +3908,7 @@ long - produces podcasts longer than 7 minutes.
-List the dubs you have access to. +Gets a list of available models.
@@ -4315,7 +3928,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.list() +client.models.list() ``` @@ -4331,38 +3944,6 @@ client.dubbing.list()
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. - -
-
- -
-
- -**page_size:** `typing.Optional[int]` — How many dubs to return at maximum. Can not exceed 200, defaults to 100. - -
-
- -
-
- -**dubbing_status:** `typing.Optional[DubbingListRequestDubbingStatus]` — What state the dub is currently in. - -
-
- -
-
- -**filter_by_creator:** `typing.Optional[DubbingListRequestFilterByCreator]` — Filters who created the resources being listed, whether it was the user running the request or someone else that shared the resource with them. - -
-
- -
-
- **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -4375,7 +3956,8 @@ client.dubbing.list()
-
client.dubbing.create(...) +## AudioNative +
client.audio_native.create(...)
@@ -4387,7 +3969,7 @@ client.dubbing.list()
-Dubs a provided audio or video file into given language. +Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet.
@@ -4407,7 +3989,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.create() +client.audio_native.create( + name="name", +) ``` @@ -4423,9 +4007,7 @@ client.dubbing.create()
-**file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**name:** `str` — Project name.
@@ -4433,9 +4015,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**csv_file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**image:** `typing.Optional[str]` — (Deprecated) Image URL used in the player. If not provided, default image set in the Player settings is used.
@@ -4443,9 +4023,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**foreground_audio_file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**author:** `typing.Optional[str]` — Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used.
@@ -4453,9 +4031,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**background_audio_file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**title:** `typing.Optional[str]` — Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used.
@@ -4463,7 +4039,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**name:** `typing.Optional[str]` — Name of the dubbing project. +**small:** `typing.Optional[bool]` — (Deprecated) Whether to use small player or not. If not provided, default value set in the Player settings is used.
@@ -4471,7 +4047,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**source_url:** `typing.Optional[str]` — URL of the source video/audio file. +**text_color:** `typing.Optional[str]` — Text color used in the player. If not provided, default text color set in the Player settings is used.
@@ -4479,7 +4055,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**source_lang:** `typing.Optional[str]` — Source language. +**background_color:** `typing.Optional[str]` — Background color used in the player. If not provided, default background color set in the Player settings is used.
@@ -4487,7 +4063,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**target_lang:** `typing.Optional[str]` — The Target language to dub the content into. +**sessionization:** `typing.Optional[int]` — (Deprecated) Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used.
@@ -4495,7 +4071,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**target_accent:** `typing.Optional[str]` — [Experimental] An accent to apply when selecting voices from the library and to use to inform translation of the dialect to prefer. +**voice_id:** `typing.Optional[str]` — Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used.
@@ -4503,7 +4079,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**num_speakers:** `typing.Optional[int]` — Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers +**model_id:** `typing.Optional[str]` — TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used.
@@ -4511,7 +4087,9 @@ typing.Optional[core.File]` — See core.File for more documentation
-**watermark:** `typing.Optional[bool]` — Whether to apply watermark to the output video. +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -4519,7 +4097,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**start_time:** `typing.Optional[int]` — Start time of the source video/audio file. +**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not.
@@ -4527,23 +4105,69 @@ typing.Optional[core.File]` — See core.File for more documentation
-**end_time:** `typing.Optional[int]` — End time of the source video/audio file. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
+ + + + +
+
client.audio_native.get_settings(...)
-**highest_resolution:** `typing.Optional[bool]` — Whether to use the highest resolution available. - +#### 📝 Description + +
+
+ +
+
+ +Get player settings for the specific project. +
+
+#### 🔌 Usage +
-**drop_background_audio:** `typing.Optional[bool]` — An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues. +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.audio_native.get_settings( + project_id="21m00Tcm4TlvDq8ikWAM", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**project_id:** `str` — The ID of the Studio project.
@@ -4551,15 +4175,69 @@ typing.Optional[core.File]` — See core.File for more documentation
-**use_profanity_filter:** `typing.Optional[bool]` — [BETA] Whether transcripts should have profanities censored with the words '[censored]' +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+
+
+ + +
+
+
+ +
client.audio_native.update(...) +
+
+ +#### 📝 Description
-**dubbing_studio:** `typing.Optional[bool]` — Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource. +
+
+ +Updates content for the specific AudioNative Project. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.audio_native.update( + project_id="21m00Tcm4TlvDq8ikWAM", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -4567,7 +4245,9 @@ typing.Optional[core.File]` — See core.File for more documentation
-**disable_voice_cloning:** `typing.Optional[bool]` — [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -4575,7 +4255,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**mode:** `typing.Optional[str]` — automatic or manual. Manual mode is only supported when creating a dubbing studio project +**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not.
@@ -4583,7 +4263,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**csv_fps:** `typing.Optional[float]` — Frames per second to use when parsing a CSV file for dubbing. If not provided, FPS will be inferred from timecodes. +**auto_publish:** `typing.Optional[bool]` — Whether to auto publish the new project snapshot after it's converted.
@@ -4603,7 +4283,8 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.dubbing.get(...) +## usage +
client.usage.get(...)
@@ -4615,7 +4296,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Returns metadata about a dubbing project, including whether it's still in progress or not +Returns the usage metrics for the current user or the entire workspace they are part of. The response provides a time axis based on the specified aggregation interval (default: day), with usage values for each interval along that axis. Usage is broken down by the selected breakdown type. For example, breakdown type "voice" will return the usage of each voice for each interval along the time axis.
@@ -4635,25 +4316,74 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.get( - dubbing_id="dubbing_id", +client.usage.get( + start_unix=1, + end_unix=1, ) -``` +``` + +
+ + + +#### ⚙️ Parameters + +
+
+ +
+
+ +**start_unix:** `int` — UTC Unix timestamp for the start of the usage window, in milliseconds. To include the first day of the window, the timestamp should be at 00:00:00 of that day. + +
+
+ +
+
+ +**end_unix:** `int` — UTC Unix timestamp for the end of the usage window, in milliseconds. To include the last day of the window, the timestamp should be at 23:59:59 of that day. + +
+
+ +
+
+ +**include_workspace_metrics:** `typing.Optional[bool]` — Whether or not to include the statistics of the entire workspace. + +
+
+ +
+
+ +**breakdown_type:** `typing.Optional[BreakdownTypes]` — How to break down the information. Cannot be "user" if include_workspace_metrics is False. +
+ +
+
+ +**aggregation_interval:** `typing.Optional[UsageAggregationInterval]` — How to aggregate usage data over time. Can be "hour", "day", "week", "month", or "cumulative". +
-#### ⚙️ Parameters -
+**aggregation_bucket_size:** `typing.Optional[int]` — Aggregation bucket size in seconds. Overrides the aggregation interval. + +
+
+
-**dubbing_id:** `str` — ID of the dubbing project. +**metric:** `typing.Optional[MetricType]` — Which metric to aggregate.
@@ -4673,7 +4403,8 @@ client.dubbing.get(
-
client.dubbing.delete(...) +## PronunciationDictionaries +
client.pronunciation_dictionaries.create_from_file(...)
@@ -4685,7 +4416,7 @@ client.dubbing.get(
-Deletes a dubbing project. +Creates a new pronunciation dictionary from a lexicon .PLS file
@@ -4705,8 +4436,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.delete( - dubbing_id="dubbing_id", +client.pronunciation_dictionaries.create_from_file( + name="name", ) ``` @@ -4723,7 +4454,7 @@ client.dubbing.delete(
-**dubbing_id:** `str` — ID of the dubbing project. +**name:** `str` — The name of the pronunciation dictionary, used for identification only.
@@ -4731,64 +4462,29 @@ client.dubbing.delete(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
- -
- +**file:** `from __future__ import annotations +typing.Optional[core.File]` — See core.File for more documentation + -
- -## Models -
client.models.list() -
-
- -#### 📝 Description - -
-
-Gets a list of available models. -
-
+**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only. +
-#### 🔌 Usage - -
-
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.models.list() - -``` -
-
+**workspace_access:** `typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. +
-#### ⚙️ Parameters - -
-
-
@@ -4804,8 +4500,7 @@ client.models.list()
-## AudioNative -
client.audio_native.create(...) +
client.pronunciation_dictionaries.create_from_rules(...)
@@ -4817,7 +4512,7 @@ client.models.list()
-Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet. +Creates a new pronunciation dictionary from provided rules.
@@ -4833,12 +4528,21 @@ Creates Audio Native enabled project, optionally starts conversion and returns p ```python from elevenlabs import ElevenLabs +from elevenlabs.pronunciation_dictionaries import ( + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.audio_native.create( - name="name", +client.pronunciation_dictionaries.create_from_rules( + rules=[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( + string_to_replace="Thailand", + alias="tie-land", + ) + ], + name="My Dictionary", ) ``` @@ -4855,7 +4559,13 @@ client.audio_native.create(
-**name:** `str` — Project name. +**rules:** `typing.Sequence[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem +]` + +List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' }
@@ -4863,7 +4573,7 @@ client.audio_native.create(
-**image:** `typing.Optional[str]` — (Deprecated) Image URL used in the player. If not provided, default image set in the Player settings is used. +**name:** `str` — The name of the pronunciation dictionary, used for identification only.
@@ -4871,7 +4581,7 @@ client.audio_native.create(
-**author:** `typing.Optional[str]` — Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used. +**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only.
@@ -4879,7 +4589,9 @@ client.audio_native.create(
-**title:** `typing.Optional[str]` — Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used. +**workspace_access:** `typing.Optional[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess +]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access.
@@ -4887,65 +4599,69 @@ client.audio_native.create(
-**small:** `typing.Optional[bool]` — (Deprecated) Whether to use small player or not. If not provided, default value set in the Player settings is used. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
-
-
-**text_color:** `typing.Optional[str]` — Text color used in the player. If not provided, default text color set in the Player settings is used. -
+
+
client.pronunciation_dictionaries.get(...)
-**background_color:** `typing.Optional[str]` — Background color used in the player. If not provided, default background color set in the Player settings is used. - -
-
+#### 📝 Description
-**sessionization:** `typing.Optional[int]` — (Deprecated) Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used. - -
-
-
-**voice_id:** `typing.Optional[str]` — Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used. - +Get metadata for a pronunciation dictionary +
+
+#### 🔌 Usage +
-**model_id:** `typing.Optional[str]` — TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used. - -
-
-
-**file:** `from __future__ import annotations +```python +from elevenlabs import ElevenLabs -typing.Optional[core.File]` — See core.File for more documentation - +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.pronunciation_dictionaries.get( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", +) + +``` +
+
+#### ⚙️ Parameters +
-**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not. +
+
+ +**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary
@@ -4965,7 +4681,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.audio_native.get_settings(...) +
client.pronunciation_dictionaries.update(...)
@@ -4977,7 +4693,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Get player settings for the specific project. +Partially update the pronunciation dictionary without changing the version
@@ -4997,8 +4713,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.audio_native.get_settings( - project_id="21m00Tcm4TlvDq8ikWAM", +client.pronunciation_dictionaries.update( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -5015,7 +4731,23 @@ client.audio_native.get_settings(
-**project_id:** `str` — The ID of the Studio project. +**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary + +
+
+ +
+
+ +**archived:** `typing.Optional[bool]` — The name of the pronunciation dictionary, used for identification only. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — The name of the pronunciation dictionary, used for identification only.
@@ -5035,7 +4767,7 @@ client.audio_native.get_settings(
-
client.audio_native.update(...) +
client.pronunciation_dictionaries.list(...)
@@ -5047,7 +4779,7 @@ client.audio_native.get_settings(
-Updates content for the specific AudioNative Project. +Get a list of the pronunciation dictionaries you have access to and their metadata
@@ -5067,9 +4799,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.audio_native.update( - project_id="21m00Tcm4TlvDq8ikWAM", -) +client.pronunciation_dictionaries.list() ``` @@ -5085,7 +4815,7 @@ client.audio_native.update(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -5093,9 +4823,7 @@ client.audio_native.update(
-**file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**page_size:** `typing.Optional[int]` — How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30.
@@ -5103,7 +4831,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not. +**sort:** `typing.Optional[PronunciationDictionariesListRequestSort]` — Which field to sort by, one of 'created_at_unix' or 'name'.
@@ -5111,7 +4839,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**auto_publish:** `typing.Optional[bool]` — Whether to auto publish the new project snapshot after it's converted. +**sort_direction:** `typing.Optional[str]` — Which direction to sort the voices in. 'ascending' or 'descending'.
@@ -5131,8 +4859,8 @@ typing.Optional[core.File]` — See core.File for more documentation
-## usage -
client.usage.get(...) +## ServiceAccounts +
client.service_accounts.list()
@@ -5144,7 +4872,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Returns the usage metrics for the current user or the entire workspace they are part of. The response provides a time axis based on the specified aggregation interval (default: day), with usage values for each interval along that axis. Usage is broken down by the selected breakdown type. For example, breakdown type "voice" will return the usage of each voice for each interval along the time axis. +List all service accounts in the workspace
@@ -5164,10 +4892,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.usage.get( - start_unix=1, - end_unix=1, -) +client.service_accounts.list() ``` @@ -5183,55 +4908,70 @@ client.usage.get(
-**start_unix:** `int` — UTC Unix timestamp for the start of the usage window, in milliseconds. To include the first day of the window, the timestamp should be at 00:00:00 of that day. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
-
-
-**end_unix:** `int` — UTC Unix timestamp for the end of the usage window, in milliseconds. To include the last day of the window, the timestamp should be at 23:59:59 of that day. -
+
+ +## Webhooks +
client.webhooks.list(...) +
+
+ +#### 📝 Description
-**include_workspace_metrics:** `typing.Optional[bool]` — Whether or not to include the statistics of the entire workspace. - +
+
+ +List all webhooks for a workspace +
+
+#### 🔌 Usage + +
+
+
-**breakdown_type:** `typing.Optional[BreakdownTypes]` — How to break down the information. Cannot be "user" if include_workspace_metrics is False. - +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.webhooks.list( + include_usages=False, +) + +```
- -
-
- -**aggregation_interval:** `typing.Optional[UsageAggregationInterval]` — How to aggregate usage data over time. Can be "hour", "day", "week", "month", or "cumulative". -
+#### ⚙️ Parameters +
-**aggregation_bucket_size:** `typing.Optional[int]` — Aggregation bucket size in seconds. Overrides the aggregation interval. - -
-
-
-**metric:** `typing.Optional[MetricType]` — Which metric to aggregate. +**include_usages:** `typing.Optional[bool]` — Whether to include active usages of the webhook, only usable by admins
@@ -5251,8 +4991,8 @@ client.usage.get(
-## PronunciationDictionaries -
client.pronunciation_dictionaries.create_from_file(...) +## SpeechToText +
client.speech_to_text.convert(...)
@@ -5264,7 +5004,7 @@ client.usage.get(
-Creates a new pronunciation dictionary from a lexicon .PLS file +Transcribe an audio or video file. If webhook is set to true, the request will be processed asynchronously and results sent to configured webhooks. When use_multi_channel is true and the provided audio has multiple channels, a 'transcripts' object with separate transcripts for each channel is returned. Otherwise, returns a single transcript. The optional webhook_metadata parameter allows you to attach custom data that will be included in webhook responses for request correlation and tracking.
@@ -5284,8 +5024,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionaries.create_from_file( - name="name", +client.speech_to_text.convert( + model_id="model_id", ) ``` @@ -5302,7 +5042,15 @@ client.pronunciation_dictionaries.create_from_file(
-**name:** `str` — The name of the pronunciation dictionary, used for identification only. +**model_id:** `str` — The ID of the model to use for transcription, currently only 'scribe_v1' and 'scribe_v1_experimental' are available. + +
+
+ +
+
+ +**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.
@@ -5320,7 +5068,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only. +**language_code:** `typing.Optional[str]` — An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically.
@@ -5328,7 +5076,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**workspace_access:** `typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. +**tag_audio_events:** `typing.Optional[bool]` — Whether to tag audio events like (laughter), (footsteps), etc. in the transcription.
@@ -5336,84 +5084,79 @@ typing.Optional[core.File]` — See core.File for more documentation
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**num_speakers:** `typing.Optional[int]` — The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports.
- -
+
+
+**timestamps_granularity:** `typing.Optional[SpeechToTextConvertRequestTimestampsGranularity]` — The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word. +
-
-
client.pronunciation_dictionaries.create_from_rules(...)
-#### 📝 Description +**diarize:** `typing.Optional[bool]` — Whether to annotate which speaker is currently talking in the uploaded file. + +
+
+**diarization_threshold:** `typing.Optional[float]` — Diarization threshold to apply during speaker diarization. A higher value means there will be a lower chance of one speaker being diarized as two different speakers but also a higher chance of two different speakers being diarized as one speaker (less total speakers predicted). A low value means there will be a higher chance of one speaker being diarized as two different speakers but also a lower chance of two different speakers being diarized as one speaker (more total speakers predicted). Can only be set when diarize=True and num_speakers=None. Defaults to None, in which case we will choose a threshold based on the model_id (0.22 usually). + +
+
+
-Creates a new pronunciation dictionary from provided rules. -
-
+**additional_formats:** `typing.Optional[AdditionalFormats]` — A list of additional formats to export the transcript to. + -#### 🔌 Usage -
+**file_format:** `typing.Optional[SpeechToTextConvertRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + +
+
+
-```python -from elevenlabs import ElevenLabs -from elevenlabs.pronunciation_dictionaries import ( - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, -) - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.pronunciation_dictionaries.create_from_rules( - rules=[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( - string_to_replace="Thailand", - alias="tie-land", - ) - ], - name="My Dictionary", -) - -``` +**cloud_storage_url:** `typing.Optional[str]` — The HTTPS URL of the file to transcribe. Exactly one of the file or cloud_storage_url parameters must be provided. The file must be accessible via HTTPS and the file size must be less than 2GB. Any valid HTTPS URL is accepted, including URLs from cloud storage providers (AWS S3, Google Cloud Storage, Cloudflare R2, etc.), CDNs, or any other HTTPS source. URLs can be pre-signed or include authentication tokens in query parameters. +
+ +
+
+ +**webhook:** `typing.Optional[bool]` — Whether to send the transcription result to configured speech-to-text webhooks. If set the request will return early without the transcription, which will be delivered later via webhook. +
-#### ⚙️ Parameters -
+**webhook_id:** `typing.Optional[str]` — Optional specific webhook ID to send the transcription result to. Only valid when webhook is set to true. If not provided, transcription will be sent to all configured speech-to-text webhooks. + +
+
+
-**rules:** `typing.Sequence[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem -]` - -List of pronunciation rules. Rule can be either: - an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } - or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } +**temperature:** `typing.Optional[float]` — Controls the randomness of the transcription output. Accepts values between 0.0 and 2.0, where higher values result in more diverse and less deterministic results. If omitted, we will use a temperature based on the model you selected which is usually 0.
@@ -5421,7 +5164,7 @@ List of pronunciation rules. Rule can be either:
-**name:** `str` — The name of the pronunciation dictionary, used for identification only. +**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be an integer between 0 and 2147483647.
@@ -5429,7 +5172,7 @@ List of pronunciation rules. Rule can be either:
-**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only. +**use_multi_channel:** `typing.Optional[bool]` — Whether the audio file contains multiple channels where each channel contains a single speaker. When enabled, each channel will be transcribed independently and the results will be combined. Each word in the response will include a 'channel_index' field indicating which channel it was spoken on. A maximum of 5 channels is supported.
@@ -5437,9 +5180,7 @@ List of pronunciation rules. Rule can be either:
-**workspace_access:** `typing.Optional[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess -]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. +**webhook_metadata:** `typing.Optional[SpeechToTextConvertRequestWebhookMetadata]` — Optional metadata to be included in the webhook response. This should be a JSON string representing an object with a maximum depth of 2 levels and maximum size of 16KB. Useful for tracking internal IDs, job references, or other contextual information.
@@ -5459,7 +5200,8 @@ List of pronunciation rules. Rule can be either:
-
client.pronunciation_dictionaries.get(...) +## ForcedAlignment +
client.forced_alignment.create(...)
@@ -5471,7 +5213,7 @@ List of pronunciation rules. Rule can be either:
-Get metadata for a pronunciation dictionary +Force align an audio file to text. Use this endpoint to get the timing information for each character and word in an audio file based on a provided text transcript.
@@ -5491,8 +5233,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionaries.get( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", +client.forced_alignment.create( + text="text", ) ``` @@ -5509,7 +5251,25 @@ client.pronunciation_dictionaries.get(
-**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary +**file:** `from __future__ import annotations + +core.File` — See core.File for more documentation + +
+
+ +
+
+ +**text:** `str` — The text to align with the audio. The input text can be in any format, however diarization is not supported at this time. + +
+
+ +
+
+ +**enabled_spooled_file:** `typing.Optional[bool]` — If true, the file will be streamed to the server and processed in chunks. This is useful for large files that cannot be loaded into memory. The default is false.
@@ -5529,7 +5289,8 @@ client.pronunciation_dictionaries.get(
-
client.pronunciation_dictionaries.update(...) +## ConversationalAi +
client.conversational_ai.add_to_knowledge_base(...)
@@ -5541,7 +5302,7 @@ client.pronunciation_dictionaries.get(
-Partially update the pronunciation dictionary without changing the version +Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/api-reference/agents/update).
@@ -5561,9 +5322,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionaries.update( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", -) +client.conversational_ai.add_to_knowledge_base() ``` @@ -5579,7 +5338,7 @@ client.pronunciation_dictionaries.update(
-**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary +**agent_id:** `typing.Optional[str]`
@@ -5587,7 +5346,7 @@ client.pronunciation_dictionaries.update(
-**archived:** `typing.Optional[bool]` — The name of the pronunciation dictionary, used for identification only. +**name:** `typing.Optional[str]` — A custom, human-readable name for the document.
@@ -5595,7 +5354,17 @@ client.pronunciation_dictionaries.update(
-**name:** `typing.Optional[str]` — The name of the pronunciation dictionary, used for identification only. +**url:** `typing.Optional[str]` — URL to a page of documentation that the agent will have access to in order to interact with users. + +
+
+ +
+
+ +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -5615,7 +5384,7 @@ client.pronunciation_dictionaries.update(
-
client.pronunciation_dictionaries.list(...) +
client.conversational_ai.get_document_rag_indexes(...)
@@ -5627,7 +5396,7 @@ client.pronunciation_dictionaries.update(
-Get a list of the pronunciation dictionaries you have access to and their metadata +Provides information about all RAG indexes of the specified knowledgebase document.
@@ -5647,7 +5416,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionaries.list() +client.conversational_ai.get_document_rag_indexes( + documentation_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -5663,31 +5434,7 @@ client.pronunciation_dictionaries.list()
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. - -
-
- -
-
- -**page_size:** `typing.Optional[int]` — How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30. - -
-
- -
-
- -**sort:** `typing.Optional[PronunciationDictionariesListRequestSort]` — Which field to sort by, one of 'created_at_unix' or 'name'. - -
-
- -
-
- -**sort_direction:** `typing.Optional[str]` — Which direction to sort the voices in. 'ascending' or 'descending'. +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition.
@@ -5707,8 +5454,7 @@ client.pronunciation_dictionaries.list()
-## ServiceAccounts -
client.service_accounts.list() +
client.conversational_ai.delete_document_rag_index(...)
@@ -5720,7 +5466,7 @@ client.pronunciation_dictionaries.list()
-List all service accounts in the workspace +Delete RAG index for the knowledgebase document.
@@ -5740,7 +5486,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.service_accounts.list() +client.conversational_ai.delete_document_rag_index( + documentation_id="21m00Tcm4TlvDq8ikWAM", + rag_index_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -5756,6 +5505,22 @@ client.service_accounts.list()
+**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. + +
+
+ +
+
+ +**rag_index_id:** `str` — The id of RAG index of document from the knowledge base. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -5768,8 +5533,7 @@ client.service_accounts.list()
-## Webhooks -
client.webhooks.list(...) +
client.conversational_ai.rag_index_overview()
@@ -5781,7 +5545,7 @@ client.service_accounts.list()
-List all webhooks for a workspace +Provides total size and other information of RAG indexes used by knowledgebase documents
@@ -5801,9 +5565,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.webhooks.list( - include_usages=False, -) +client.conversational_ai.rag_index_overview() ``` @@ -5811,19 +5573,11 @@ client.webhooks.list(
-#### ⚙️ Parameters - -
-
+#### ⚙️ Parameters
-**include_usages:** `typing.Optional[bool]` — Whether to include active usages of the webhook, only usable by admins - -
-
-
@@ -5839,8 +5593,7 @@ client.webhooks.list(
-## SpeechToText -
client.speech_to_text.convert(...) +
client.conversational_ai.update_secret(...)
@@ -5852,7 +5605,7 @@ client.webhooks.list(
-Transcribe an audio or video file. If webhook is set to true, the request will be processed asynchronously and results sent to configured webhooks. When use_multi_channel is true and the provided audio has multiple channels, a 'transcripts' object with separate transcripts for each channel is returned. Otherwise, returns a single transcript. The optional webhook_metadata parameter allows you to attach custom data that will be included in webhook responses for request correlation and tracking. +Update an existing secret for the workspace
@@ -5872,8 +5625,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.speech_to_text.convert( - model_id="model_id", +client.conversational_ai.update_secret( + secret_id="secret_id", + name="name", + value="value", ) ``` @@ -5890,7 +5645,7 @@ client.speech_to_text.convert(
-**model_id:** `str` — The ID of the model to use for transcription, currently only 'scribe_v1' and 'scribe_v1_experimental' are available. +**secret_id:** `str`
@@ -5898,7 +5653,7 @@ client.speech_to_text.convert(
-**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +**name:** `str`
@@ -5906,9 +5661,7 @@ client.speech_to_text.convert(
-**file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**value:** `str`
@@ -5916,119 +5669,71 @@ typing.Optional[core.File]` — See core.File for more documentation
-**language_code:** `typing.Optional[str]` — An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
- -
-
- -**tag_audio_events:** `typing.Optional[bool]` — Whether to tag audio events like (laughter), (footsteps), etc. in the transcription. -
-
-
-**num_speakers:** `typing.Optional[int]` — The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports. -
+
+## Music +## ConversationalAi Conversations +
client.conversational_ai.conversations.get_signed_url(...)
-**timestamps_granularity:** `typing.Optional[SpeechToTextConvertRequestTimestampsGranularity]` — The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word. - -
-
+#### 📝 Description
-**diarize:** `typing.Optional[bool]` — Whether to annotate which speaker is currently talking in the uploaded file. - -
-
-
-**diarization_threshold:** `typing.Optional[float]` — Diarization threshold to apply during speaker diarization. A higher value means there will be a lower chance of one speaker being diarized as two different speakers but also a higher chance of two different speakers being diarized as one speaker (less total speakers predicted). A low value means there will be a higher chance of one speaker being diarized as two different speakers but also a lower chance of two different speakers being diarized as one speaker (more total speakers predicted). Can only be set when diarize=True and num_speakers=None. Defaults to None, in which case we will choose a threshold based on the model_id (0.22 usually). - +Get a signed url to start a conversation with an agent with an agent that requires authorization
- -
-
- -**additional_formats:** `typing.Optional[AdditionalFormats]` — A list of additional formats to export the transcript to. -
-
-
- -**file_format:** `typing.Optional[SpeechToTextConvertRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. - -
-
+#### 🔌 Usage
-**cloud_storage_url:** `typing.Optional[str]` — The HTTPS URL of the file to transcribe. Exactly one of the file or cloud_storage_url parameters must be provided. The file must be accessible via HTTPS and the file size must be less than 2GB. Any valid HTTPS URL is accepted, including URLs from cloud storage providers (AWS S3, Google Cloud Storage, Cloudflare R2, etc.), CDNs, or any other HTTPS source. URLs can be pre-signed or include authentication tokens in query parameters. - -
-
-
-**webhook:** `typing.Optional[bool]` — Whether to send the transcription result to configured speech-to-text webhooks. If set the request will return early without the transcription, which will be delivered later via webhook. - -
-
+```python +from elevenlabs import ElevenLabs -
-
+client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.conversations.get_signed_url( + agent_id="21m00Tcm4TlvDq8ikWAM", +) -**webhook_id:** `typing.Optional[str]` — Optional specific webhook ID to send the transcription result to. Only valid when webhook is set to true. If not provided, transcription will be sent to all configured speech-to-text webhooks. - +```
- -
-
- -**temperature:** `typing.Optional[float]` — Controls the randomness of the transcription output. Accepts values between 0.0 and 2.0, where higher values result in more diverse and less deterministic results. If omitted, we will use a temperature based on the model you selected which is usually 0. -
-
-
- -**seed:** `typing.Optional[int]` — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be an integer between 0 and 2147483647. - -
-
+#### ⚙️ Parameters
-**use_multi_channel:** `typing.Optional[bool]` — Whether the audio file contains multiple channels where each channel contains a single speaker. When enabled, each channel will be transcribed independently and the results will be combined. Each word in the response will include a 'channel_index' field indicating which channel it was spoken on. A maximum of 5 channels is supported. - -
-
-
-**webhook_metadata:** `typing.Optional[SpeechToTextConvertRequestWebhookMetadata]` — Optional metadata to be included in the webhook response. This should be a JSON string representing an object with a maximum depth of 2 levels and maximum size of 16KB. Useful for tracking internal IDs, job references, or other contextual information. +**agent_id:** `str` — The id of the agent you're taking the action on.
@@ -6048,8 +5753,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-## ForcedAlignment -
client.forced_alignment.create(...) +
client.conversational_ai.conversations.get_webrtc_token(...)
@@ -6061,7 +5765,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Force align an audio file to text. Use this endpoint to get the timing information for each character and word in an audio file based on a provided text transcript. +Get a WebRTC session token for real-time communication.
@@ -6081,8 +5785,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.forced_alignment.create( - text="text", +client.conversational_ai.conversations.get_webrtc_token( + agent_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -6099,17 +5803,7 @@ client.forced_alignment.create(
-**file:** `from __future__ import annotations - -core.File` — See core.File for more documentation - -
-
- -
-
- -**text:** `str` — The text to align with the audio. The input text can be in any format, however diarization is not supported at this time. +**agent_id:** `str` — The id of the agent you're taking the action on.
@@ -6117,7 +5811,7 @@ core.File` — See core.File for more documentation
-**enabled_spooled_file:** `typing.Optional[bool]` — If true, the file will be streamed to the server and processed in chunks. This is useful for large files that cannot be loaded into memory. The default is false. +**participant_name:** `typing.Optional[str]` — Optional custom participant name. If not provided, user ID will be used
@@ -6137,8 +5831,7 @@ core.File` — See core.File for more documentation
-## ConversationalAi -
client.conversational_ai.add_to_knowledge_base(...) +
client.conversational_ai.conversations.list(...)
@@ -6150,7 +5843,7 @@ core.File` — See core.File for more documentation
-Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/api-reference/agents/update). +Get all conversations of agents that user owns. With option to restrict to a specific agent.
@@ -6170,7 +5863,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.add_to_knowledge_base() +client.conversational_ai.conversations.list() ``` @@ -6186,7 +5879,7 @@ client.conversational_ai.add_to_knowledge_base()
-**agent_id:** `typing.Optional[str]` +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -6194,7 +5887,7 @@ client.conversational_ai.add_to_knowledge_base()
-**name:** `typing.Optional[str]` — A custom, human-readable name for the document. +**agent_id:** `typing.Optional[str]` — The id of the agent you're taking the action on.
@@ -6202,7 +5895,7 @@ client.conversational_ai.add_to_knowledge_base()
-**url:** `typing.Optional[str]` — URL to a page of documentation that the agent will have access to in order to interact with users. +**call_successful:** `typing.Optional[EvaluationSuccessResult]` — The result of the success evaluation
@@ -6210,9 +5903,39 @@ client.conversational_ai.add_to_knowledge_base()
-**file:** `from __future__ import annotations +**call_start_before_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations up to this start date. + +
+
-typing.Optional[core.File]` — See core.File for more documentation +
+
+ +**call_start_after_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations after to this start date. + +
+
+ +
+
+ +**user_id:** `typing.Optional[str]` — Filter conversations by the user ID who initiated them. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — How many conversations to return at maximum. Can not exceed 100, defaults to 30. + +
+
+ +
+
+ +**summary_mode:** `typing.Optional[ConversationsListRequestSummaryMode]` — Whether to include transcript summaries in the response.
@@ -6232,7 +5955,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.conversational_ai.get_document_rag_indexes(...) +
client.conversational_ai.conversations.get(...)
@@ -6244,7 +5967,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Provides information about all RAG indexes of the specified knowledgebase document. +Get the details of a particular conversation
@@ -6264,8 +5987,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_document_rag_indexes( - documentation_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.conversations.get( + conversation_id="123", ) ``` @@ -6282,7 +6005,7 @@ client.conversational_ai.get_document_rag_indexes(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. +**conversation_id:** `str` — The id of the conversation you're taking the action on.
@@ -6302,7 +6025,7 @@ client.conversational_ai.get_document_rag_indexes(
-
client.conversational_ai.delete_document_rag_index(...) +
client.conversational_ai.conversations.delete(...)
@@ -6314,7 +6037,7 @@ client.conversational_ai.get_document_rag_indexes(
-Delete RAG index for the knowledgebase document. +Delete a particular conversation
@@ -6334,9 +6057,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.delete_document_rag_index( - documentation_id="21m00Tcm4TlvDq8ikWAM", - rag_index_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.conversations.delete( + conversation_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -6353,15 +6075,7 @@ client.conversational_ai.delete_document_rag_index(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. - -
-
- -
-
- -**rag_index_id:** `str` — The id of RAG index of document from the knowledge base. +**conversation_id:** `str` — The id of the conversation you're taking the action on.
@@ -6381,7 +6095,8 @@ client.conversational_ai.delete_document_rag_index(
-
client.conversational_ai.rag_index_overview() +## ConversationalAi Twilio +
client.conversational_ai.twilio.outbound_call(...)
@@ -6393,7 +6108,7 @@ client.conversational_ai.delete_document_rag_index(
-Provides total size and other information of RAG indexes used by knowledgebase documents +Handle an outbound call via Twilio
@@ -6407,25 +6122,61 @@ Provides total size and other information of RAG indexes used by knowledgebase d
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.rag_index_overview() - -``` -
-
+```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.twilio.outbound_call( + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + to_number="to_number", +) + +``` + +
+ + + +#### ⚙️ Parameters + +
+
+ +
+
+ +**agent_id:** `str` + +
+
+ +
+
+ +**agent_phone_number_id:** `str` + +
+
+ +
+
+ +**to_number:** `str` +
-#### ⚙️ Parameters -
+**conversation_initiation_client_data:** `typing.Optional[ConversationInitiationClientDataRequestInput]` + +
+
+
@@ -6441,7 +6192,8 @@ client.conversational_ai.rag_index_overview()
-
client.conversational_ai.update_secret(...) +## ConversationalAi Agents +
client.conversational_ai.agents.create(...)
@@ -6453,7 +6205,7 @@ client.conversational_ai.rag_index_overview()
-Update an existing secret for the workspace +Create an agent from a config object
@@ -6468,15 +6220,13 @@ Update an existing secret for the workspace
```python -from elevenlabs import ElevenLabs +from elevenlabs import ConversationalConfig, ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.update_secret( - secret_id="secret_id", - name="name", - value="value", +client.conversational_ai.agents.create( + conversation_config=ConversationalConfig(), ) ``` @@ -6493,7 +6243,7 @@ client.conversational_ai.update_secret(
-**secret_id:** `str` +**conversation_config:** `ConversationalConfig` — Conversation configuration for an agent
@@ -6501,7 +6251,7 @@ client.conversational_ai.update_secret(
-**name:** `str` +**platform_settings:** `typing.Optional[AgentPlatformSettingsRequestModel]` — Platform settings for the agent are all settings that aren't related to the conversation orchestration and content.
@@ -6509,7 +6259,23 @@ client.conversational_ai.update_secret(
-**value:** `str` +**workflow:** `typing.Optional[typing.Optional[typing.Any]]` + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — A name to make the agent easier to find + +
+
+ +
+
+ +**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent
@@ -6529,9 +6295,7 @@ client.conversational_ai.update_secret(
-## Music -## ConversationalAi Conversations -
client.conversational_ai.conversations.get_signed_url(...) +
client.conversational_ai.agents.get(...)
@@ -6543,7 +6307,7 @@ client.conversational_ai.update_secret(
-Get a signed url to start a conversation with an agent with an agent that requires authorization +Retrieve config for an agent
@@ -6563,7 +6327,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.conversations.get_signed_url( +client.conversational_ai.agents.get( agent_id="21m00Tcm4TlvDq8ikWAM", ) @@ -6581,7 +6345,7 @@ client.conversational_ai.conversations.get_signed_url(
-**agent_id:** `str` — The id of the agent you're taking the action on. +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -6601,7 +6365,7 @@ client.conversational_ai.conversations.get_signed_url(
-
client.conversational_ai.conversations.get_webrtc_token(...) +
client.conversational_ai.agents.delete(...)
@@ -6613,7 +6377,7 @@ client.conversational_ai.conversations.get_signed_url(
-Get a WebRTC session token for real-time communication. +Delete an agent
@@ -6633,7 +6397,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.conversations.get_webrtc_token( +client.conversational_ai.agents.delete( agent_id="21m00Tcm4TlvDq8ikWAM", ) @@ -6651,15 +6415,7 @@ client.conversational_ai.conversations.get_webrtc_token(
-**agent_id:** `str` — The id of the agent you're taking the action on. - -
-
- -
-
- -**participant_name:** `typing.Optional[str]` — Optional custom participant name. If not provided, user ID will be used +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -6679,7 +6435,7 @@ client.conversational_ai.conversations.get_webrtc_token(
-
client.conversational_ai.conversations.list(...) +
client.conversational_ai.agents.update(...)
@@ -6691,7 +6447,7 @@ client.conversational_ai.conversations.get_webrtc_token(
-Get all conversations of agents that user owns. With option to restrict to a specific agent. +Patches an Agent settings
@@ -6711,7 +6467,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.conversations.list() +client.conversational_ai.agents.update( + agent_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -6727,7 +6485,7 @@ client.conversational_ai.conversations.list()
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -6735,7 +6493,7 @@ client.conversational_ai.conversations.list()
-**agent_id:** `typing.Optional[str]` — The id of the agent you're taking the action on. +**conversation_config:** `typing.Optional[ConversationalConfig]` — Conversation configuration for an agent
@@ -6743,7 +6501,7 @@ client.conversational_ai.conversations.list()
-**call_successful:** `typing.Optional[EvaluationSuccessResult]` — The result of the success evaluation +**platform_settings:** `typing.Optional[AgentPlatformSettingsRequestModel]` — Platform settings for the agent are all settings that aren't related to the conversation orchestration and content.
@@ -6751,7 +6509,7 @@ client.conversational_ai.conversations.list()
-**call_start_before_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations up to this start date. +**workflow:** `typing.Optional[typing.Optional[typing.Any]]`
@@ -6759,7 +6517,7 @@ client.conversational_ai.conversations.list()
-**call_start_after_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations after to this start date. +**name:** `typing.Optional[str]` — A name to make the agent easier to find
@@ -6767,7 +6525,7 @@ client.conversational_ai.conversations.list()
-**user_id:** `typing.Optional[str]` — Filter conversations by the user ID who initiated them. +**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent
@@ -6775,15 +6533,83 @@ client.conversational_ai.conversations.list()
-**page_size:** `typing.Optional[int]` — How many conversations to return at maximum. Can not exceed 100, defaults to 30. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
+ + + + +
+ +
client.conversational_ai.agents.list(...) +
+
+ +#### 📝 Description
-**summary_mode:** `typing.Optional[ConversationsListRequestSummaryMode]` — Whether to include transcript summaries in the response. +
+
+ +Returns a list of your agents and their metadata. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.agents.list() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — How many Agents to return at maximum. Can not exceed 100, defaults to 30. + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Search by agents name.
@@ -6803,7 +6629,7 @@ client.conversational_ai.conversations.list()
-
client.conversational_ai.conversations.get(...) +
client.conversational_ai.agents.duplicate(...)
@@ -6815,7 +6641,7 @@ client.conversational_ai.conversations.list()
-Get the details of a particular conversation +Create a new agent by duplicating an existing one
@@ -6835,8 +6661,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.conversations.get( - conversation_id="123", +client.conversational_ai.agents.duplicate( + agent_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -6853,7 +6679,15 @@ client.conversational_ai.conversations.get(
-**conversation_id:** `str` — The id of the conversation you're taking the action on. +**agent_id:** `str` — The id of an agent. This is returned on agent creation. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — A name to make the agent easier to find
@@ -6873,7 +6707,7 @@ client.conversational_ai.conversations.get(
-
client.conversational_ai.conversations.delete(...) +
client.conversational_ai.agents.simulate_conversation(...)
@@ -6885,7 +6719,7 @@ client.conversational_ai.conversations.get(
-Delete a particular conversation +Run a conversation between the agent and a simulated user.
@@ -6900,13 +6734,23 @@ Delete a particular conversation
```python -from elevenlabs import ElevenLabs +from elevenlabs import ( + AgentConfig, + ConversationSimulationSpecification, + ElevenLabs, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.conversations.delete( - conversation_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.agents.simulate_conversation( + agent_id="21m00Tcm4TlvDq8ikWAM", + simulation_specification=ConversationSimulationSpecification( + simulated_user_config=AgentConfig( + first_message="Hello, how can I help you today?", + language="en", + ), + ), ) ``` @@ -6923,7 +6767,31 @@ client.conversational_ai.conversations.delete(
-**conversation_id:** `str` — The id of the conversation you're taking the action on. +**agent_id:** `str` — The id of an agent. This is returned on agent creation. + +
+
+ +
+
+ +**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated + +
+
+ +
+
+ +**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test + +
+
+ +
+
+ +**new_turns_limit:** `typing.Optional[int]` — Maximum number of new turns to generate in the conversation simulation
@@ -6943,8 +6811,7 @@ client.conversational_ai.conversations.delete(
-## ConversationalAi Twilio -
client.conversational_ai.twilio.outbound_call(...) +
client.conversational_ai.agents.simulate_conversation_stream(...)
@@ -6956,7 +6823,7 @@ client.conversational_ai.conversations.delete(
-Handle an outbound call via Twilio +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 and once the conversation has complete a single final message with the conversation analysis will be sent.
@@ -6971,15 +6838,23 @@ Handle an outbound call via Twilio
```python -from elevenlabs import ElevenLabs +from elevenlabs import ( + AgentConfig, + ConversationSimulationSpecification, + ElevenLabs, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.twilio.outbound_call( - agent_id="agent_id", - agent_phone_number_id="agent_phone_number_id", - to_number="to_number", +client.conversational_ai.agents.simulate_conversation_stream( + agent_id="21m00Tcm4TlvDq8ikWAM", + simulation_specification=ConversationSimulationSpecification( + simulated_user_config=AgentConfig( + first_message="Hello, how can I help you today?", + language="en", + ), + ), ) ``` @@ -6996,7 +6871,7 @@ client.conversational_ai.twilio.outbound_call(
-**agent_id:** `str` +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -7004,7 +6879,7 @@ client.conversational_ai.twilio.outbound_call(
-**agent_phone_number_id:** `str` +**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated
@@ -7012,7 +6887,7 @@ client.conversational_ai.twilio.outbound_call(
-**to_number:** `str` +**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test
@@ -7020,7 +6895,7 @@ client.conversational_ai.twilio.outbound_call(
-**conversation_initiation_client_data:** `typing.Optional[ConversationInitiationClientDataRequestInput]` +**new_turns_limit:** `typing.Optional[int]` — Maximum number of new turns to generate in the conversation simulation
@@ -7040,8 +6915,7 @@ client.conversational_ai.twilio.outbound_call(
-## ConversationalAi Agents -
client.conversational_ai.agents.create(...) +
client.conversational_ai.agents.run_tests(...)
@@ -7053,7 +6927,7 @@ client.conversational_ai.twilio.outbound_call(
-Create an agent from a config object +Run selected tests on the agent with provided configuration. If the agent configuration is provided, it will be used to override default agent configuration.
@@ -7068,13 +6942,18 @@ Create an agent from a config object
```python -from elevenlabs import ConversationalConfig, ElevenLabs +from elevenlabs import ElevenLabs, SingleTestRunRequestModel client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.create( - conversation_config=ConversationalConfig(), +client.conversational_ai.agents.run_tests( + agent_id="21m00Tcm4TlvDq8ikWAM", + tests=[ + SingleTestRunRequestModel( + test_id="test_id", + ) + ], ) ``` @@ -7091,23 +6970,7 @@ client.conversational_ai.agents.create(
-**conversation_config:** `ConversationalConfig` — Conversation configuration for an agent - -
-
- -
-
- -**platform_settings:** `typing.Optional[AgentPlatformSettingsRequestModel]` — Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. - -
-
- -
-
- -**workflow:** `typing.Optional[typing.Optional[typing.Any]]` +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -7115,7 +6978,7 @@ client.conversational_ai.agents.create(
-**name:** `typing.Optional[str]` — A name to make the agent easier to find +**tests:** `typing.Sequence[SingleTestRunRequestModel]` — List of tests to run on the agent
@@ -7123,7 +6986,7 @@ client.conversational_ai.agents.create(
-**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent +**agent_config_override:** `typing.Optional[AdhocAgentConfigOverrideForTestRequestModel]` — Configuration overrides to use for testing. If not provided, the agent's default configuration will be used.
@@ -7143,7 +7006,8 @@ client.conversational_ai.agents.create(
-
client.conversational_ai.agents.get(...) +## ConversationalAi Tests +
client.conversational_ai.tests.create(...)
@@ -7155,7 +7019,7 @@ client.conversational_ai.agents.create(
-Retrieve config for an agent +Creates a new agent response test.
@@ -7170,13 +7034,35 @@ Retrieve config for an agent
```python -from elevenlabs import ElevenLabs +from elevenlabs import ( + AgentFailureResponseExample, + AgentSuccessfulResponseExample, + ConversationHistoryTranscriptCommonModelInput, + ElevenLabs, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.get( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.tests.create( + chat_history=[ + ConversationHistoryTranscriptCommonModelInput( + role="user", + time_in_call_secs=1, + ) + ], + success_condition="success_condition", + success_examples=[ + AgentSuccessfulResponseExample( + response="response", + ) + ], + failure_examples=[ + AgentFailureResponseExample( + response="response", + ) + ], + name="name", ) ``` @@ -7193,7 +7079,7 @@ client.conversational_ai.agents.get(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**chat_history:** `typing.Sequence[ConversationHistoryTranscriptCommonModelInput]`
@@ -7201,69 +7087,51 @@ client.conversational_ai.agents.get(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**success_condition:** `str` — A prompt that evaluates whether the agent's response is successful. Should return True or False.
-
-
+
+
+**success_examples:** `typing.Sequence[AgentSuccessfulResponseExample]` — Non-empty list of example responses that should be considered successful +
-
-
client.conversational_ai.agents.delete(...)
-#### 📝 Description - -
-
+**failure_examples:** `typing.Sequence[AgentFailureResponseExample]` — Non-empty list of example responses that should be considered failures + +
+
-Delete an agent -
-
+**name:** `str` +
-#### 🔌 Usage - -
-
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.agents.delete( - agent_id="21m00Tcm4TlvDq8ikWAM", -) - -``` -
-
+**tool_call_parameters:** `typing.Optional[UnitTestToolCallEvaluationModelInput]` — How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. +
-#### ⚙️ Parameters - -
-
-
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**dynamic_variables:** `typing.Optional[ + typing.Dict[ + str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue] + ] +]` — Dynamic variables to replace in the agent config during testing
@@ -7283,7 +7151,7 @@ client.conversational_ai.agents.delete(
-
client.conversational_ai.agents.update(...) +
client.conversational_ai.tests.get(...)
@@ -7295,7 +7163,7 @@ client.conversational_ai.agents.delete(
-Patches an Agent settings +Gets an agent response test by ID.
@@ -7315,8 +7183,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.update( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.tests.get( + test_id="TeaqRRdTcIfIu2i7BYfT", ) ``` @@ -7333,7 +7201,7 @@ client.conversational_ai.agents.update(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**test_id:** `str` — The id of a chat response test. This is returned on test creation.
@@ -7341,77 +7209,84 @@ client.conversational_ai.agents.update(
-**conversation_config:** `typing.Optional[ConversationalConfig]` — Conversation configuration for an agent +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
- -
-
- -**platform_settings:** `typing.Optional[AgentPlatformSettingsRequestModel]` — Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. -
-
-
-**workflow:** `typing.Optional[typing.Optional[typing.Any]]` -
+
+
client.conversational_ai.tests.update(...)
-**name:** `typing.Optional[str]` — A name to make the agent easier to find - -
-
+#### 📝 Description
-**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent - -
-
-
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - +Updates an agent response test by ID.
+#### 🔌 Usage - - -
- -
client.conversational_ai.agents.list(...)
-#### 📝 Description -
-
-
+```python +from elevenlabs import ( + AgentFailureResponseExample, + AgentSuccessfulResponseExample, + ConversationHistoryTranscriptCommonModelInput, + ElevenLabs, +) -Returns a list of your agents and their metadata. +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.tests.update( + test_id="TeaqRRdTcIfIu2i7BYfT", + chat_history=[ + ConversationHistoryTranscriptCommonModelInput( + role="user", + time_in_call_secs=1, + ) + ], + success_condition="success_condition", + success_examples=[ + AgentSuccessfulResponseExample( + response="response", + ) + ], + failure_examples=[ + AgentFailureResponseExample( + response="response", + ) + ], + name="name", +) + +```
-#### 🔌 Usage +#### ⚙️ Parameters
@@ -7419,29 +7294,47 @@ Returns a list of your agents and their metadata.
-```python -from elevenlabs import ElevenLabs +**test_id:** `str` — The id of a chat response test. This is returned on test creation. + +
+
-client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.agents.list() +
+
-``` +**chat_history:** `typing.Sequence[ConversationHistoryTranscriptCommonModelInput]` +
+ +
+
+ +**success_condition:** `str` — A prompt that evaluates whether the agent's response is successful. Should return True or False. +
-#### ⚙️ Parameters +
+
+ +**success_examples:** `typing.Sequence[AgentSuccessfulResponseExample]` — Non-empty list of example responses that should be considered successful + +
+
+**failure_examples:** `typing.Sequence[AgentFailureResponseExample]` — Non-empty list of example responses that should be considered failures + +
+
+
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. +**name:** `str`
@@ -7449,7 +7342,7 @@ client.conversational_ai.agents.list()
-**page_size:** `typing.Optional[int]` — How many Agents to return at maximum. Can not exceed 100, defaults to 30. +**tool_call_parameters:** `typing.Optional[UnitTestToolCallEvaluationModelInput]` — How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated.
@@ -7457,7 +7350,11 @@ client.conversational_ai.agents.list()
-**search:** `typing.Optional[str]` — Search by agents name. +**dynamic_variables:** `typing.Optional[ + typing.Dict[ + str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue] + ] +]` — Dynamic variables to replace in the agent config during testing
@@ -7477,7 +7374,7 @@ client.conversational_ai.agents.list()
-
client.conversational_ai.agents.duplicate(...) +
client.conversational_ai.tests.delete(...)
@@ -7489,7 +7386,7 @@ client.conversational_ai.agents.list()
-Create a new agent by duplicating an existing one +Deletes an agent response test by ID.
@@ -7509,8 +7406,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.duplicate( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.tests.delete( + test_id="TeaqRRdTcIfIu2i7BYfT", ) ``` @@ -7527,15 +7424,7 @@ client.conversational_ai.agents.duplicate(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. - -
-
- -
-
- -**name:** `typing.Optional[str]` — A name to make the agent easier to find +**test_id:** `str` — The id of a chat response test. This is returned on test creation.
@@ -7555,7 +7444,7 @@ client.conversational_ai.agents.duplicate(
-
client.conversational_ai.agents.simulate_conversation(...) +
client.conversational_ai.tests.summaries(...)
@@ -7567,7 +7456,7 @@ client.conversational_ai.agents.duplicate(
-Run a conversation between the agent and a simulated user. +Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries.
@@ -7582,23 +7471,13 @@ Run a conversation between the agent and a simulated user.
```python -from elevenlabs import ( - AgentConfig, - ConversationSimulationSpecification, - ElevenLabs, -) +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.simulate_conversation( - agent_id="21m00Tcm4TlvDq8ikWAM", - simulation_specification=ConversationSimulationSpecification( - simulated_user_config=AgentConfig( - first_message="Hello, how can I help you today?", - language="en", - ), - ), +client.conversational_ai.tests.summaries( + test_ids=["test_id_1", "test_id_2"], ) ``` @@ -7615,31 +7494,7 @@ client.conversational_ai.agents.simulate_conversation(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. - -
-
- -
-
- -**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated - -
-
- -
-
- -**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test - -
-
- -
-
- -**new_turns_limit:** `typing.Optional[int]` — Maximum number of new turns to generate in the conversation simulation +**test_ids:** `typing.Sequence[str]` — List of test IDs to fetch. No duplicates allowed.
@@ -7659,7 +7514,7 @@ client.conversational_ai.agents.simulate_conversation(
-
client.conversational_ai.agents.simulate_conversation_stream(...) +
client.conversational_ai.tests.list(...)
@@ -7671,7 +7526,7 @@ client.conversational_ai.agents.simulate_conversation(
-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 and once the conversation has complete a single final message with the conversation analysis will be sent. +Lists all agent response tests with pagination support and optional search filtering.
@@ -7686,24 +7541,12 @@ Run a conversation between the agent and a simulated user and stream back the re
```python -from elevenlabs import ( - AgentConfig, - ConversationSimulationSpecification, - ElevenLabs, -) +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.simulate_conversation_stream( - agent_id="21m00Tcm4TlvDq8ikWAM", - simulation_specification=ConversationSimulationSpecification( - simulated_user_config=AgentConfig( - first_message="Hello, how can I help you today?", - language="en", - ), - ), -) +client.conversational_ai.tests.list() ```
@@ -7719,15 +7562,7 @@ client.conversational_ai.agents.simulate_conversation_stream(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. - -
-
- -
-
- -**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -7735,7 +7570,7 @@ client.conversational_ai.agents.simulate_conversation_stream(
-**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test +**page_size:** `typing.Optional[int]` — How many Tests to return at maximum. Can not exceed 100, defaults to 30.
@@ -7743,7 +7578,7 @@ client.conversational_ai.agents.simulate_conversation_stream(
-**new_turns_limit:** `typing.Optional[int]` — Maximum number of new turns to generate in the conversation simulation +**search:** `typing.Optional[str]` — Search query to filter tests by name.
@@ -11562,6 +11397,173 @@ client.conversational_ai.mcp_servers.tool_approvals.delete(
+ + +
+ +## ConversationalAi Tests Invocations +
client.conversational_ai.tests.invocations.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Gets a test invocation by ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.tests.invocations.get( + test_invocation_id="test_invocation_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**test_invocation_id:** `str` — The id of a test invocation. This is returned when tests are run. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.conversational_ai.tests.invocations.resubmit(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Resubmits specific test runs from a test invocation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.tests.invocations.resubmit( + test_invocation_id="test_invocation_id", + test_run_ids=["test_run_ids"], + agent_id="agent_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**test_invocation_id:** `str` — The id of a test invocation. This is returned when tests are run. + +
+
+ +
+
+ +**test_run_ids:** `typing.Sequence[str]` — List of test run IDs to resubmit + +
+
+ +
+
+ +**agent_id:** `str` — Agent ID to resubmit tests for + +
+
+ +
+
+ +**agent_config_override:** `typing.Optional[AdhocAgentConfigOverrideForTestRequestModel]` — Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/src/elevenlabs/__init__.py b/src/elevenlabs/__init__.py index 73171f97..a25d3849 100644 --- a/src/elevenlabs/__init__.py +++ b/src/elevenlabs/__init__.py @@ -213,7 +213,6 @@ CreateSipTrunkPhoneNumberRequest, CreateTranscriptRequest, CreateTwilioPhoneNumberRequest, - CreateUnitTestRequestDynamicVariablesValue, CreateUnitTestResponseModel, CustomLlm, CustomLlmRequestHeadersValue, @@ -623,6 +622,7 @@ TestConditionResultCommonModel, TestRunStatus, TestToolResultModel, + TestsFeatureUsageCommonModel, TextToSpeechApplyTextNormalizationEnum, TextToSpeechOutputFormatEnum, TextToSpeechStreamRequest, @@ -679,7 +679,6 @@ UpdateChapterRequest, UpdateProjectRequest, UpdatePronunciationDictionariesRequest, - UpdateUnitTestRequestDynamicVariablesValue, UpdateWorkspaceMemberResponseModel, UrlAvatar, UsageAggregationInterval, @@ -1098,7 +1097,6 @@ "CreateSipTrunkPhoneNumberRequest", "CreateTranscriptRequest", "CreateTwilioPhoneNumberRequest", - "CreateUnitTestRequestDynamicVariablesValue", "CreateUnitTestResponseModel", "CustomLlm", "CustomLlmRequestHeadersValue", @@ -1532,6 +1530,7 @@ "TestConditionResultCommonModel", "TestRunStatus", "TestToolResultModel", + "TestsFeatureUsageCommonModel", "TextToDialogueConvertRequestOutputFormat", "TextToDialogueStreamRequestOutputFormat", "TextToSoundEffectsConvertRequestOutputFormat", @@ -1599,7 +1598,6 @@ "UpdateChapterRequest", "UpdateProjectRequest", "UpdatePronunciationDictionariesRequest", - "UpdateUnitTestRequestDynamicVariablesValue", "UpdateWorkspaceMemberResponseModel", "UrlAvatar", "UsageAggregationInterval", diff --git a/src/elevenlabs/base_client.py b/src/elevenlabs/base_client.py index 87c75ebc..54d9566a 100644 --- a/src/elevenlabs/base_client.py +++ b/src/elevenlabs/base_client.py @@ -25,28 +25,12 @@ from .text_to_sound_effects.client import AsyncTextToSoundEffectsClient, TextToSoundEffectsClient from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient from .text_to_voice.client import AsyncTextToVoiceClient, TextToVoiceClient -from .types.adhoc_agent_config_override_for_test_request_model import AdhocAgentConfigOverrideForTestRequestModel -from .types.agent_failure_response_example import AgentFailureResponseExample -from .types.agent_successful_response_example import AgentSuccessfulResponseExample -from .types.conversation_history_transcript_common_model_input import ConversationHistoryTranscriptCommonModelInput -from .types.create_unit_test_request_dynamic_variables_value import CreateUnitTestRequestDynamicVariablesValue -from .types.create_unit_test_response_model import CreateUnitTestResponseModel -from .types.get_test_suite_invocation_response_model import GetTestSuiteInvocationResponseModel -from .types.get_tests_page_response_model import GetTestsPageResponseModel -from .types.get_tests_summaries_by_ids_response_model import GetTestsSummariesByIdsResponseModel -from .types.get_unit_test_response_model import GetUnitTestResponseModel -from .types.single_test_run_request_model import SingleTestRunRequestModel -from .types.unit_test_tool_call_evaluation_model_input import UnitTestToolCallEvaluationModelInput -from .types.update_unit_test_request_dynamic_variables_value import UpdateUnitTestRequestDynamicVariablesValue from .usage.client import AsyncUsageClient, UsageClient from .user.client import AsyncUserClient, UserClient from .voices.client import AsyncVoicesClient, VoicesClient from .webhooks.client import AsyncWebhooksClient, WebhooksClient from .workspace.client import AsyncWorkspaceClient, WorkspaceClient -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - class BaseElevenLabs: """ @@ -144,479 +128,6 @@ def with_raw_response(self) -> RawBaseElevenLabs: """ return self._raw_client - def create_agent_response_test_route( - self, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreateUnitTestResponseModel: - """ - Creates a new agent response test. - - Parameters - ---------- - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreateUnitTestResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ( - AgentFailureResponseExample, - AgentSuccessfulResponseExample, - ConversationHistoryTranscriptCommonModelInput, - ElevenLabs, - ) - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.create_agent_response_test_route( - chat_history=[ - ConversationHistoryTranscriptCommonModelInput( - role="user", - time_in_call_secs=1, - ) - ], - success_condition="success_condition", - success_examples=[ - AgentSuccessfulResponseExample( - response="response", - ) - ], - failure_examples=[ - AgentFailureResponseExample( - response="response", - ) - ], - name="name", - ) - """ - _response = self._raw_client.create_agent_response_test_route( - chat_history=chat_history, - success_condition=success_condition, - success_examples=success_examples, - failure_examples=failure_examples, - name=name, - tool_call_parameters=tool_call_parameters, - dynamic_variables=dynamic_variables, - request_options=request_options, - ) - return _response.data - - def get_agent_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetUnitTestResponseModel: - """ - Gets an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetUnitTestResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.get_agent_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", - ) - """ - _response = self._raw_client.get_agent_response_test_route(test_id, request_options=request_options) - return _response.data - - def update_agent_response_test_route( - self, - test_id: str, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetUnitTestResponseModel: - """ - Updates an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetUnitTestResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ( - AgentFailureResponseExample, - AgentSuccessfulResponseExample, - ConversationHistoryTranscriptCommonModelInput, - ElevenLabs, - ) - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.update_agent_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", - chat_history=[ - ConversationHistoryTranscriptCommonModelInput( - role="user", - time_in_call_secs=1, - ) - ], - success_condition="success_condition", - success_examples=[ - AgentSuccessfulResponseExample( - response="response", - ) - ], - failure_examples=[ - AgentFailureResponseExample( - response="response", - ) - ], - name="name", - ) - """ - _response = self._raw_client.update_agent_response_test_route( - test_id, - chat_history=chat_history, - success_condition=success_condition, - success_examples=success_examples, - failure_examples=failure_examples, - name=name, - tool_call_parameters=tool_call_parameters, - dynamic_variables=dynamic_variables, - request_options=request_options, - ) - return _response.data - - def delete_chat_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Optional[typing.Any]: - """ - Deletes an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.delete_chat_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", - ) - """ - _response = self._raw_client.delete_chat_response_test_route(test_id, request_options=request_options) - return _response.data - - def get_agent_response_tests_summaries_route( - self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None - ) -> GetTestsSummariesByIdsResponseModel: - """ - Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. - - Parameters - ---------- - test_ids : typing.Sequence[str] - List of test IDs to fetch. No duplicates allowed. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestsSummariesByIdsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.get_agent_response_tests_summaries_route( - test_ids=["test_id_1", "test_id_2"], - ) - """ - _response = self._raw_client.get_agent_response_tests_summaries_route( - test_ids=test_ids, request_options=request_options - ) - return _response.data - - def list_chat_response_tests_route( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetTestsPageResponseModel: - """ - Lists all agent response tests with pagination support and optional search filtering. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many Tests to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - Search query to filter tests by name. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestsPageResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.list_chat_response_tests_route() - """ - _response = self._raw_client.list_chat_response_tests_route( - cursor=cursor, page_size=page_size, search=search, request_options=request_options - ) - return _response.data - - def run_agent_test_suite_route( - self, - agent_id: str, - *, - tests: typing.Sequence[SingleTestRunRequestModel], - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.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. - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - tests : typing.Sequence[SingleTestRunRequestModel] - List of tests to run on the agent - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestSuiteInvocationResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs, SingleTestRunRequestModel - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.run_agent_test_suite_route( - agent_id="21m00Tcm4TlvDq8ikWAM", - tests=[ - SingleTestRunRequestModel( - test_id="test_id", - ) - ], - ) - """ - _response = self._raw_client.run_agent_test_suite_route( - agent_id, tests=tests, agent_config_override=agent_config_override, request_options=request_options - ) - return _response.data - - def get_test_invocation_route( - self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetTestSuiteInvocationResponseModel: - """ - Gets a test invocation by ID. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestSuiteInvocationResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.get_test_invocation_route( - test_invocation_id="test_invocation_id", - ) - """ - _response = self._raw_client.get_test_invocation_route(test_invocation_id, request_options=request_options) - return _response.data - - def resubmit_tests_route( - self, - test_invocation_id: str, - *, - test_run_ids: typing.Sequence[str], - agent_id: str, - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Resubmits specific test runs from a test invocation. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - test_run_ids : typing.Sequence[str] - List of test run IDs to resubmit - - agent_id : str - Agent ID to resubmit tests for - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.resubmit_tests_route( - test_invocation_id="test_invocation_id", - test_run_ids=["test_run_ids"], - agent_id="agent_id", - ) - """ - _response = self._raw_client.resubmit_tests_route( - test_invocation_id, - test_run_ids=test_run_ids, - agent_id=agent_id, - agent_config_override=agent_config_override, - request_options=request_options, - ) - return _response.data - def save_a_voice_preview(self, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Add a generated voice to the voice library. @@ -739,553 +250,6 @@ def with_raw_response(self) -> AsyncRawBaseElevenLabs: """ return self._raw_client - async def create_agent_response_test_route( - self, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreateUnitTestResponseModel: - """ - Creates a new agent response test. - - Parameters - ---------- - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreateUnitTestResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import ( - AgentFailureResponseExample, - AgentSuccessfulResponseExample, - AsyncElevenLabs, - ConversationHistoryTranscriptCommonModelInput, - ) - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.create_agent_response_test_route( - chat_history=[ - ConversationHistoryTranscriptCommonModelInput( - role="user", - time_in_call_secs=1, - ) - ], - success_condition="success_condition", - success_examples=[ - AgentSuccessfulResponseExample( - response="response", - ) - ], - failure_examples=[ - AgentFailureResponseExample( - response="response", - ) - ], - name="name", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.create_agent_response_test_route( - chat_history=chat_history, - success_condition=success_condition, - success_examples=success_examples, - failure_examples=failure_examples, - name=name, - tool_call_parameters=tool_call_parameters, - dynamic_variables=dynamic_variables, - request_options=request_options, - ) - return _response.data - - async def get_agent_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetUnitTestResponseModel: - """ - Gets an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetUnitTestResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.get_agent_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.get_agent_response_test_route(test_id, request_options=request_options) - return _response.data - - async def update_agent_response_test_route( - self, - test_id: str, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetUnitTestResponseModel: - """ - Updates an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetUnitTestResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import ( - AgentFailureResponseExample, - AgentSuccessfulResponseExample, - AsyncElevenLabs, - ConversationHistoryTranscriptCommonModelInput, - ) - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.update_agent_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", - chat_history=[ - ConversationHistoryTranscriptCommonModelInput( - role="user", - time_in_call_secs=1, - ) - ], - success_condition="success_condition", - success_examples=[ - AgentSuccessfulResponseExample( - response="response", - ) - ], - failure_examples=[ - AgentFailureResponseExample( - response="response", - ) - ], - name="name", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.update_agent_response_test_route( - test_id, - chat_history=chat_history, - success_condition=success_condition, - success_examples=success_examples, - failure_examples=failure_examples, - name=name, - tool_call_parameters=tool_call_parameters, - dynamic_variables=dynamic_variables, - request_options=request_options, - ) - return _response.data - - async def delete_chat_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.Optional[typing.Any]: - """ - Deletes an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.delete_chat_response_test_route( - test_id="TeaqRRdTcIfIu2i7BYfT", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.delete_chat_response_test_route(test_id, request_options=request_options) - return _response.data - - async def get_agent_response_tests_summaries_route( - self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None - ) -> GetTestsSummariesByIdsResponseModel: - """ - Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. - - Parameters - ---------- - test_ids : typing.Sequence[str] - List of test IDs to fetch. No duplicates allowed. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestsSummariesByIdsResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.get_agent_response_tests_summaries_route( - test_ids=["test_id_1", "test_id_2"], - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.get_agent_response_tests_summaries_route( - test_ids=test_ids, request_options=request_options - ) - return _response.data - - async def list_chat_response_tests_route( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetTestsPageResponseModel: - """ - Lists all agent response tests with pagination support and optional search filtering. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many Tests to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - Search query to filter tests by name. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestsPageResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.list_chat_response_tests_route() - - - asyncio.run(main()) - """ - _response = await self._raw_client.list_chat_response_tests_route( - cursor=cursor, page_size=page_size, search=search, request_options=request_options - ) - return _response.data - - async def run_agent_test_suite_route( - self, - agent_id: str, - *, - tests: typing.Sequence[SingleTestRunRequestModel], - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.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. - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - tests : typing.Sequence[SingleTestRunRequestModel] - List of tests to run on the agent - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestSuiteInvocationResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs, SingleTestRunRequestModel - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.run_agent_test_suite_route( - agent_id="21m00Tcm4TlvDq8ikWAM", - tests=[ - SingleTestRunRequestModel( - test_id="test_id", - ) - ], - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.run_agent_test_suite_route( - agent_id, tests=tests, agent_config_override=agent_config_override, request_options=request_options - ) - return _response.data - - async def get_test_invocation_route( - self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetTestSuiteInvocationResponseModel: - """ - Gets a test invocation by ID. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetTestSuiteInvocationResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.get_test_invocation_route( - test_invocation_id="test_invocation_id", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.get_test_invocation_route( - test_invocation_id, request_options=request_options - ) - return _response.data - - async def resubmit_tests_route( - self, - test_invocation_id: str, - *, - test_run_ids: typing.Sequence[str], - agent_id: str, - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Resubmits specific test runs from a test invocation. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - test_run_ids : typing.Sequence[str] - List of test run IDs to resubmit - - agent_id : str - Agent ID to resubmit tests for - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.resubmit_tests_route( - test_invocation_id="test_invocation_id", - test_run_ids=["test_run_ids"], - agent_id="agent_id", - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.resubmit_tests_route( - test_invocation_id, - test_run_ids=test_run_ids, - agent_id=agent_id, - agent_config_override=agent_config_override, - request_options=request_options, - ) - return _response.data - async def save_a_voice_preview(self, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Add a generated voice to the voice library. diff --git a/src/elevenlabs/conversational_ai/__init__.py b/src/elevenlabs/conversational_ai/__init__.py index 2db12114..4c24a3df 100644 --- a/src/elevenlabs/conversational_ai/__init__.py +++ b/src/elevenlabs/conversational_ai/__init__.py @@ -14,6 +14,7 @@ secrets, settings, sip_trunk, + tests, tools, twilio, ) @@ -32,9 +33,11 @@ PhoneNumbersUpdateResponse_SipTrunk, PhoneNumbersUpdateResponse_Twilio, ) +from .tests import CreateUnitTestRequestDynamicVariablesValue, UpdateUnitTestRequestDynamicVariablesValue __all__ = [ "ConversationsListRequestSummaryMode", + "CreateUnitTestRequestDynamicVariablesValue", "PhoneNumbersCreateRequestBody", "PhoneNumbersCreateRequestBody_SipTrunk", "PhoneNumbersCreateRequestBody_Twilio", @@ -47,6 +50,7 @@ "PhoneNumbersUpdateResponse", "PhoneNumbersUpdateResponse_SipTrunk", "PhoneNumbersUpdateResponse_Twilio", + "UpdateUnitTestRequestDynamicVariablesValue", "agents", "batch_calls", "conversations", @@ -58,6 +62,7 @@ "secrets", "settings", "sip_trunk", + "tests", "tools", "twilio", ] diff --git a/src/elevenlabs/conversational_ai/agents/client.py b/src/elevenlabs/conversational_ai/agents/client.py index b05ac8fc..262d530e 100644 --- a/src/elevenlabs/conversational_ai/agents/client.py +++ b/src/elevenlabs/conversational_ai/agents/client.py @@ -4,6 +4,7 @@ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions +from ...types.adhoc_agent_config_override_for_test_request_model import AdhocAgentConfigOverrideForTestRequestModel from ...types.agent_platform_settings_request_model import AgentPlatformSettingsRequestModel from ...types.agent_simulated_chat_test_response_model import AgentSimulatedChatTestResponseModel from ...types.conversation_simulation_specification import ConversationSimulationSpecification @@ -11,7 +12,9 @@ from ...types.create_agent_response_model import CreateAgentResponseModel from ...types.get_agent_response_model import GetAgentResponseModel from ...types.get_agents_page_response_model import GetAgentsPageResponseModel +from ...types.get_test_suite_invocation_response_model import GetTestSuiteInvocationResponseModel from ...types.prompt_evaluation_criteria import PromptEvaluationCriteria +from ...types.single_test_run_request_model import SingleTestRunRequestModel from .knowledge_base.client import AsyncKnowledgeBaseClient, KnowledgeBaseClient from .link.client import AsyncLinkClient, LinkClient from .llm_usage.client import AsyncLlmUsageClient, LlmUsageClient @@ -437,6 +440,57 @@ def simulate_conversation_stream( ) return _response.data + def run_tests( + self, + agent_id: str, + *, + tests: typing.Sequence[SingleTestRunRequestModel], + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.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. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + tests : typing.Sequence[SingleTestRunRequestModel] + List of tests to run on the agent + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestSuiteInvocationResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs, SingleTestRunRequestModel + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.run_tests( + agent_id="21m00Tcm4TlvDq8ikWAM", + tests=[ + SingleTestRunRequestModel( + test_id="test_id", + ) + ], + ) + """ + _response = self._raw_client.run_tests( + agent_id, tests=tests, agent_config_override=agent_config_override, request_options=request_options + ) + return _response.data + class AsyncAgentsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -918,3 +972,62 @@ async def main() -> None: request_options=request_options, ) return _response.data + + async def run_tests( + self, + agent_id: str, + *, + tests: typing.Sequence[SingleTestRunRequestModel], + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.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. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + tests : typing.Sequence[SingleTestRunRequestModel] + List of tests to run on the agent + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestSuiteInvocationResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs, SingleTestRunRequestModel + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.run_tests( + agent_id="21m00Tcm4TlvDq8ikWAM", + tests=[ + SingleTestRunRequestModel( + test_id="test_id", + ) + ], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.run_tests( + agent_id, tests=tests, agent_config_override=agent_config_override, request_options=request_options + ) + return _response.data diff --git a/src/elevenlabs/conversational_ai/agents/raw_client.py b/src/elevenlabs/conversational_ai/agents/raw_client.py index f8bdc1b9..8bba27fe 100644 --- a/src/elevenlabs/conversational_ai/agents/raw_client.py +++ b/src/elevenlabs/conversational_ai/agents/raw_client.py @@ -11,6 +11,7 @@ from ...core.serialization import convert_and_respect_annotation_metadata from ...core.unchecked_base_model import construct_type from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.adhoc_agent_config_override_for_test_request_model import AdhocAgentConfigOverrideForTestRequestModel from ...types.agent_platform_settings_request_model import AgentPlatformSettingsRequestModel from ...types.agent_simulated_chat_test_response_model import AgentSimulatedChatTestResponseModel from ...types.conversation_simulation_specification import ConversationSimulationSpecification @@ -18,8 +19,10 @@ from ...types.create_agent_response_model import CreateAgentResponseModel from ...types.get_agent_response_model import GetAgentResponseModel from ...types.get_agents_page_response_model import GetAgentsPageResponseModel +from ...types.get_test_suite_invocation_response_model import GetTestSuiteInvocationResponseModel from ...types.http_validation_error import HttpValidationError from ...types.prompt_evaluation_criteria import PromptEvaluationCriteria +from ...types.single_test_run_request_model import SingleTestRunRequestModel # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -571,6 +574,81 @@ def simulate_conversation_stream( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + def run_tests( + self, + agent_id: str, + *, + tests: typing.Sequence[SingleTestRunRequestModel], + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[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. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + tests : typing.Sequence[SingleTestRunRequestModel] + List of tests to run on the agent + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetTestSuiteInvocationResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/run-tests", + method="POST", + json={ + "tests": convert_and_respect_annotation_metadata( + object_=tests, annotation=typing.Sequence[SingleTestRunRequestModel], direction="write" + ), + "agent_config_override": convert_and_respect_annotation_metadata( + object_=agent_config_override, + annotation=AdhocAgentConfigOverrideForTestRequestModel, + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestSuiteInvocationResponseModel, + construct_type( + type_=GetTestSuiteInvocationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + class AsyncRawAgentsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -1119,3 +1197,78 @@ async def simulate_conversation_stream( except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def run_tests( + self, + agent_id: str, + *, + tests: typing.Sequence[SingleTestRunRequestModel], + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[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. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + tests : typing.Sequence[SingleTestRunRequestModel] + List of tests to run on the agent + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetTestSuiteInvocationResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/run-tests", + method="POST", + json={ + "tests": convert_and_respect_annotation_metadata( + object_=tests, annotation=typing.Sequence[SingleTestRunRequestModel], direction="write" + ), + "agent_config_override": convert_and_respect_annotation_metadata( + object_=agent_config_override, + annotation=AdhocAgentConfigOverrideForTestRequestModel, + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestSuiteInvocationResponseModel, + construct_type( + type_=GetTestSuiteInvocationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/client.py b/src/elevenlabs/conversational_ai/client.py index 2c7ab2aa..60aee9e9 100644 --- a/src/elevenlabs/conversational_ai/client.py +++ b/src/elevenlabs/conversational_ai/client.py @@ -22,6 +22,7 @@ from .secrets.client import AsyncSecretsClient, SecretsClient from .settings.client import AsyncSettingsClient, SettingsClient from .sip_trunk.client import AsyncSipTrunkClient, SipTrunkClient +from .tests.client import AsyncTestsClient, TestsClient from .tools.client import AsyncToolsClient, ToolsClient from .twilio.client import AsyncTwilioClient, TwilioClient @@ -38,6 +39,8 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): self.agents = AgentsClient(client_wrapper=client_wrapper) + self.tests = TestsClient(client_wrapper=client_wrapper) + self.phone_numbers = PhoneNumbersClient(client_wrapper=client_wrapper) self.llm_usage = LlmUsageClient(client_wrapper=client_wrapper) @@ -264,6 +267,8 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): self.agents = AsyncAgentsClient(client_wrapper=client_wrapper) + self.tests = AsyncTestsClient(client_wrapper=client_wrapper) + self.phone_numbers = AsyncPhoneNumbersClient(client_wrapper=client_wrapper) self.llm_usage = AsyncLlmUsageClient(client_wrapper=client_wrapper) diff --git a/src/elevenlabs/conversational_ai/tests/__init__.py b/src/elevenlabs/conversational_ai/tests/__init__.py new file mode 100644 index 00000000..95047906 --- /dev/null +++ b/src/elevenlabs/conversational_ai/tests/__init__.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import CreateUnitTestRequestDynamicVariablesValue, UpdateUnitTestRequestDynamicVariablesValue +from . import invocations + +__all__ = ["CreateUnitTestRequestDynamicVariablesValue", "UpdateUnitTestRequestDynamicVariablesValue", "invocations"] diff --git a/src/elevenlabs/conversational_ai/tests/client.py b/src/elevenlabs/conversational_ai/tests/client.py new file mode 100644 index 00000000..83bd1ab2 --- /dev/null +++ b/src/elevenlabs/conversational_ai/tests/client.py @@ -0,0 +1,763 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.agent_failure_response_example import AgentFailureResponseExample +from ...types.agent_successful_response_example import AgentSuccessfulResponseExample +from ...types.conversation_history_transcript_common_model_input import ConversationHistoryTranscriptCommonModelInput +from ...types.create_unit_test_response_model import CreateUnitTestResponseModel +from ...types.get_tests_page_response_model import GetTestsPageResponseModel +from ...types.get_tests_summaries_by_ids_response_model import GetTestsSummariesByIdsResponseModel +from ...types.get_unit_test_response_model import GetUnitTestResponseModel +from ...types.unit_test_tool_call_evaluation_model_input import UnitTestToolCallEvaluationModelInput +from .invocations.client import AsyncInvocationsClient, InvocationsClient +from .raw_client import AsyncRawTestsClient, RawTestsClient +from .types.create_unit_test_request_dynamic_variables_value import CreateUnitTestRequestDynamicVariablesValue +from .types.update_unit_test_request_dynamic_variables_value import UpdateUnitTestRequestDynamicVariablesValue + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class TestsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawTestsClient(client_wrapper=client_wrapper) + self.invocations = InvocationsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTestsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTestsClient + """ + return self._raw_client + + def create( + self, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateUnitTestResponseModel: + """ + Creates a new agent response test. + + Parameters + ---------- + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateUnitTestResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ( + AgentFailureResponseExample, + AgentSuccessfulResponseExample, + ConversationHistoryTranscriptCommonModelInput, + ElevenLabs, + ) + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.create( + chat_history=[ + ConversationHistoryTranscriptCommonModelInput( + role="user", + time_in_call_secs=1, + ) + ], + success_condition="success_condition", + success_examples=[ + AgentSuccessfulResponseExample( + response="response", + ) + ], + failure_examples=[ + AgentFailureResponseExample( + response="response", + ) + ], + name="name", + ) + """ + _response = self._raw_client.create( + chat_history=chat_history, + success_condition=success_condition, + success_examples=success_examples, + failure_examples=failure_examples, + name=name, + tool_call_parameters=tool_call_parameters, + dynamic_variables=dynamic_variables, + request_options=request_options, + ) + return _response.data + + def get(self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetUnitTestResponseModel: + """ + Gets an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetUnitTestResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.get( + test_id="TeaqRRdTcIfIu2i7BYfT", + ) + """ + _response = self._raw_client.get(test_id, request_options=request_options) + return _response.data + + def update( + self, + test_id: str, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetUnitTestResponseModel: + """ + Updates an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetUnitTestResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ( + AgentFailureResponseExample, + AgentSuccessfulResponseExample, + ConversationHistoryTranscriptCommonModelInput, + ElevenLabs, + ) + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.update( + test_id="TeaqRRdTcIfIu2i7BYfT", + chat_history=[ + ConversationHistoryTranscriptCommonModelInput( + role="user", + time_in_call_secs=1, + ) + ], + success_condition="success_condition", + success_examples=[ + AgentSuccessfulResponseExample( + response="response", + ) + ], + failure_examples=[ + AgentFailureResponseExample( + response="response", + ) + ], + name="name", + ) + """ + _response = self._raw_client.update( + test_id, + chat_history=chat_history, + success_condition=success_condition, + success_examples=success_examples, + failure_examples=failure_examples, + name=name, + tool_call_parameters=tool_call_parameters, + dynamic_variables=dynamic_variables, + request_options=request_options, + ) + return _response.data + + def delete( + self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Deletes an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.delete( + test_id="TeaqRRdTcIfIu2i7BYfT", + ) + """ + _response = self._raw_client.delete(test_id, request_options=request_options) + return _response.data + + def summaries( + self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> GetTestsSummariesByIdsResponseModel: + """ + Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. + + Parameters + ---------- + test_ids : typing.Sequence[str] + List of test IDs to fetch. No duplicates allowed. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestsSummariesByIdsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.summaries( + test_ids=["test_id_1", "test_id_2"], + ) + """ + _response = self._raw_client.summaries(test_ids=test_ids, request_options=request_options) + return _response.data + + def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetTestsPageResponseModel: + """ + Lists all agent response tests with pagination support and optional search filtering. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Tests to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search query to filter tests by name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestsPageResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.list() + """ + _response = self._raw_client.list( + cursor=cursor, page_size=page_size, search=search, request_options=request_options + ) + return _response.data + + +class AsyncTestsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawTestsClient(client_wrapper=client_wrapper) + self.invocations = AsyncInvocationsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTestsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTestsClient + """ + return self._raw_client + + async def create( + self, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateUnitTestResponseModel: + """ + Creates a new agent response test. + + Parameters + ---------- + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateUnitTestResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import ( + AgentFailureResponseExample, + AgentSuccessfulResponseExample, + AsyncElevenLabs, + ConversationHistoryTranscriptCommonModelInput, + ) + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.create( + chat_history=[ + ConversationHistoryTranscriptCommonModelInput( + role="user", + time_in_call_secs=1, + ) + ], + success_condition="success_condition", + success_examples=[ + AgentSuccessfulResponseExample( + response="response", + ) + ], + failure_examples=[ + AgentFailureResponseExample( + response="response", + ) + ], + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + chat_history=chat_history, + success_condition=success_condition, + success_examples=success_examples, + failure_examples=failure_examples, + name=name, + tool_call_parameters=tool_call_parameters, + dynamic_variables=dynamic_variables, + request_options=request_options, + ) + return _response.data + + async def get( + self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetUnitTestResponseModel: + """ + Gets an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetUnitTestResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.get( + test_id="TeaqRRdTcIfIu2i7BYfT", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(test_id, request_options=request_options) + return _response.data + + async def update( + self, + test_id: str, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetUnitTestResponseModel: + """ + Updates an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetUnitTestResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import ( + AgentFailureResponseExample, + AgentSuccessfulResponseExample, + AsyncElevenLabs, + ConversationHistoryTranscriptCommonModelInput, + ) + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.update( + test_id="TeaqRRdTcIfIu2i7BYfT", + chat_history=[ + ConversationHistoryTranscriptCommonModelInput( + role="user", + time_in_call_secs=1, + ) + ], + success_condition="success_condition", + success_examples=[ + AgentSuccessfulResponseExample( + response="response", + ) + ], + failure_examples=[ + AgentFailureResponseExample( + response="response", + ) + ], + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + test_id, + chat_history=chat_history, + success_condition=success_condition, + success_examples=success_examples, + failure_examples=failure_examples, + name=name, + tool_call_parameters=tool_call_parameters, + dynamic_variables=dynamic_variables, + request_options=request_options, + ) + return _response.data + + async def delete( + self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Deletes an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.delete( + test_id="TeaqRRdTcIfIu2i7BYfT", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(test_id, request_options=request_options) + return _response.data + + async def summaries( + self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> GetTestsSummariesByIdsResponseModel: + """ + Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. + + Parameters + ---------- + test_ids : typing.Sequence[str] + List of test IDs to fetch. No duplicates allowed. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestsSummariesByIdsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.summaries( + test_ids=["test_id_1", "test_id_2"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.summaries(test_ids=test_ids, request_options=request_options) + return _response.data + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetTestsPageResponseModel: + """ + Lists all agent response tests with pagination support and optional search filtering. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Tests to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search query to filter tests by name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestsPageResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list( + cursor=cursor, page_size=page_size, search=search, request_options=request_options + ) + return _response.data diff --git a/src/elevenlabs/conversational_ai/tests/invocations/__init__.py b/src/elevenlabs/conversational_ai/tests/invocations/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/tests/invocations/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/tests/invocations/client.py b/src/elevenlabs/conversational_ai/tests/invocations/client.py new file mode 100644 index 00000000..2062c321 --- /dev/null +++ b/src/elevenlabs/conversational_ai/tests/invocations/client.py @@ -0,0 +1,238 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.adhoc_agent_config_override_for_test_request_model import AdhocAgentConfigOverrideForTestRequestModel +from ....types.get_test_suite_invocation_response_model import GetTestSuiteInvocationResponseModel +from .raw_client import AsyncRawInvocationsClient, RawInvocationsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class InvocationsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawInvocationsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawInvocationsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawInvocationsClient + """ + return self._raw_client + + def get( + self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetTestSuiteInvocationResponseModel: + """ + Gets a test invocation by ID. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestSuiteInvocationResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.invocations.get( + test_invocation_id="test_invocation_id", + ) + """ + _response = self._raw_client.get(test_invocation_id, request_options=request_options) + return _response.data + + def resubmit( + self, + test_invocation_id: str, + *, + test_run_ids: typing.Sequence[str], + agent_id: str, + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Resubmits specific test runs from a test invocation. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + test_run_ids : typing.Sequence[str] + List of test run IDs to resubmit + + agent_id : str + Agent ID to resubmit tests for + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.tests.invocations.resubmit( + test_invocation_id="test_invocation_id", + test_run_ids=["test_run_ids"], + agent_id="agent_id", + ) + """ + _response = self._raw_client.resubmit( + test_invocation_id, + test_run_ids=test_run_ids, + agent_id=agent_id, + agent_config_override=agent_config_override, + request_options=request_options, + ) + return _response.data + + +class AsyncInvocationsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawInvocationsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawInvocationsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawInvocationsClient + """ + return self._raw_client + + async def get( + self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetTestSuiteInvocationResponseModel: + """ + Gets a test invocation by ID. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetTestSuiteInvocationResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.invocations.get( + test_invocation_id="test_invocation_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(test_invocation_id, request_options=request_options) + return _response.data + + async def resubmit( + self, + test_invocation_id: str, + *, + test_run_ids: typing.Sequence[str], + agent_id: str, + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Resubmits specific test runs from a test invocation. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + test_run_ids : typing.Sequence[str] + List of test run IDs to resubmit + + agent_id : str + Agent ID to resubmit tests for + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.tests.invocations.resubmit( + test_invocation_id="test_invocation_id", + test_run_ids=["test_run_ids"], + agent_id="agent_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.resubmit( + test_invocation_id, + test_run_ids=test_run_ids, + agent_id=agent_id, + agent_config_override=agent_config_override, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/conversational_ai/tests/invocations/raw_client.py b/src/elevenlabs/conversational_ai/tests/invocations/raw_client.py new file mode 100644 index 00000000..f7eeb21f --- /dev/null +++ b/src/elevenlabs/conversational_ai/tests/invocations/raw_client.py @@ -0,0 +1,289 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.serialization import convert_and_respect_annotation_metadata +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.adhoc_agent_config_override_for_test_request_model import AdhocAgentConfigOverrideForTestRequestModel +from ....types.get_test_suite_invocation_response_model import GetTestSuiteInvocationResponseModel +from ....types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawInvocationsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetTestSuiteInvocationResponseModel]: + """ + Gets a test invocation by ID. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetTestSuiteInvocationResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestSuiteInvocationResponseModel, + construct_type( + type_=GetTestSuiteInvocationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def resubmit( + self, + test_invocation_id: str, + *, + test_run_ids: typing.Sequence[str], + agent_id: str, + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Resubmits specific test runs from a test invocation. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + test_run_ids : typing.Sequence[str] + List of test run IDs to resubmit + + agent_id : str + Agent ID to resubmit tests for + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}/resubmit", + method="POST", + json={ + "test_run_ids": test_run_ids, + "agent_config_override": convert_and_respect_annotation_metadata( + object_=agent_config_override, + annotation=AdhocAgentConfigOverrideForTestRequestModel, + direction="write", + ), + "agent_id": agent_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if _response is None or not _response.text.strip(): + return HttpResponse(response=_response, data=None) + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawInvocationsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetTestSuiteInvocationResponseModel]: + """ + Gets a test invocation by ID. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetTestSuiteInvocationResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestSuiteInvocationResponseModel, + construct_type( + type_=GetTestSuiteInvocationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def resubmit( + self, + test_invocation_id: str, + *, + test_run_ids: typing.Sequence[str], + agent_id: str, + agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Resubmits specific test runs from a test invocation. + + Parameters + ---------- + test_invocation_id : str + The id of a test invocation. This is returned when tests are run. + + test_run_ids : typing.Sequence[str] + List of test run IDs to resubmit + + agent_id : str + Agent ID to resubmit tests for + + agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] + Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}/resubmit", + method="POST", + json={ + "test_run_ids": test_run_ids, + "agent_config_override": convert_and_respect_annotation_metadata( + object_=agent_config_override, + annotation=AdhocAgentConfigOverrideForTestRequestModel, + direction="write", + ), + "agent_id": agent_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if _response is None or not _response.text.strip(): + return AsyncHttpResponse(response=_response, data=None) + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/tests/raw_client.py b/src/elevenlabs/conversational_ai/tests/raw_client.py new file mode 100644 index 00000000..1194d582 --- /dev/null +++ b/src/elevenlabs/conversational_ai/tests/raw_client.py @@ -0,0 +1,919 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.agent_failure_response_example import AgentFailureResponseExample +from ...types.agent_successful_response_example import AgentSuccessfulResponseExample +from ...types.conversation_history_transcript_common_model_input import ConversationHistoryTranscriptCommonModelInput +from ...types.create_unit_test_response_model import CreateUnitTestResponseModel +from ...types.get_tests_page_response_model import GetTestsPageResponseModel +from ...types.get_tests_summaries_by_ids_response_model import GetTestsSummariesByIdsResponseModel +from ...types.get_unit_test_response_model import GetUnitTestResponseModel +from ...types.http_validation_error import HttpValidationError +from ...types.unit_test_tool_call_evaluation_model_input import UnitTestToolCallEvaluationModelInput +from .types.create_unit_test_request_dynamic_variables_value import CreateUnitTestRequestDynamicVariablesValue +from .types.update_unit_test_request_dynamic_variables_value import UpdateUnitTestRequestDynamicVariablesValue + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawTestsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CreateUnitTestResponseModel]: + """ + Creates a new agent response test. + + Parameters + ---------- + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreateUnitTestResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/agent-testing/create", + method="POST", + json={ + "chat_history": convert_and_respect_annotation_metadata( + object_=chat_history, + annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + direction="write", + ), + "success_condition": success_condition, + "success_examples": convert_and_respect_annotation_metadata( + object_=success_examples, + annotation=typing.Sequence[AgentSuccessfulResponseExample], + direction="write", + ), + "failure_examples": convert_and_respect_annotation_metadata( + object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" + ), + "tool_call_parameters": convert_and_respect_annotation_metadata( + object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" + ), + "dynamic_variables": convert_and_respect_annotation_metadata( + object_=dynamic_variables, + annotation=typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]], + direction="write", + ), + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateUnitTestResponseModel, + construct_type( + type_=CreateUnitTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetUnitTestResponseModel]: + """ + Gets an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetUnitTestResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetUnitTestResponseModel, + construct_type( + type_=GetUnitTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + test_id: str, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetUnitTestResponseModel]: + """ + Updates an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetUnitTestResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", + method="PUT", + json={ + "chat_history": convert_and_respect_annotation_metadata( + object_=chat_history, + annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + direction="write", + ), + "success_condition": success_condition, + "success_examples": convert_and_respect_annotation_metadata( + object_=success_examples, + annotation=typing.Sequence[AgentSuccessfulResponseExample], + direction="write", + ), + "failure_examples": convert_and_respect_annotation_metadata( + object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" + ), + "tool_call_parameters": convert_and_respect_annotation_metadata( + object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" + ), + "dynamic_variables": convert_and_respect_annotation_metadata( + object_=dynamic_variables, + annotation=typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]], + direction="write", + ), + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetUnitTestResponseModel, + construct_type( + type_=GetUnitTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Deletes an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if _response is None or not _response.text.strip(): + return HttpResponse(response=_response, data=None) + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def summaries( + self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetTestsSummariesByIdsResponseModel]: + """ + Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. + + Parameters + ---------- + test_ids : typing.Sequence[str] + List of test IDs to fetch. No duplicates allowed. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetTestsSummariesByIdsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/agent-testing/summaries", + method="POST", + json={ + "test_ids": test_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestsSummariesByIdsResponseModel, + construct_type( + type_=GetTestsSummariesByIdsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetTestsPageResponseModel]: + """ + Lists all agent response tests with pagination support and optional search filtering. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Tests to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search query to filter tests by name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetTestsPageResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/agent-testing", + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + "search": search, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestsPageResponseModel, + construct_type( + type_=GetTestsPageResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawTestsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CreateUnitTestResponseModel]: + """ + Creates a new agent response test. + + Parameters + ---------- + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreateUnitTestResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/agent-testing/create", + method="POST", + json={ + "chat_history": convert_and_respect_annotation_metadata( + object_=chat_history, + annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + direction="write", + ), + "success_condition": success_condition, + "success_examples": convert_and_respect_annotation_metadata( + object_=success_examples, + annotation=typing.Sequence[AgentSuccessfulResponseExample], + direction="write", + ), + "failure_examples": convert_and_respect_annotation_metadata( + object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" + ), + "tool_call_parameters": convert_and_respect_annotation_metadata( + object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" + ), + "dynamic_variables": convert_and_respect_annotation_metadata( + object_=dynamic_variables, + annotation=typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]], + direction="write", + ), + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateUnitTestResponseModel, + construct_type( + type_=CreateUnitTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetUnitTestResponseModel]: + """ + Gets an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetUnitTestResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetUnitTestResponseModel, + construct_type( + type_=GetUnitTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + test_id: str, + *, + chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + success_condition: str, + success_examples: typing.Sequence[AgentSuccessfulResponseExample], + failure_examples: typing.Sequence[AgentFailureResponseExample], + name: str, + tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, + dynamic_variables: typing.Optional[ + typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetUnitTestResponseModel]: + """ + Updates an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] + + success_condition : str + A prompt that evaluates whether the agent's response is successful. Should return True or False. + + success_examples : typing.Sequence[AgentSuccessfulResponseExample] + Non-empty list of example responses that should be considered successful + + failure_examples : typing.Sequence[AgentFailureResponseExample] + Non-empty list of example responses that should be considered failures + + name : str + + tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] + How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. + + dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] + Dynamic variables to replace in the agent config during testing + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetUnitTestResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", + method="PUT", + json={ + "chat_history": convert_and_respect_annotation_metadata( + object_=chat_history, + annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], + direction="write", + ), + "success_condition": success_condition, + "success_examples": convert_and_respect_annotation_metadata( + object_=success_examples, + annotation=typing.Sequence[AgentSuccessfulResponseExample], + direction="write", + ), + "failure_examples": convert_and_respect_annotation_metadata( + object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" + ), + "tool_call_parameters": convert_and_respect_annotation_metadata( + object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" + ), + "dynamic_variables": convert_and_respect_annotation_metadata( + object_=dynamic_variables, + annotation=typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]], + direction="write", + ), + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetUnitTestResponseModel, + construct_type( + type_=GetUnitTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Deletes an agent response test by ID. + + Parameters + ---------- + test_id : str + The id of a chat response test. This is returned on test creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if _response is None or not _response.text.strip(): + return AsyncHttpResponse(response=_response, data=None) + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def summaries( + self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetTestsSummariesByIdsResponseModel]: + """ + Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. + + Parameters + ---------- + test_ids : typing.Sequence[str] + List of test IDs to fetch. No duplicates allowed. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetTestsSummariesByIdsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/agent-testing/summaries", + method="POST", + json={ + "test_ids": test_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestsSummariesByIdsResponseModel, + construct_type( + type_=GetTestsSummariesByIdsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetTestsPageResponseModel]: + """ + Lists all agent response tests with pagination support and optional search filtering. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Tests to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search query to filter tests by name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetTestsPageResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/agent-testing", + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + "search": search, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetTestsPageResponseModel, + construct_type( + type_=GetTestsPageResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/tests/types/__init__.py b/src/elevenlabs/conversational_ai/tests/types/__init__.py new file mode 100644 index 00000000..69b19600 --- /dev/null +++ b/src/elevenlabs/conversational_ai/tests/types/__init__.py @@ -0,0 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .create_unit_test_request_dynamic_variables_value import CreateUnitTestRequestDynamicVariablesValue +from .update_unit_test_request_dynamic_variables_value import UpdateUnitTestRequestDynamicVariablesValue + +__all__ = ["CreateUnitTestRequestDynamicVariablesValue", "UpdateUnitTestRequestDynamicVariablesValue"] diff --git a/src/elevenlabs/types/create_unit_test_request_dynamic_variables_value.py b/src/elevenlabs/conversational_ai/tests/types/create_unit_test_request_dynamic_variables_value.py similarity index 100% rename from src/elevenlabs/types/create_unit_test_request_dynamic_variables_value.py rename to src/elevenlabs/conversational_ai/tests/types/create_unit_test_request_dynamic_variables_value.py diff --git a/src/elevenlabs/types/update_unit_test_request_dynamic_variables_value.py b/src/elevenlabs/conversational_ai/tests/types/update_unit_test_request_dynamic_variables_value.py similarity index 100% rename from src/elevenlabs/types/update_unit_test_request_dynamic_variables_value.py rename to src/elevenlabs/conversational_ai/tests/types/update_unit_test_request_dynamic_variables_value.py diff --git a/src/elevenlabs/core/client_wrapper.py b/src/elevenlabs/core/client_wrapper.py index 74ba0faa..905074d5 100644 --- a/src/elevenlabs/core/client_wrapper.py +++ b/src/elevenlabs/core/client_wrapper.py @@ -14,10 +14,10 @@ def __init__(self, *, api_key: typing.Optional[str] = None, base_url: str, timeo def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { - "User-Agent": "elevenlabs/v2.12.0", + "User-Agent": "elevenlabs/v2.12.1", "X-Fern-Language": "Python", "X-Fern-SDK-Name": "elevenlabs", - "X-Fern-SDK-Version": "v2.12.0", + "X-Fern-SDK-Version": "v2.12.1", } if self._api_key is not None: headers["xi-api-key"] = self._api_key diff --git a/src/elevenlabs/raw_base_client.py b/src/elevenlabs/raw_base_client.py index 806eaa3b..0cdebbe0 100644 --- a/src/elevenlabs/raw_base_client.py +++ b/src/elevenlabs/raw_base_client.py @@ -6,680 +6,13 @@ from .core.api_error import ApiError from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .core.http_response import AsyncHttpResponse, HttpResponse -from .core.jsonable_encoder import jsonable_encoder from .core.request_options import RequestOptions -from .core.serialization import convert_and_respect_annotation_metadata -from .core.unchecked_base_model import construct_type -from .errors.unprocessable_entity_error import UnprocessableEntityError -from .types.adhoc_agent_config_override_for_test_request_model import AdhocAgentConfigOverrideForTestRequestModel -from .types.agent_failure_response_example import AgentFailureResponseExample -from .types.agent_successful_response_example import AgentSuccessfulResponseExample -from .types.conversation_history_transcript_common_model_input import ConversationHistoryTranscriptCommonModelInput -from .types.create_unit_test_request_dynamic_variables_value import CreateUnitTestRequestDynamicVariablesValue -from .types.create_unit_test_response_model import CreateUnitTestResponseModel -from .types.get_test_suite_invocation_response_model import GetTestSuiteInvocationResponseModel -from .types.get_tests_page_response_model import GetTestsPageResponseModel -from .types.get_tests_summaries_by_ids_response_model import GetTestsSummariesByIdsResponseModel -from .types.get_unit_test_response_model import GetUnitTestResponseModel -from .types.http_validation_error import HttpValidationError -from .types.single_test_run_request_model import SingleTestRunRequestModel -from .types.unit_test_tool_call_evaluation_model_input import UnitTestToolCallEvaluationModelInput -from .types.update_unit_test_request_dynamic_variables_value import UpdateUnitTestRequestDynamicVariablesValue - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) class RawBaseElevenLabs: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def create_agent_response_test_route( - self, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[CreateUnitTestResponseModel]: - """ - Creates a new agent response test. - - Parameters - ---------- - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[CreateUnitTestResponseModel] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/agent-testing/create", - method="POST", - json={ - "chat_history": convert_and_respect_annotation_metadata( - object_=chat_history, - annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - direction="write", - ), - "success_condition": success_condition, - "success_examples": convert_and_respect_annotation_metadata( - object_=success_examples, - annotation=typing.Sequence[AgentSuccessfulResponseExample], - direction="write", - ), - "failure_examples": convert_and_respect_annotation_metadata( - object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" - ), - "tool_call_parameters": convert_and_respect_annotation_metadata( - object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" - ), - "dynamic_variables": convert_and_respect_annotation_metadata( - object_=dynamic_variables, - annotation=typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]], - direction="write", - ), - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - CreateUnitTestResponseModel, - construct_type( - type_=CreateUnitTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def get_agent_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[GetUnitTestResponseModel]: - """ - Gets an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[GetUnitTestResponseModel] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetUnitTestResponseModel, - construct_type( - type_=GetUnitTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def update_agent_response_test_route( - self, - test_id: str, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[GetUnitTestResponseModel]: - """ - Updates an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[GetUnitTestResponseModel] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", - method="PUT", - json={ - "chat_history": convert_and_respect_annotation_metadata( - object_=chat_history, - annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - direction="write", - ), - "success_condition": success_condition, - "success_examples": convert_and_respect_annotation_metadata( - object_=success_examples, - annotation=typing.Sequence[AgentSuccessfulResponseExample], - direction="write", - ), - "failure_examples": convert_and_respect_annotation_metadata( - object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" - ), - "tool_call_parameters": convert_and_respect_annotation_metadata( - object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" - ), - "dynamic_variables": convert_and_respect_annotation_metadata( - object_=dynamic_variables, - annotation=typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]], - direction="write", - ), - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetUnitTestResponseModel, - construct_type( - type_=GetUnitTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def delete_chat_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[typing.Optional[typing.Any]]: - """ - Deletes an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[typing.Optional[typing.Any]] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", - method="DELETE", - request_options=request_options, - ) - try: - if _response is None or not _response.text.strip(): - return HttpResponse(response=_response, data=None) - if 200 <= _response.status_code < 300: - _data = typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def get_agent_response_tests_summaries_route( - self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[GetTestsSummariesByIdsResponseModel]: - """ - Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. - - Parameters - ---------- - test_ids : typing.Sequence[str] - List of test IDs to fetch. No duplicates allowed. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[GetTestsSummariesByIdsResponseModel] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/agent-testing/summaries", - method="POST", - json={ - "test_ids": test_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestsSummariesByIdsResponseModel, - construct_type( - type_=GetTestsSummariesByIdsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def list_chat_response_tests_route( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[GetTestsPageResponseModel]: - """ - Lists all agent response tests with pagination support and optional search filtering. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many Tests to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - Search query to filter tests by name. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[GetTestsPageResponseModel] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/agent-testing", - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - "search": search, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestsPageResponseModel, - construct_type( - type_=GetTestsPageResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def run_agent_test_suite_route( - self, - agent_id: str, - *, - tests: typing.Sequence[SingleTestRunRequestModel], - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[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. - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - tests : typing.Sequence[SingleTestRunRequestModel] - List of tests to run on the agent - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[GetTestSuiteInvocationResponseModel] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/run-tests", - method="POST", - json={ - "tests": convert_and_respect_annotation_metadata( - object_=tests, annotation=typing.Sequence[SingleTestRunRequestModel], direction="write" - ), - "agent_config_override": convert_and_respect_annotation_metadata( - object_=agent_config_override, - annotation=AdhocAgentConfigOverrideForTestRequestModel, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestSuiteInvocationResponseModel, - construct_type( - type_=GetTestSuiteInvocationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def get_test_invocation_route( - self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> HttpResponse[GetTestSuiteInvocationResponseModel]: - """ - Gets a test invocation by ID. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[GetTestSuiteInvocationResponseModel] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestSuiteInvocationResponseModel, - construct_type( - type_=GetTestSuiteInvocationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - def resubmit_tests_route( - self, - test_invocation_id: str, - *, - test_run_ids: typing.Sequence[str], - agent_id: str, - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[typing.Optional[typing.Any]]: - """ - Resubmits specific test runs from a test invocation. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - test_run_ids : typing.Sequence[str] - List of test run IDs to resubmit - - agent_id : str - Agent ID to resubmit tests for - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[typing.Optional[typing.Any]] - Successful Response - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}/resubmit", - method="POST", - json={ - "test_run_ids": test_run_ids, - "agent_config_override": convert_and_respect_annotation_metadata( - object_=agent_config_override, - annotation=AdhocAgentConfigOverrideForTestRequestModel, - direction="write", - ), - "agent_id": agent_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if _response is None or not _response.text.strip(): - return HttpResponse(response=_response, data=None) - if 200 <= _response.status_code < 300: - _data = typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def save_a_voice_preview(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: """ Add a generated voice to the voice library. @@ -711,652 +44,6 @@ class AsyncRawBaseElevenLabs: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def create_agent_response_test_route( - self, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[CreateUnitTestResponseModel]: - """ - Creates a new agent response test. - - Parameters - ---------- - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[CreateUnitTestResponseModel] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/agent-testing/create", - method="POST", - json={ - "chat_history": convert_and_respect_annotation_metadata( - object_=chat_history, - annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - direction="write", - ), - "success_condition": success_condition, - "success_examples": convert_and_respect_annotation_metadata( - object_=success_examples, - annotation=typing.Sequence[AgentSuccessfulResponseExample], - direction="write", - ), - "failure_examples": convert_and_respect_annotation_metadata( - object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" - ), - "tool_call_parameters": convert_and_respect_annotation_metadata( - object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" - ), - "dynamic_variables": convert_and_respect_annotation_metadata( - object_=dynamic_variables, - annotation=typing.Dict[str, typing.Optional[CreateUnitTestRequestDynamicVariablesValue]], - direction="write", - ), - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - CreateUnitTestResponseModel, - construct_type( - type_=CreateUnitTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def get_agent_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[GetUnitTestResponseModel]: - """ - Gets an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[GetUnitTestResponseModel] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetUnitTestResponseModel, - construct_type( - type_=GetUnitTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def update_agent_response_test_route( - self, - test_id: str, - *, - chat_history: typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - success_condition: str, - success_examples: typing.Sequence[AgentSuccessfulResponseExample], - failure_examples: typing.Sequence[AgentFailureResponseExample], - name: str, - tool_call_parameters: typing.Optional[UnitTestToolCallEvaluationModelInput] = OMIT, - dynamic_variables: typing.Optional[ - typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]] - ] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[GetUnitTestResponseModel]: - """ - Updates an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - chat_history : typing.Sequence[ConversationHistoryTranscriptCommonModelInput] - - success_condition : str - A prompt that evaluates whether the agent's response is successful. Should return True or False. - - success_examples : typing.Sequence[AgentSuccessfulResponseExample] - Non-empty list of example responses that should be considered successful - - failure_examples : typing.Sequence[AgentFailureResponseExample] - Non-empty list of example responses that should be considered failures - - name : str - - tool_call_parameters : typing.Optional[UnitTestToolCallEvaluationModelInput] - How to evaluate the agent's tool call (if any). If empty, the tool call is not evaluated. - - dynamic_variables : typing.Optional[typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]]] - Dynamic variables to replace in the agent config during testing - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[GetUnitTestResponseModel] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", - method="PUT", - json={ - "chat_history": convert_and_respect_annotation_metadata( - object_=chat_history, - annotation=typing.Sequence[ConversationHistoryTranscriptCommonModelInput], - direction="write", - ), - "success_condition": success_condition, - "success_examples": convert_and_respect_annotation_metadata( - object_=success_examples, - annotation=typing.Sequence[AgentSuccessfulResponseExample], - direction="write", - ), - "failure_examples": convert_and_respect_annotation_metadata( - object_=failure_examples, annotation=typing.Sequence[AgentFailureResponseExample], direction="write" - ), - "tool_call_parameters": convert_and_respect_annotation_metadata( - object_=tool_call_parameters, annotation=UnitTestToolCallEvaluationModelInput, direction="write" - ), - "dynamic_variables": convert_and_respect_annotation_metadata( - object_=dynamic_variables, - annotation=typing.Dict[str, typing.Optional[UpdateUnitTestRequestDynamicVariablesValue]], - direction="write", - ), - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetUnitTestResponseModel, - construct_type( - type_=GetUnitTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def delete_chat_response_test_route( - self, test_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: - """ - Deletes an agent response test by ID. - - Parameters - ---------- - test_id : str - The id of a chat response test. This is returned on test creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[typing.Optional[typing.Any]] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agent-testing/{jsonable_encoder(test_id)}", - method="DELETE", - request_options=request_options, - ) - try: - if _response is None or not _response.text.strip(): - return AsyncHttpResponse(response=_response, data=None) - if 200 <= _response.status_code < 300: - _data = typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def get_agent_response_tests_summaries_route( - self, *, test_ids: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[GetTestsSummariesByIdsResponseModel]: - """ - Gets multiple agent response tests by their IDs. Returns a dictionary mapping test IDs to test summaries. - - Parameters - ---------- - test_ids : typing.Sequence[str] - List of test IDs to fetch. No duplicates allowed. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[GetTestsSummariesByIdsResponseModel] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/agent-testing/summaries", - method="POST", - json={ - "test_ids": test_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestsSummariesByIdsResponseModel, - construct_type( - type_=GetTestsSummariesByIdsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def list_chat_response_tests_route( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[GetTestsPageResponseModel]: - """ - Lists all agent response tests with pagination support and optional search filtering. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many Tests to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - Search query to filter tests by name. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[GetTestsPageResponseModel] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/agent-testing", - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - "search": search, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestsPageResponseModel, - construct_type( - type_=GetTestsPageResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def run_agent_test_suite_route( - self, - agent_id: str, - *, - tests: typing.Sequence[SingleTestRunRequestModel], - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[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. - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - tests : typing.Sequence[SingleTestRunRequestModel] - List of tests to run on the agent - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[GetTestSuiteInvocationResponseModel] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/run-tests", - method="POST", - json={ - "tests": convert_and_respect_annotation_metadata( - object_=tests, annotation=typing.Sequence[SingleTestRunRequestModel], direction="write" - ), - "agent_config_override": convert_and_respect_annotation_metadata( - object_=agent_config_override, - annotation=AdhocAgentConfigOverrideForTestRequestModel, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestSuiteInvocationResponseModel, - construct_type( - type_=GetTestSuiteInvocationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def get_test_invocation_route( - self, test_invocation_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> AsyncHttpResponse[GetTestSuiteInvocationResponseModel]: - """ - Gets a test invocation by ID. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[GetTestSuiteInvocationResponseModel] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}", - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - GetTestSuiteInvocationResponseModel, - construct_type( - type_=GetTestSuiteInvocationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - - async def resubmit_tests_route( - self, - test_invocation_id: str, - *, - test_run_ids: typing.Sequence[str], - agent_id: str, - agent_config_override: typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: - """ - Resubmits specific test runs from a test invocation. - - Parameters - ---------- - test_invocation_id : str - The id of a test invocation. This is returned when tests are run. - - test_run_ids : typing.Sequence[str] - List of test run IDs to resubmit - - agent_id : str - Agent ID to resubmit tests for - - agent_config_override : typing.Optional[AdhocAgentConfigOverrideForTestRequestModel] - Configuration overrides to use for testing. If not provided, the agent's default configuration will be used. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[typing.Optional[typing.Any]] - Successful Response - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/test-invocations/{jsonable_encoder(test_invocation_id)}/resubmit", - method="POST", - json={ - "test_run_ids": test_run_ids, - "agent_config_override": convert_and_respect_annotation_metadata( - object_=agent_config_override, - annotation=AdhocAgentConfigOverrideForTestRequestModel, - direction="write", - ), - "agent_id": agent_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if _response is None or not _response.text.strip(): - return AsyncHttpResponse(response=_response, data=None) - if 200 <= _response.status_code < 300: - _data = typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 422: - raise UnprocessableEntityError( - headers=dict(_response.headers), - body=typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def save_a_voice_preview( self, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[None]: diff --git a/src/elevenlabs/types/__init__.py b/src/elevenlabs/types/__init__.py index 262a77b6..da109c98 100644 --- a/src/elevenlabs/types/__init__.py +++ b/src/elevenlabs/types/__init__.py @@ -264,7 +264,6 @@ from .create_sip_trunk_phone_number_request import CreateSipTrunkPhoneNumberRequest from .create_transcript_request import CreateTranscriptRequest from .create_twilio_phone_number_request import CreateTwilioPhoneNumberRequest -from .create_unit_test_request_dynamic_variables_value import CreateUnitTestRequestDynamicVariablesValue from .create_unit_test_response_model import CreateUnitTestResponseModel from .custom_llm import CustomLlm from .custom_llm_request_headers_value import CustomLlmRequestHeadersValue @@ -712,6 +711,7 @@ from .test_condition_result_common_model import TestConditionResultCommonModel from .test_run_status import TestRunStatus from .test_tool_result_model import TestToolResultModel +from .tests_feature_usage_common_model import TestsFeatureUsageCommonModel from .text_to_speech_apply_text_normalization_enum import TextToSpeechApplyTextNormalizationEnum from .text_to_speech_output_format_enum import TextToSpeechOutputFormatEnum from .text_to_speech_stream_request import TextToSpeechStreamRequest @@ -774,7 +774,6 @@ from .update_chapter_request import UpdateChapterRequest from .update_project_request import UpdateProjectRequest from .update_pronunciation_dictionaries_request import UpdatePronunciationDictionariesRequest -from .update_unit_test_request_dynamic_variables_value import UpdateUnitTestRequestDynamicVariablesValue from .update_workspace_member_response_model import UpdateWorkspaceMemberResponseModel from .url_avatar import UrlAvatar from .usage_aggregation_interval import UsageAggregationInterval @@ -1094,7 +1093,6 @@ "CreateSipTrunkPhoneNumberRequest", "CreateTranscriptRequest", "CreateTwilioPhoneNumberRequest", - "CreateUnitTestRequestDynamicVariablesValue", "CreateUnitTestResponseModel", "CustomLlm", "CustomLlmRequestHeadersValue", @@ -1504,6 +1502,7 @@ "TestConditionResultCommonModel", "TestRunStatus", "TestToolResultModel", + "TestsFeatureUsageCommonModel", "TextToSpeechApplyTextNormalizationEnum", "TextToSpeechOutputFormatEnum", "TextToSpeechStreamRequest", @@ -1560,7 +1559,6 @@ "UpdateChapterRequest", "UpdateProjectRequest", "UpdatePronunciationDictionariesRequest", - "UpdateUnitTestRequestDynamicVariablesValue", "UpdateWorkspaceMemberResponseModel", "UrlAvatar", "UsageAggregationInterval", diff --git a/src/elevenlabs/types/client_event.py b/src/elevenlabs/types/client_event.py index 17fd0241..c0f65f7e 100644 --- a/src/elevenlabs/types/client_event.py +++ b/src/elevenlabs/types/client_event.py @@ -10,6 +10,7 @@ "audio", "interruption", "user_transcript", + "tentative_user_transcript", "agent_response", "agent_response_correction", "client_tool_call", diff --git a/src/elevenlabs/types/features_usage_common_model.py b/src/elevenlabs/types/features_usage_common_model.py index 06b4f7dd..0ef0a32f 100644 --- a/src/elevenlabs/types/features_usage_common_model.py +++ b/src/elevenlabs/types/features_usage_common_model.py @@ -6,6 +6,7 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .feature_status_common_model import FeatureStatusCommonModel +from .tests_feature_usage_common_model import TestsFeatureUsageCommonModel from .workflow_features_usage_common_model import WorkflowFeaturesUsageCommonModel @@ -22,6 +23,7 @@ class FeaturesUsageCommonModel(UncheckedBaseModel): is_livekit: typing.Optional[bool] = None voicemail_detection: typing.Optional[FeatureStatusCommonModel] = None workflow: typing.Optional[WorkflowFeaturesUsageCommonModel] = None + agent_testing: typing.Optional[TestsFeatureUsageCommonModel] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/elevenlabs/types/tests_feature_usage_common_model.py b/src/elevenlabs/types/tests_feature_usage_common_model.py new file mode 100644 index 00000000..aabb91ae --- /dev/null +++ b/src/elevenlabs/types/tests_feature_usage_common_model.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class TestsFeatureUsageCommonModel(UncheckedBaseModel): + enabled: typing.Optional[bool] = None + tests_ran_after_last_modification: typing.Optional[bool] = None + tests_ran_in_last_7_days: typing.Optional[bool] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/unit_test_run_response_model.py b/src/elevenlabs/types/unit_test_run_response_model.py index bc1ecde5..47eb234d 100644 --- a/src/elevenlabs/types/unit_test_run_response_model.py +++ b/src/elevenlabs/types/unit_test_run_response_model.py @@ -20,6 +20,7 @@ class UnitTestRunResponseModel(UncheckedBaseModel): agent_responses: typing.Optional[typing.List[ConversationHistoryTranscriptCommonModelOutput]] = None test_id: str condition_result: typing.Optional[TestConditionResultCommonModel] = None + last_updated_at_unix: typing.Optional[int] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2