Skip to content

Latest commit

 

History

History
6108 lines (4203 loc) · 96.8 KB

File metadata and controls

6108 lines (4203 loc) · 96.8 KB

Reference

Agent V1 Settings Think Models

client.agent.v1.settings.think.models.list() -> AsyncHttpResponse[AgentThinkModelsV1Response]

📝 Description

Retrieves the available think models that can be used for AI agent processing

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.agent.v1.settings.think.models.list()

⚙️ Parameters

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Auth V1 Tokens

client.auth.v1.tokens.grant(...) -> AsyncHttpResponse[GrantV1Response]

📝 Description

Generates a temporary JSON Web Token (JWT) with a 30-second (by default) TTL and usage::write permission for core voice APIs, requiring an API key with Member or higher authorization. Tokens created with this endpoint will not work with the Manage APIs.

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.auth.v1.tokens.grant()

⚙️ Parameters

ttl_seconds: typing.Optional[float] — Time to live in seconds for the token. Defaults to 30 seconds.

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Listen V1 Media

client.listen.v1.media.transcribe_url(...) -> AsyncHttpResponse[MediaTranscribeResponse]

📝 Description

Transcribe audio and video using Deepgram's speech-to-text REST API

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.listen.v1.media.transcribe_url(
    callback="callback",
    callback_method="POST",
    extra="extra",
    sentiment=True,
    summarize="v2",
    tag="tag",
    topics=True,
    custom_topic="custom_topic",
    custom_topic_mode="extended",
    intents=True,
    custom_intent="custom_intent",
    custom_intent_mode="extended",
    detect_entities=True,
    detect_language=True,
    diarize=True,
    dictation=True,
    encoding="linear16",
    filler_words=True,
    keywords="keywords",
    language="language",
    measurements=True,
    model="nova-3",
    multichannel=True,
    numerals=True,
    paragraphs=True,
    profanity_filter=True,
    punctuate=True,
    redact="redact",
    replace="replace",
    search="search",
    smart_format=True,
    utterances=True,
    utt_split=1.1,
    version="latest",
    mip_opt_out=True,
    url="https://dpgr.am/spacewalk.wav",
)

⚙️ Parameters

url: str

callback: typing.Optional[str] — URL to which we'll make the callback request

callback_method: typing.Optional[MediaTranscribeRequestCallbackMethod] — HTTP method by which the callback request will be made

extra: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

sentiment: typing.Optional[bool] — Recognizes the sentiment throughout a transcript or text

summarize: typing.Optional[MediaTranscribeRequestSummarize] — Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

tag: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Label your requests for the purpose of identification during usage reporting

topics: typing.Optional[bool] — Detect topics throughout a transcript or text

custom_topic: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

custom_topic_mode: typing.Optional[MediaTranscribeRequestCustomTopicMode] — Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

intents: typing.Optional[bool] — Recognizes speaker intent throughout a transcript or text

custom_intent: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Custom intents you want the model to detect within your input audio if present

custom_intent_mode: typing.Optional[MediaTranscribeRequestCustomIntentMode] — Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

detect_entities: typing.Optional[bool] — Identifies and extracts key entities from content in submitted audio

detect_language: typing.Optional[bool] — Identifies the dominant language spoken in submitted audio

diarize: typing.Optional[bool] — Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0

dictation: typing.Optional[bool] — Dictation mode for controlling formatting with dictated speech

encoding: typing.Optional[MediaTranscribeRequestEncoding] — Specify the expected encoding of your submitted audio

filler_words: typing.Optional[bool] — Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

keyterm: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Key term prompting can boost or suppress specialized terminology and brands. Only compatible with Nova-3

keywords: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Keywords can boost or suppress specialized terminology and brands

language: typing.Optional[str] — The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

measurements: typing.Optional[bool] — Spoken measurements will be converted to their corresponding abbreviations

model: typing.Optional[MediaTranscribeRequestModel] — AI model used to process submitted audio

multichannel: typing.Optional[bool] — Transcribe each audio channel independently

numerals: typing.Optional[bool] — Numerals converts numbers from written format to numerical format

paragraphs: typing.Optional[bool] — Splits audio into paragraphs to improve transcript readability

profanity_filter: typing.Optional[bool] — Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

punctuate: typing.Optional[bool] — Add punctuation and capitalization to the transcript

redact: typing.Optional[str] — Redaction removes sensitive information from your transcripts

replace: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Search for terms or phrases in submitted audio and replaces them

search: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Search for terms or phrases in submitted audio

smart_format: typing.Optional[bool] — Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

utterances: typing.Optional[bool] — Segments speech into meaningful semantic units

utt_split: typing.Optional[float] — Seconds to wait before detecting a pause between words in submitted audio

version: typing.Optional[MediaTranscribeRequestVersion] — Version of an AI model to use

mip_opt_out: typing.Optional[bool] — Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.listen.v1.media.transcribe_file(...) -> AsyncHttpResponse[MediaTranscribeResponse]

📝 Description

Transcribe audio and video using Deepgram's speech-to-text REST API

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)

with open("audio.wav", "rb") as f:
    response = client.listen.v1.media.transcribe_file(request=f)

⚙️ Parameters

request: typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]

callback: typing.Optional[str] — URL to which we'll make the callback request

callback_method: typing.Optional[MediaTranscribeRequestCallbackMethod] — HTTP method by which the callback request will be made

extra: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

sentiment: typing.Optional[bool] — Recognizes the sentiment throughout a transcript or text

summarize: typing.Optional[MediaTranscribeRequestSummarize] — Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

tag: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Label your requests for the purpose of identification during usage reporting

topics: typing.Optional[bool] — Detect topics throughout a transcript or text

custom_topic: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

custom_topic_mode: typing.Optional[MediaTranscribeRequestCustomTopicMode] — Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

intents: typing.Optional[bool] — Recognizes speaker intent throughout a transcript or text

custom_intent: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Custom intents you want the model to detect within your input audio if present

custom_intent_mode: typing.Optional[MediaTranscribeRequestCustomIntentMode] — Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

detect_entities: typing.Optional[bool] — Identifies and extracts key entities from content in submitted audio

detect_language: typing.Optional[bool] — Identifies the dominant language spoken in submitted audio

diarize: typing.Optional[bool] — Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0

dictation: typing.Optional[bool] — Dictation mode for controlling formatting with dictated speech

encoding: typing.Optional[MediaTranscribeRequestEncoding] — Specify the expected encoding of your submitted audio

filler_words: typing.Optional[bool] — Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

keyterm: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Key term prompting can boost or suppress specialized terminology and brands. Only compatible with Nova-3

keywords: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Keywords can boost or suppress specialized terminology and brands

language: typing.Optional[str] — The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

measurements: typing.Optional[bool] — Spoken measurements will be converted to their corresponding abbreviations

model: typing.Optional[MediaTranscribeRequestModel] — AI model used to process submitted audio

multichannel: typing.Optional[bool] — Transcribe each audio channel independently

numerals: typing.Optional[bool] — Numerals converts numbers from written format to numerical format

paragraphs: typing.Optional[bool] — Splits audio into paragraphs to improve transcript readability

profanity_filter: typing.Optional[bool] — Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

punctuate: typing.Optional[bool] — Add punctuation and capitalization to the transcript

redact: typing.Optional[str] — Redaction removes sensitive information from your transcripts

replace: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Search for terms or phrases in submitted audio and replaces them

search: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Search for terms or phrases in submitted audio

smart_format: typing.Optional[bool] — Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

utterances: typing.Optional[bool] — Segments speech into meaningful semantic units

utt_split: typing.Optional[float] — Seconds to wait before detecting a pause between words in submitted audio

version: typing.Optional[MediaTranscribeRequestVersion] — Version of an AI model to use

mip_opt_out: typing.Optional[bool] — Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Models

client.manage.v1.models.list(...) -> AsyncHttpResponse[ListModelsV1Response]

📝 Description

Returns metadata on all the latest public models. To retrieve custom models, use Get Project Models.

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.models.list(
    include_outdated=True,
)

⚙️ Parameters

include_outdated: typing.Optional[bool] — returns non-latest versions of models

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.models.get(...) -> AsyncHttpResponse[GetModelV1Response]

📝 Description

Returns metadata for a specific public model

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.models.get(
    model_id="af6e9977-99f6-4d8f-b6f5-dfdf6fb6e291",
)

⚙️ Parameters

model_id: str — The specific UUID of the model

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects

client.manage.v1.projects.list() -> AsyncHttpResponse[ListProjectsV1Response]

📝 Description

Retrieves basic information about the projects associated with the API key

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.list()

⚙️ Parameters

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.get(...) -> AsyncHttpResponse[GetProjectV1Response]

📝 Description

Retrieves information about the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.get(
    project_id="123456-7890-1234-5678-901234",
    limit=1.1,
    page=1.1,
)

⚙️ Parameters

project_id: str — The unique identifier of the project

limit: typing.Optional[float] — Number of results to return per page. Default 10. Range [1,1000]

page: typing.Optional[float] — Navigate and return the results to retrieve specific portions of information of the response

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.delete(...) -> AsyncHttpResponse[DeleteProjectV1Response]

📝 Description

Deletes the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.delete(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.update(...) -> AsyncHttpResponse[UpdateProjectV1Response]

📝 Description

Updates the name or other properties of an existing project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.update(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

name: typing.Optional[str] — The name of the project

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.leave(...) -> AsyncHttpResponse[LeaveProjectV1Response]

📝 Description

Removes the authenticated account from the specific project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.leave(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Keys

client.manage.v1.projects.keys.list(...) -> AsyncHttpResponse[ListProjectKeysV1Response]

📝 Description

Retrieves all API keys associated with the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.keys.list(
    project_id="123456-7890-1234-5678-901234",
    status="active",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

status: typing.Optional[KeysListRequestStatus] — Only return keys with a specific status

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.keys.create(...) -> AsyncHttpResponse[CreateKeyV1Response]

📝 Description

Creates a new API key with specified settings for the project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.keys.create(
    project_id="project_id",
    request={"key": "value"},
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request: CreateKeyV1RequestOne

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.keys.get(...) -> AsyncHttpResponse[GetProjectKeyV1Response]

📝 Description

Retrieves information about a specified API key

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.keys.get(
    project_id="123456-7890-1234-5678-901234",
    key_id="123456789012345678901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

key_id: str — The unique identifier of the API key

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.keys.delete(...) -> AsyncHttpResponse[DeleteProjectKeyV1Response]

📝 Description

Deletes an API key for a specific project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.keys.delete(
    project_id="123456-7890-1234-5678-901234",
    key_id="123456789012345678901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

key_id: str — The unique identifier of the API key

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Members

client.manage.v1.projects.members.list(...) -> AsyncHttpResponse[ListProjectMembersV1Response]

📝 Description

Retrieves a list of members for a given project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.members.list(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.members.delete(...) -> AsyncHttpResponse[DeleteProjectMemberV1Response]

📝 Description

Removes a member from the project using their unique member ID

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.members.delete(
    project_id="123456-7890-1234-5678-901234",
    member_id="123456789012345678901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

member_id: str — The unique identifier of the Member

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Models

client.manage.v1.projects.models.list(...) -> AsyncHttpResponse[ListModelsV1Response]

📝 Description

Returns metadata on all the latest models that a specific project has access to, including non-public models

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.models.list(
    project_id="123456-7890-1234-5678-901234",
    include_outdated=True,
)

⚙️ Parameters

project_id: str — The unique identifier of the project

include_outdated: typing.Optional[bool] — returns non-latest versions of models

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.models.get(...) -> AsyncHttpResponse[GetModelV1Response]

📝 Description

Returns metadata for a specific model

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.models.get(
    project_id="123456-7890-1234-5678-901234",
    model_id="af6e9977-99f6-4d8f-b6f5-dfdf6fb6e291",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

model_id: str — The specific UUID of the model

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Requests

client.manage.v1.projects.requests.list(...) -> AsyncHttpResponse[ListProjectRequestsV1Response]

📝 Description

Generates a list of requests for a specific project

🔌 Usage

import datetime

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.requests.list(
    project_id="123456-7890-1234-5678-901234",
    start=datetime.datetime.fromisoformat(
        "2024-01-15 09:30:00+00:00",
    ),
    end=datetime.datetime.fromisoformat(
        "2024-01-15 09:30:00+00:00",
    ),
    limit=1.1,
    page=1.1,
    accessor="12345678-1234-1234-1234-123456789012",
    request_id="12345678-1234-1234-1234-123456789012",
    deployment="hosted",
    endpoint="listen",
    method="sync",
    status="succeeded",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

start: typing.Optional[dt.datetime] — Start date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

end: typing.Optional[dt.datetime] — End date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

limit: typing.Optional[float] — Number of results to return per page. Default 10. Range [1,1000]

page: typing.Optional[float] — Navigate and return the results to retrieve specific portions of information of the response

accessor: typing.Optional[str] — Filter for requests where a specific accessor was used

request_id: typing.Optional[str] — Filter for a specific request id

deployment: typing.Optional[RequestsListRequestDeployment] — Filter for requests where a specific deployment was used

endpoint: typing.Optional[RequestsListRequestEndpoint] — Filter for requests where a specific endpoint was used

method: typing.Optional[RequestsListRequestMethod] — Filter for requests where a specific method was used

status: typing.Optional[RequestsListRequestStatus] — Filter for requests that succeeded (status code < 300) or failed (status code >=400)

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.requests.get(...) -> AsyncHttpResponse[GetProjectRequestV1Response]

📝 Description

Retrieves a specific request for a specific project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.requests.get(
    project_id="123456-7890-1234-5678-901234",
    request_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request_id: str — The unique identifier of the request

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Usage

client.manage.v1.projects.usage.get(...) -> AsyncHttpResponse[UsageV1Response]

📝 Description

Retrieves the usage for a specific project. Use Get Project Usage Breakdown for a more comprehensive usage summary.

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.usage.get(
    project_id="123456-7890-1234-5678-901234",
    start="start",
    end="end",
    accessor="12345678-1234-1234-1234-123456789012",
    alternatives=True,
    callback_method=True,
    callback=True,
    channels=True,
    custom_intent_mode=True,
    custom_intent=True,
    custom_topic_mode=True,
    custom_topic=True,
    deployment="hosted",
    detect_entities=True,
    detect_language=True,
    diarize=True,
    dictation=True,
    encoding=True,
    endpoint="listen",
    extra=True,
    filler_words=True,
    intents=True,
    keyterm=True,
    keywords=True,
    language=True,
    measurements=True,
    method="sync",
    model="6f548761-c9c0-429a-9315-11a1d28499c8",
    multichannel=True,
    numerals=True,
    paragraphs=True,
    profanity_filter=True,
    punctuate=True,
    redact=True,
    replace=True,
    sample_rate=True,
    search=True,
    sentiment=True,
    smart_format=True,
    summarize=True,
    tag="tag1",
    topics=True,
    utt_split=True,
    utterances=True,
    version=True,
)

⚙️ Parameters

project_id: str — The unique identifier of the project

start: typing.Optional[str] — Start date of the requested date range. Format accepted is YYYY-MM-DD

end: typing.Optional[str] — End date of the requested date range. Format accepted is YYYY-MM-DD

accessor: typing.Optional[str] — Filter for requests where a specific accessor was used

alternatives: typing.Optional[bool] — Filter for requests where alternatives were used

callback_method: typing.Optional[bool] — Filter for requests where callback method was used

callback: typing.Optional[bool] — Filter for requests where callback was used

channels: typing.Optional[bool] — Filter for requests where channels were used

custom_intent_mode: typing.Optional[bool] — Filter for requests where custom intent mode was used

custom_intent: typing.Optional[bool] — Filter for requests where custom intent was used

custom_topic_mode: typing.Optional[bool] — Filter for requests where custom topic mode was used

custom_topic: typing.Optional[bool] — Filter for requests where custom topic was used

deployment: typing.Optional[UsageGetRequestDeployment] — Filter for requests where a specific deployment was used

detect_entities: typing.Optional[bool] — Filter for requests where detect entities was used

detect_language: typing.Optional[bool] — Filter for requests where detect language was used

diarize: typing.Optional[bool] — Filter for requests where diarize was used

dictation: typing.Optional[bool] — Filter for requests where dictation was used

encoding: typing.Optional[bool] — Filter for requests where encoding was used

endpoint: typing.Optional[UsageGetRequestEndpoint] — Filter for requests where a specific endpoint was used

extra: typing.Optional[bool] — Filter for requests where extra was used

filler_words: typing.Optional[bool] — Filter for requests where filler words was used

intents: typing.Optional[bool] — Filter for requests where intents was used

keyterm: typing.Optional[bool] — Filter for requests where keyterm was used

keywords: typing.Optional[bool] — Filter for requests where keywords was used

language: typing.Optional[bool] — Filter for requests where language was used

measurements: typing.Optional[bool] — Filter for requests where measurements were used

method: typing.Optional[UsageGetRequestMethod] — Filter for requests where a specific method was used

model: typing.Optional[str] — Filter for requests where a specific model uuid was used

multichannel: typing.Optional[bool] — Filter for requests where multichannel was used

numerals: typing.Optional[bool] — Filter for requests where numerals were used

paragraphs: typing.Optional[bool] — Filter for requests where paragraphs were used

profanity_filter: typing.Optional[bool] — Filter for requests where profanity filter was used

punctuate: typing.Optional[bool] — Filter for requests where punctuate was used

redact: typing.Optional[bool] — Filter for requests where redact was used

replace: typing.Optional[bool] — Filter for requests where replace was used

sample_rate: typing.Optional[bool] — Filter for requests where sample rate was used

search: typing.Optional[bool] — Filter for requests where search was used

sentiment: typing.Optional[bool] — Filter for requests where sentiment was used

smart_format: typing.Optional[bool] — Filter for requests where smart format was used

summarize: typing.Optional[bool] — Filter for requests where summarize was used

tag: typing.Optional[str] — Filter for requests where a specific tag was used

topics: typing.Optional[bool] — Filter for requests where topics was used

utt_split: typing.Optional[bool] — Filter for requests where utt split was used

utterances: typing.Optional[bool] — Filter for requests where utterances was used

version: typing.Optional[bool] — Filter for requests where version was used

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Billing Balances

client.manage.v1.projects.billing.balances.list(...) -> AsyncHttpResponse[ListProjectBalancesV1Response]

📝 Description

Generates a list of outstanding balances for the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.billing.balances.list(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.billing.balances.get(...) -> AsyncHttpResponse[GetProjectBalanceV1Response]

📝 Description

Retrieves details about the specified balance

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.billing.balances.get(
    project_id="123456-7890-1234-5678-901234",
    balance_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

balance_id: str — The unique identifier of the balance

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Billing Breakdown

client.manage.v1.projects.billing.breakdown.list(...) -> AsyncHttpResponse[BillingBreakdownV1Response]

📝 Description

Retrieves the billing summary for a specific project, with various filter options or by grouping options.

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.billing.breakdown.list(
    project_id="123456-7890-1234-5678-901234",
    start="start",
    end="end",
    accessor="12345678-1234-1234-1234-123456789012",
    deployment="hosted",
    tag="tag1",
    line_item="streaming::nova-3",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

start: typing.Optional[str] — Start date of the requested date range. Format accepted is YYYY-MM-DD

end: typing.Optional[str] — End date of the requested date range. Format accepted is YYYY-MM-DD

accessor: typing.Optional[str] — Filter for requests where a specific accessor was used

deployment: typing.Optional[BreakdownListRequestDeployment] — Filter for requests where a specific deployment was used

tag: typing.Optional[str] — Filter for requests where a specific tag was used

line_item: typing.Optional[str] — Filter requests by line item (e.g. streaming::nova-3)

grouping: typing.Optional[ typing.Union[ BreakdownListRequestGroupingItem, typing.Sequence[BreakdownListRequestGroupingItem], ] ] — Group billing breakdown by one or more dimensions (accessor, deployment, line_item, tags)

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Billing Fields

client.manage.v1.projects.billing.fields.list(...) -> AsyncHttpResponse[ListBillingFieldsV1Response]

📝 Description

Lists the accessors, deployment types, tags, and line items used for billing data in the specified time period. Use this endpoint if you want to filter your results from the Billing Breakdown endpoint and want to know what filters are available.

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.billing.fields.list(
    project_id="123456-7890-1234-5678-901234",
    start="start",
    end="end",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

start: typing.Optional[str] — Start date of the requested date range. Format accepted is YYYY-MM-DD

end: typing.Optional[str] — End date of the requested date range. Format accepted is YYYY-MM-DD

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Billing Purchases

client.manage.v1.projects.billing.purchases.list(...) -> AsyncHttpResponse[ListProjectPurchasesV1Response]

📝 Description

Returns the original purchased amount on an order transaction

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.billing.purchases.list(
    project_id="123456-7890-1234-5678-901234",
    limit=1.1,
)

⚙️ Parameters

project_id: str — The unique identifier of the project

limit: typing.Optional[float] — Number of results to return per page. Default 10. Range [1,1000]

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Members Invites

client.manage.v1.projects.members.invites.list(...) -> AsyncHttpResponse[ListProjectInvitesV1Response]

📝 Description

Generates a list of invites for a specific project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.members.invites.list(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.members.invites.create(...) -> AsyncHttpResponse[CreateProjectInviteV1Response]

📝 Description

Generates an invite for a specific project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.members.invites.create(
    project_id="123456-7890-1234-5678-901234",
    email="email",
    scope="scope",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

email: str — The email address of the invitee

scope: str — The scope of the invitee

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.members.invites.delete(...) -> AsyncHttpResponse[DeleteProjectInviteV1Response]

📝 Description

Deletes an invite for a specific project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.members.invites.delete(
    project_id="123456-7890-1234-5678-901234",
    email="john.doe@example.com",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

email: str — The email address of the member

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Members Scopes

client.manage.v1.projects.members.scopes.list(...) -> AsyncHttpResponse[ListProjectMemberScopesV1Response]

📝 Description

Retrieves a list of scopes for a specific member

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.members.scopes.list(
    project_id="123456-7890-1234-5678-901234",
    member_id="123456789012345678901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

member_id: str — The unique identifier of the Member

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.manage.v1.projects.members.scopes.update(...) -> AsyncHttpResponse[UpdateProjectMemberScopesV1Response]

📝 Description

Updates the scopes for a specific member

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.members.scopes.update(
    project_id="123456-7890-1234-5678-901234",
    member_id="123456789012345678901234",
    scope="admin",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

member_id: str — The unique identifier of the Member

scope: str — A scope to update

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Usage Breakdown

client.manage.v1.projects.usage.breakdown.get(...) -> AsyncHttpResponse[UsageBreakdownV1Response]

📝 Description

Retrieves the usage breakdown for a specific project, with various filter options by API feature or by groupings. Setting a feature (e.g. diarize) to true includes requests that used that feature, while false excludes requests that used it. Multiple true filters are combined with OR logic, while false filters use AND logic.

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.usage.breakdown.get(
    project_id="123456-7890-1234-5678-901234",
    start="start",
    end="end",
    grouping="accessor",
    accessor="12345678-1234-1234-1234-123456789012",
    alternatives=True,
    callback_method=True,
    callback=True,
    channels=True,
    custom_intent_mode=True,
    custom_intent=True,
    custom_topic_mode=True,
    custom_topic=True,
    deployment="hosted",
    detect_entities=True,
    detect_language=True,
    diarize=True,
    dictation=True,
    encoding=True,
    endpoint="listen",
    extra=True,
    filler_words=True,
    intents=True,
    keyterm=True,
    keywords=True,
    language=True,
    measurements=True,
    method="sync",
    model="6f548761-c9c0-429a-9315-11a1d28499c8",
    multichannel=True,
    numerals=True,
    paragraphs=True,
    profanity_filter=True,
    punctuate=True,
    redact=True,
    replace=True,
    sample_rate=True,
    search=True,
    sentiment=True,
    smart_format=True,
    summarize=True,
    tag="tag1",
    topics=True,
    utt_split=True,
    utterances=True,
    version=True,
)

⚙️ Parameters

project_id: str — The unique identifier of the project

start: typing.Optional[str] — Start date of the requested date range. Format accepted is YYYY-MM-DD

end: typing.Optional[str] — End date of the requested date range. Format accepted is YYYY-MM-DD

grouping: typing.Optional[BreakdownGetRequestGrouping] — Common usage grouping parameters

accessor: typing.Optional[str] — Filter for requests where a specific accessor was used

alternatives: typing.Optional[bool] — Filter for requests where alternatives were used

callback_method: typing.Optional[bool] — Filter for requests where callback method was used

callback: typing.Optional[bool] — Filter for requests where callback was used

channels: typing.Optional[bool] — Filter for requests where channels were used

custom_intent_mode: typing.Optional[bool] — Filter for requests where custom intent mode was used

custom_intent: typing.Optional[bool] — Filter for requests where custom intent was used

custom_topic_mode: typing.Optional[bool] — Filter for requests where custom topic mode was used

custom_topic: typing.Optional[bool] — Filter for requests where custom topic was used

deployment: typing.Optional[BreakdownGetRequestDeployment] — Filter for requests where a specific deployment was used

detect_entities: typing.Optional[bool] — Filter for requests where detect entities was used

detect_language: typing.Optional[bool] — Filter for requests where detect language was used

diarize: typing.Optional[bool] — Filter for requests where diarize was used

dictation: typing.Optional[bool] — Filter for requests where dictation was used

encoding: typing.Optional[bool] — Filter for requests where encoding was used

endpoint: typing.Optional[BreakdownGetRequestEndpoint] — Filter for requests where a specific endpoint was used

extra: typing.Optional[bool] — Filter for requests where extra was used

filler_words: typing.Optional[bool] — Filter for requests where filler words was used

intents: typing.Optional[bool] — Filter for requests where intents was used

keyterm: typing.Optional[bool] — Filter for requests where keyterm was used

keywords: typing.Optional[bool] — Filter for requests where keywords was used

language: typing.Optional[bool] — Filter for requests where language was used

measurements: typing.Optional[bool] — Filter for requests where measurements were used

method: typing.Optional[BreakdownGetRequestMethod] — Filter for requests where a specific method was used

model: typing.Optional[str] — Filter for requests where a specific model uuid was used

multichannel: typing.Optional[bool] — Filter for requests where multichannel was used

numerals: typing.Optional[bool] — Filter for requests where numerals were used

paragraphs: typing.Optional[bool] — Filter for requests where paragraphs were used

profanity_filter: typing.Optional[bool] — Filter for requests where profanity filter was used

punctuate: typing.Optional[bool] — Filter for requests where punctuate was used

redact: typing.Optional[bool] — Filter for requests where redact was used

replace: typing.Optional[bool] — Filter for requests where replace was used

sample_rate: typing.Optional[bool] — Filter for requests where sample rate was used

search: typing.Optional[bool] — Filter for requests where search was used

sentiment: typing.Optional[bool] — Filter for requests where sentiment was used

smart_format: typing.Optional[bool] — Filter for requests where smart format was used

summarize: typing.Optional[bool] — Filter for requests where summarize was used

tag: typing.Optional[str] — Filter for requests where a specific tag was used

topics: typing.Optional[bool] — Filter for requests where topics was used

utt_split: typing.Optional[bool] — Filter for requests where utt split was used

utterances: typing.Optional[bool] — Filter for requests where utterances was used

version: typing.Optional[bool] — Filter for requests where version was used

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Manage V1 Projects Usage Fields

client.manage.v1.projects.usage.fields.list(...) -> AsyncHttpResponse[UsageFieldsV1Response]

📝 Description

Lists the features, models, tags, languages, and processing method used for requests in the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.manage.v1.projects.usage.fields.list(
    project_id="123456-7890-1234-5678-901234",
    start="start",
    end="end",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

start: typing.Optional[str] — Start date of the requested date range. Format accepted is YYYY-MM-DD

end: typing.Optional[str] — End date of the requested date range. Format accepted is YYYY-MM-DD

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Read V1 Text

client.read.v1.text.analyze(...) -> AsyncHttpResponse[ReadV1Response]

📝 Description

Analyze text content using Deepgrams text analysis API

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.read.v1.text.analyze(
    callback="callback",
    callback_method="POST",
    sentiment=True,
    summarize="v2",
    tag="tag",
    topics=True,
    custom_topic="custom_topic",
    custom_topic_mode="extended",
    intents=True,
    custom_intent="custom_intent",
    custom_intent_mode="extended",
    language="language",
    request={"url": "url"},
)

⚙️ Parameters

request: ReadV1RequestParams

callback: typing.Optional[str] — URL to which we'll make the callback request

callback_method: typing.Optional[TextAnalyzeRequestCallbackMethod] — HTTP method by which the callback request will be made

sentiment: typing.Optional[bool] — Recognizes the sentiment throughout a transcript or text

summarize: typing.Optional[TextAnalyzeRequestSummarize] — Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

tag: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Label your requests for the purpose of identification during usage reporting

topics: typing.Optional[bool] — Detect topics throughout a transcript or text

custom_topic: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

custom_topic_mode: typing.Optional[TextAnalyzeRequestCustomTopicMode] — Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

intents: typing.Optional[bool] — Recognizes speaker intent throughout a transcript or text

custom_intent: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Custom intents you want the model to detect within your input audio if present

custom_intent_mode: typing.Optional[TextAnalyzeRequestCustomIntentMode] — Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

language: typing.Optional[str] — The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

SelfHosted V1 DistributionCredentials

client.self_hosted.v1.distribution_credentials.list(...) -> AsyncHttpResponse[ListProjectDistributionCredentialsV1Response]

📝 Description

Lists sets of distribution credentials for the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.self_hosted.v1.distribution_credentials.list(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.self_hosted.v1.distribution_credentials.create(...) -> AsyncHttpResponse[CreateProjectDistributionCredentialsV1Response]

📝 Description

Creates a set of distribution credentials for the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.self_hosted.v1.distribution_credentials.create(
    project_id="123456-7890-1234-5678-901234",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

scopes: typing.Optional[ typing.Union[ DistributionCredentialsCreateRequestScopesItem, typing.Sequence[DistributionCredentialsCreateRequestScopesItem], ] ] — List of permission scopes for the credentials

provider: typing.Optional[typing.Literal["quay"]] — The provider of the distribution service

comment: typing.Optional[str] — Optional comment about the credentials

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.self_hosted.v1.distribution_credentials.get(...) -> AsyncHttpResponse[GetProjectDistributionCredentialsV1Response]

📝 Description

Returns a set of distribution credentials for the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.self_hosted.v1.distribution_credentials.get(
    project_id="123456-7890-1234-5678-901234",
    distribution_credentials_id="8b36cfd0-472f-4a21-833f-2d6343c3a2f3",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

distribution_credentials_id: str — The UUID of the distribution credentials

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

client.self_hosted.v1.distribution_credentials.delete(...) -> AsyncHttpResponse[GetProjectDistributionCredentialsV1Response]

📝 Description

Deletes a set of distribution credentials for the specified project

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.self_hosted.v1.distribution_credentials.delete(
    project_id="123456-7890-1234-5678-901234",
    distribution_credentials_id="8b36cfd0-472f-4a21-833f-2d6343c3a2f3",
)

⚙️ Parameters

project_id: str — The unique identifier of the project

distribution_credentials_id: str — The UUID of the distribution credentials

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Speak V1 Audio

client.speak.v1.audio.generate(...) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]

📝 Description

Convert text into natural-sounding speech using Deepgram's TTS REST API

🔌 Usage

from deepgram import DeepgramClient

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)
client.speak.v1.audio.generate(
    text="text",
)

⚙️ Parameters

text: str — The text content to be converted to speech

callback: typing.Optional[str] — URL to which we'll make the callback request

callback_method: typing.Optional[AudioGenerateRequestCallbackMethod] — HTTP method by which the callback request will be made

mip_opt_out: typing.Optional[bool] — Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

tag: typing.Optional[typing.Union[str, typing.Sequence[str]]] — Label your requests for the purpose of identification during usage reporting

bit_rate: typing.Optional[float] — The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.

container: typing.Optional[AudioGenerateRequestContainer] — Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.

encoding: typing.Optional[AudioGenerateRequestEncoding] — Encoding allows you to specify the expected encoding of your audio output

model: typing.Optional[AudioGenerateRequestModel] — AI model used to process submitted text

sample_rate: typing.Optional[float] — Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable

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.

Listen V1 Connect

client.listen.v1.connect(...)

📝 Description

Transcribe audio and video using Deepgram's speech-to-text WebSocket

🔌 Usage

from typing import Union

from deepgram import DeepgramClient
from deepgram.core.events import EventType
from deepgram.listen.v1.types import (
    ListenV1Results,
    ListenV1Metadata,
    ListenV1UtteranceEnd,
    ListenV1SpeechStarted,
)

ListenV1Response = Union[ListenV1Results, ListenV1Metadata, ListenV1UtteranceEnd, ListenV1SpeechStarted]

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)

with client.listen.v1.connect(model="nova-3") as connection:
    def on_message(message: ListenV1Response) -> None:
        msg_type = getattr(message, "type", "Unknown")
        print(f"Received {msg_type} event")

    connection.on(EventType.OPEN, lambda _: print("Connection opened"))
    connection.on(EventType.MESSAGE, on_message)
    connection.on(EventType.CLOSE, lambda _: print("Connection closed"))
    connection.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

    # Start listening
    connection.start_listening()

    # Send audio data (raw bytes)
    connection.send_media(audio_bytes)

    # Send control messages
    connection.send_keep_alive()
    connection.send_finalize()
    connection.send_close_stream()

🔌 Async Usage

import asyncio
from typing import Union

from deepgram import AsyncDeepgramClient
from deepgram.core.events import EventType
from deepgram.listen.v1.types import (
    ListenV1Results,
    ListenV1Metadata,
    ListenV1UtteranceEnd,
    ListenV1SpeechStarted,
)

ListenV1Response = Union[ListenV1Results, ListenV1Metadata, ListenV1UtteranceEnd, ListenV1SpeechStarted]

client = AsyncDeepgramClient(
    api_key="YOUR_API_KEY",
)

async def main():
    async with client.listen.v1.connect(model="nova-3") as connection:
        def on_message(message: ListenV1Response) -> None:
            msg_type = getattr(message, "type", "Unknown")
            print(f"Received {msg_type} event")

        connection.on(EventType.OPEN, lambda _: print("Connection opened"))
        connection.on(EventType.MESSAGE, on_message)
        connection.on(EventType.CLOSE, lambda _: print("Connection closed"))
        connection.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

        # Start listening
        await connection.start_listening()

        # Send audio data (raw bytes)
        await connection.send_media(audio_bytes)

        # Send control messages
        await connection.send_keep_alive()
        await connection.send_finalize()
        await connection.send_close_stream()

asyncio.run(main())

📤 Send Methods

send_media(message: bytes) — Send binary audio data for transcription

  • connection.send_media(audio_bytes) — Send raw audio bytes directly

send_keep_alive() — Keep the connection alive

  • connection.send_keep_alive()

send_finalize() — Finalize the transcription

  • connection.send_finalize()

send_close_stream() — Close the audio stream

  • connection.send_close_stream()

⚙️ Parameters

model: str — AI model to use for the transcription

callback: typing.Optional[str] — URL to which we'll make the callback request

callback_method: typing.Optional[str] — HTTP method by which the callback request will be made

channels: typing.Optional[str] — Number of independent audio channels contained in submitted audio

diarize: typing.Optional[str] — Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0

dictation: typing.Optional[str] — Dictation mode for controlling formatting with dictated speech

encoding: typing.Optional[str] — Specify the expected encoding of your submitted audio

endpointing: typing.Optional[str] — Control when speech recognition ends

extra: typing.Optional[str] — Arbitrary key-value pairs that are attached to the API response

filler_words: typing.Optional[str] — Include filler words like "uh" and "um" in transcripts

interim_results: typing.Optional[str] — Return partial transcripts as audio is being processed

keyterm: typing.Optional[str] — Key term prompting can boost or suppress specialized terminology and brands

keywords: typing.Optional[str] — Keywords can boost or suppress specialized terminology and brands

language: typing.Optional[str] — BCP-47 language tag that hints at the primary spoken language

mip_opt_out: typing.Optional[str] — Opts out requests from the Deepgram Model Improvement Program

multichannel: typing.Optional[str] — Transcribe each audio channel independently

numerals: typing.Optional[str] — Convert numbers from written format to numerical format

profanity_filter: typing.Optional[str] — Remove profanity from transcripts

punctuate: typing.Optional[str] — Add punctuation and capitalization to the transcript

redact: typing.Optional[str] — Redaction removes sensitive information from your transcripts

replace: typing.Optional[str] — Search for terms or phrases in submitted audio and replaces them

sample_rate: typing.Optional[str] — Sample rate of the submitted audio

search: typing.Optional[str] — Search for terms or phrases in submitted audio

smart_format: typing.Optional[str] — Apply formatting to transcript output for improved readability

tag: typing.Optional[str] — Label your requests for the purpose of identification during usage reporting

utterance_end_ms: typing.Optional[str] — Length of time in milliseconds of silence to wait for before finalizing speech

vad_events: typing.Optional[str] — Return Voice Activity Detection events via the websocket

version: typing.Optional[str] — Version of the model to use

authorization: typing.Optional[str] — Use your API key for authentication, or alternatively generate a temporary token and pass it via the token query parameter.

Example: token %DEEPGRAM_API_KEY% or bearer %DEEPGRAM_TOKEN%

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Listen V2 Connect

client.listen.v2.connect(...)

📝 Description

Real-time conversational speech recognition with contextual turn detection for natural voice conversations

🔌 Usage

from typing import Union

from deepgram import DeepgramClient
from deepgram.core.events import EventType
from deepgram.listen.v2.types import (
    ListenV2Connected,
    ListenV2TurnInfo,
    ListenV2FatalError,
)

ListenV2Response = Union[ListenV2Connected, ListenV2TurnInfo, ListenV2FatalError]

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)

with client.listen.v2.connect(
    model="flux-general-en",
    encoding="linear16",
    sample_rate=16000
) as connection:
    def on_message(message: ListenV2Response) -> None:
        msg_type = getattr(message, "type", "Unknown")
        print(f"Received {msg_type} event")

    connection.on(EventType.OPEN, lambda _: print("Connection opened"))
    connection.on(EventType.MESSAGE, on_message)
    connection.on(EventType.CLOSE, lambda _: print("Connection closed"))
    connection.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

    # Start listening
    connection.start_listening()

    # Send audio data (raw bytes)
    connection.send_media(audio_bytes)

    # Close the audio stream
    connection.send_close_stream()

🔌 Async Usage

import asyncio
from typing import Union

from deepgram import AsyncDeepgramClient
from deepgram.core.events import EventType
from deepgram.listen.v2.types import (
    ListenV2Connected,
    ListenV2TurnInfo,
    ListenV2FatalError,
)

ListenV2Response = Union[ListenV2Connected, ListenV2TurnInfo, ListenV2FatalError]

client = AsyncDeepgramClient(
    api_key="YOUR_API_KEY",
)

async def main():
    async with client.listen.v2.connect(
        model="flux-general-en",
        encoding="linear16",
        sample_rate=16000
    ) as connection:
        def on_message(message: ListenV2Response) -> None:
            msg_type = getattr(message, "type", "Unknown")
            print(f"Received {msg_type} event")

        connection.on(EventType.OPEN, lambda _: print("Connection opened"))
        connection.on(EventType.MESSAGE, on_message)
        connection.on(EventType.CLOSE, lambda _: print("Connection closed"))
        connection.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

        # Start listening
        await connection.start_listening()

        # Send audio data (raw bytes)
        await connection.send_media(audio_bytes)

        # Close the audio stream
        await connection.send_close_stream()

asyncio.run(main())

📤 Send Methods

send_media(message: bytes) — Send binary audio data for transcription

  • connection.send_media(audio_bytes) — Send raw audio bytes directly

send_close_stream() — Close the audio stream

  • connection.send_close_stream()

⚙️ Parameters

model: str — AI model used to process submitted audio

encoding: str — Specify the expected encoding of your submitted audio

sample_rate: int — Sample rate of the submitted audio

eager_eot_threshold: typing.Optional[str] — Threshold for eager end-of-turn detection

eot_threshold: typing.Optional[str] — Threshold for end-of-turn detection

eot_timeout_ms: typing.Optional[str] — Timeout in milliseconds for end-of-turn detection

keyterm: typing.Optional[str] — Key term prompting can boost or suppress specialized terminology and brands

mip_opt_out: typing.Optional[str] — Opts out requests from the Deepgram Model Improvement Program

tag: typing.Optional[str] — Label your requests for the purpose of identification during usage reporting

authorization: typing.Optional[str] — Use your API key for authentication, or alternatively generate a temporary token and pass it via the token query parameter.

Example: token %DEEPGRAM_API_KEY% or bearer %DEEPGRAM_TOKEN%

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Speak V1 Connect

client.speak.v1.connect(...)

📝 Description

Convert text into natural-sounding speech using Deepgram's TTS WebSocket

🔌 Usage

from typing import Union

from deepgram import DeepgramClient
from deepgram.core.events import EventType
from deepgram.speak.v1.types import (
    SpeakV1Text,
    SpeakV1Metadata,
    SpeakV1Flushed,
    SpeakV1Cleared,
    SpeakV1Warning,
)

SpeakV1Response = Union[bytes, SpeakV1Metadata, SpeakV1Flushed, SpeakV1Cleared, SpeakV1Warning]

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)

with client.speak.v1.connect(
    model="aura-2-asteria-en",
    encoding="linear16",
    sample_rate=24000
) as connection:
    def on_message(message: SpeakV1Response) -> None:
        if isinstance(message, bytes):
            print("Received audio event")
        else:
            msg_type = getattr(message, "type", "Unknown")
            print(f"Received {msg_type} event")

    connection.on(EventType.OPEN, lambda _: print("Connection opened"))
    connection.on(EventType.MESSAGE, on_message)
    connection.on(EventType.CLOSE, lambda _: print("Connection closed"))
    connection.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

    # Start listening
    connection.start_listening()

    # Send text to be converted to speech
    connection.send_text(SpeakV1Text(text="Hello, world!"))

    # Send control messages
    connection.send_flush()
    connection.send_close()

🔌 Async Usage

import asyncio
from typing import Union

from deepgram import AsyncDeepgramClient
from deepgram.core.events import EventType
from deepgram.speak.v1.types import (
    SpeakV1Text,
    SpeakV1Metadata,
    SpeakV1Flushed,
    SpeakV1Cleared,
    SpeakV1Warning,
)

SpeakV1Response = Union[bytes, SpeakV1Metadata, SpeakV1Flushed, SpeakV1Cleared, SpeakV1Warning]

client = AsyncDeepgramClient(
    api_key="YOUR_API_KEY",
)

async def main():
    async with client.speak.v1.connect(
        model="aura-2-asteria-en",
        encoding="linear16",
        sample_rate=24000
    ) as connection:
        def on_message(message: SpeakV1Response) -> None:
            if isinstance(message, bytes):
                print("Received audio event")
            else:
                msg_type = getattr(message, "type", "Unknown")
                print(f"Received {msg_type} event")

        connection.on(EventType.OPEN, lambda _: print("Connection opened"))
        connection.on(EventType.MESSAGE, on_message)
        connection.on(EventType.CLOSE, lambda _: print("Connection closed"))
        connection.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

        # Start listening
        await connection.start_listening()

        # Send text to be converted to speech
        await connection.send_text(SpeakV1Text(text="Hello, world!"))

        # Send control messages
        await connection.send_flush()
        await connection.send_close()

asyncio.run(main())

📤 Send Methods

send_text(message: SpeakV1Text) — Send text to be converted to speech

  • connection.send_text(SpeakV1Text(text="Hello, world!"))

send_flush() — Process all queued text immediately

  • connection.send_flush()

send_clear() — Clear the text queue

  • connection.send_clear()

send_close() — Close the connection

  • connection.send_close()

⚙️ Parameters

encoding: typing.Optional[str] — Specify the expected encoding of your output audio

mip_opt_out: typing.Optional[str] — Opts out requests from the Deepgram Model Improvement Program

model: typing.Optional[str] — AI model used to process submitted text

sample_rate: typing.Optional[str] — Sample rate for the output audio

authorization: typing.Optional[str] — Use your API key for authentication, or alternatively generate a temporary token and pass it via the token query parameter.

Example: token %DEEPGRAM_API_KEY% or bearer %DEEPGRAM_TOKEN%

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

Agent V1 Connect

client.agent.v1.connect(...)

📝 Description

Build a conversational voice agent using Deepgram's Voice Agent WebSocket

🔌 Usage

from deepgram import DeepgramClient
from deepgram.core.events import EventType
from deepgram.agent.v1.types import (
    AgentV1Settings,
    AgentV1SettingsAgent,
    AgentV1SettingsAudio,
    AgentV1SettingsAudioInput,
    AgentV1SettingsAgentListen,
    AgentV1SettingsAgentListenProvider_V1,
    AgentV1Welcome,
    AgentV1SettingsApplied,
    AgentV1ConversationText,
    AgentV1UserStartedSpeaking,
    AgentV1AgentThinking,
    AgentV1FunctionCallRequest,
    AgentV1AgentStartedSpeaking,
    AgentV1AgentAudioDone,
    AgentV1Error,
    AgentV1Warning,
)
from deepgram.types import (
    ThinkSettingsV1,
    ThinkSettingsV1Provider_OpenAi,
    SpeakSettingsV1,
    SpeakSettingsV1Provider_Deepgram,
)

client = DeepgramClient(
    api_key="YOUR_API_KEY",
)

with client.agent.v1.connect() as agent:
    # Configure the agent
    settings = AgentV1Settings(
        audio=AgentV1SettingsAudio(
            input=AgentV1SettingsAudioInput(
                encoding="linear16",
                sample_rate=44100,
            )
        ),
        agent=AgentV1SettingsAgent(
            listen=AgentV1SettingsAgentListen(
                provider=AgentV1SettingsAgentListenProvider_V1(
                    type="deepgram",
                    model="nova-3",
                    smart_format=True,
                )
            ),
            think=ThinkSettingsV1(
                provider=ThinkSettingsV1Provider_OpenAi(
                    type="open_ai",
                    model="gpt-4o-mini",
                    temperature=0.7,
                ),
                prompt='Reply only and explicitly with "OK".',
            ),
            speak=[SpeakSettingsV1(
                provider=SpeakSettingsV1Provider_Deepgram(
                    type="deepgram",
                    model="aura-2-asteria-en",
                )
            )],
        ),
    )

    agent.send_settings(settings)

    def on_message(message) -> None:
        if isinstance(message, bytes):
            print("Received audio event")
        else:
            msg_type = getattr(message, "type", "Unknown")
            print(f"Received {msg_type} event")

    agent.on(EventType.OPEN, lambda _: print("Connection opened"))
    agent.on(EventType.MESSAGE, on_message)
    agent.on(EventType.CLOSE, lambda _: print("Connection closed"))
    agent.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

    # Start listening
    agent.start_listening()

    # Send audio data (raw bytes)
    agent.send_media(audio_bytes)

    # Send keep-alive
    agent.send_keep_alive()

🔌 Async Usage

import asyncio

from deepgram import AsyncDeepgramClient
from deepgram.core.events import EventType
from deepgram.agent.v1.types import (
    AgentV1Settings,
    AgentV1SettingsAgent,
    AgentV1SettingsAudio,
    AgentV1SettingsAudioInput,
    AgentV1SettingsAgentListen,
    AgentV1SettingsAgentListenProvider_V1,
    AgentV1Welcome,
    AgentV1SettingsApplied,
    AgentV1ConversationText,
    AgentV1UserStartedSpeaking,
    AgentV1AgentThinking,
    AgentV1FunctionCallRequest,
    AgentV1AgentStartedSpeaking,
    AgentV1AgentAudioDone,
    AgentV1Error,
    AgentV1Warning,
)
from deepgram.types import (
    ThinkSettingsV1,
    ThinkSettingsV1Provider_OpenAi,
    SpeakSettingsV1,
    SpeakSettingsV1Provider_Deepgram,
)

client = AsyncDeepgramClient(
    api_key="YOUR_API_KEY",
)

async def main():
    async with client.agent.v1.connect() as agent:
        # Configure the agent
        settings = AgentV1Settings(
            audio=AgentV1SettingsAudio(
                input=AgentV1SettingsAudioInput(
                    encoding="linear16",
                    sample_rate=16000,
                )
            ),
            agent=AgentV1SettingsAgent(
                listen=AgentV1SettingsAgentListen(
                    provider=AgentV1SettingsAgentListenProvider_V1(
                        type="deepgram",
                        model="nova-3",
                        smart_format=True,
                    )
                ),
                think=ThinkSettingsV1(
                    provider=ThinkSettingsV1Provider_OpenAi(
                        type="open_ai",
                        model="gpt-4o-mini",
                        temperature=0.7,
                    ),
                ),
                speak=[SpeakSettingsV1(
                    provider=SpeakSettingsV1Provider_Deepgram(
                        type="deepgram",
                        model="aura-2-asteria-en",
                    )
                )],
            ),
        )

        await agent.send_settings(settings)

        def on_message(message) -> None:
            if isinstance(message, bytes):
                print("Received audio event")
            else:
                msg_type = getattr(message, "type", "Unknown")
                print(f"Received {msg_type} event")

        agent.on(EventType.OPEN, lambda _: print("Connection opened"))
        agent.on(EventType.MESSAGE, on_message)
        agent.on(EventType.CLOSE, lambda _: print("Connection closed"))
        agent.on(EventType.ERROR, lambda error: print(f"Caught: {error}"))

        # Start listening
        await agent.start_listening()

        # Send audio data (raw bytes)
        await agent.send_media(audio_bytes)

        # Send keep-alive
        await agent.send_keep_alive()

asyncio.run(main())

⚙️ Parameters

authorization: typing.Optional[str] — Use your API key for authentication, or alternatively generate a temporary token and pass it via the token query parameter.

Example: token %DEEPGRAM_API_KEY% or bearer %DEEPGRAM_TOKEN%

request_options: typing.Optional[RequestOptions] — Request-specific configuration.

📤 Send Methods

send_settings(message: AgentV1Settings) — Send initial agent configuration settings

  • AgentV1Settings(...) — Configure audio, listen, think, and speak providers

send_media(message: bytes) — Send binary audio data to the agent

  • agent.send_media(audio_bytes) — Send raw audio bytes directly

send_keep_alive() — Keep the connection alive

  • agent.send_keep_alive()

send_update_speak(message: AgentV1UpdateSpeak) — Update the agent's speech synthesis settings

  • AgentV1UpdateSpeak(speak=SpeakSettingsV1(...)) — Modify TTS configuration during conversation

send_update_prompt(message: AgentV1UpdatePrompt) — Update the agent's system prompt

  • AgentV1UpdatePrompt(prompt="...") — Change the agent's behavior instructions

send_inject_user_message(message: AgentV1InjectUserMessage) — Inject a user message into the conversation

  • AgentV1InjectUserMessage(content="...") — Add a simulated user input

send_inject_agent_message(message: AgentV1InjectAgentMessage) — Inject an agent message into the conversation

  • AgentV1InjectAgentMessage(message="...") — Add a simulated agent response

send_function_call_response(message: AgentV1SendFunctionCallResponse) — Send the result of a function call back to the agent

  • AgentV1SendFunctionCallResponse(name="...", content="...") — Provide function execution results