Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Elevenlabs Elevenlabs python GetVoicesV2Response

From Leeroopedia
Revision as of 12:25, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Elevenlabs_Elevenlabs_python_GetVoicesV2Response.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Attribute Value
Sources src/elevenlabs/types/get_voices_v_2_response.py
Domains Voice Management, Pagination
Last Updated 2026-02-15

Overview

Description

The GetVoicesV2Response model represents a paginated response from the ElevenLabs V2 voice listing API. It contains a list of Voice objects matching the query, along with pagination controls (has_more, next_page_token) and a total count. This model supports token-based pagination, where the has_more flag and next_page_token are the recommended approach for iterating through results.

Usage

This model is the primary response type for the V2 voices listing endpoint. It allows callers to retrieve voices in pages, checking has_more to determine if additional pages exist and passing next_page_token to subsequent requests. The total_count field is available for display purposes but should not be relied upon for pagination logic due to its live-snapshot nature.

Code Reference

Source Location

src/elevenlabs/types/get_voices_v_2_response.py

Class Signature

class GetVoicesV2Response(UncheckedBaseModel):
    ...

Import Statement

from elevenlabs.types import GetVoicesV2Response

Base Class

UncheckedBaseModel (from elevenlabs.core.unchecked_base_model)

I/O Contract

Field Type Required Description
voices List[Voice] Yes The list of voices matching the query.
has_more bool Yes Indicates whether there are more voices available in subsequent pages. Use this flag (and next_page_token) for reliable pagination instead of relying on total_count.
total_count int Yes The total count of voices matching the query. This is a live snapshot that may change between requests. Calculating it incurs a performance cost.
next_page_token Optional[str] No Token to retrieve the next page of results. Pass this value to the next request to continue pagination. Null if there are no more results.

Usage Examples

from elevenlabs import ElevenLabs

client = ElevenLabs(api_key="your_api_key")

# Fetch the first page of voices
response = client.voices.get_all_v2()
print(f"Total voices: {response.total_count}")
print(f"Voices in this page: {len(response.voices)}")

for voice in response.voices:
    print(f"  {voice.voice_id}: {voice.name}")

# Paginate through all voices
all_voices = list(response.voices)
while response.has_more and response.next_page_token:
    response = client.voices.get_all_v2(
        next_page_token=response.next_page_token
    )
    all_voices.extend(response.voices)

print(f"Fetched {len(all_voices)} voices in total")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment