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 SamplesClient

From Leeroopedia
Field Value
Sources src/elevenlabs/samples/client.py, src/elevenlabs/samples/raw_client.py
Domains Voice Samples, Voice Management
Last Updated 2026-02-15

Overview

The SamplesClient provides methods for managing voice samples in the ElevenLabs API. Voice samples are audio recordings associated with a specific voice that are used for voice cloning and customization. This client currently exposes a single delete() method that removes a sample by its ID from a given voice.

The client is accessible via client.samples on an ElevenLabs instance. Both synchronous (SamplesClient) and asynchronous (AsyncSamplesClient) variants are provided. A raw response variant is available via the with_raw_response property, which returns HttpResponse objects containing both the parsed data and the underlying HTTP response.

API Endpoints

Method HTTP Endpoint
delete() DELETE v1/voices/{voice_id}/samples/{sample_id}

Code Reference

Source Location

  • High-level client: src/elevenlabs/samples/client.py
  • Raw client: src/elevenlabs/samples/raw_client.py

Class Signatures

class SamplesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper): ...

class AsyncSamplesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper): ...

Import

The client is not typically imported directly. Instead, it is accessed through the main ElevenLabs client:

from elevenlabs import ElevenLabs

client = ElevenLabs(api_key="YOUR_API_KEY")
client.samples  # SamplesClient instance

I/O Contract

delete()

Removes a sample by its ID from a specified voice.

Input Parameters:

Parameter Type Required Description
voice_id str Yes ID of the voice to be used. You can use the Get voices endpoint to list all available voices.
sample_id str Yes ID of the sample to be removed. You can use the Get voices endpoint to list all available samples for a voice.
request_options typing.Optional[RequestOptions] No Request-specific configuration.

Output:

Type Description
DeleteSampleResponse Deletion confirmation response.

Error Handling

All methods may raise:

  • UnprocessableEntityError (HTTP 422) -- contains an HttpValidationError body with validation details.
  • ApiError -- for all other non-2xx HTTP status codes.

Usage Examples

Delete a Voice Sample

from elevenlabs import ElevenLabs

client = ElevenLabs(
    api_key="YOUR_API_KEY",
)
response = client.samples.delete(
    voice_id="21m00Tcm4TlvDq8ikWAM",
    sample_id="VW7YKqPnjY4h39yTbx2L",
)

Async Usage

import asyncio
from elevenlabs import AsyncElevenLabs

client = AsyncElevenLabs(
    api_key="YOUR_API_KEY",
)

async def main() -> None:
    response = await client.samples.delete(
        voice_id="21m00Tcm4TlvDq8ikWAM",
        sample_id="VW7YKqPnjY4h39yTbx2L",
    )

asyncio.run(main())

Raw Response Access

from elevenlabs import ElevenLabs

client = ElevenLabs(api_key="YOUR_API_KEY")

raw_response = client.samples.with_raw_response.delete(
    voice_id="21m00Tcm4TlvDq8ikWAM",
    sample_id="VW7YKqPnjY4h39yTbx2L",
)
print(raw_response.response.status_code)
print(raw_response.data)

Related Pages

Page Connections

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