Topic Detection
Topic Detection detects topics throughout the input text.
topics
boolean Default: false
Try this feature out in our API Playground!
Topic Detection accepts an input text, divides it into a list of segments comprised of sections of the text, and identifies key topics found within each segment.
The list of topics that can be identified are not a fixed list; this TSLM powered feature is able to generate topics based on the context of the language content in the text. You may also choose to use the optional custom-topic
parameter to provide a custom topic you want detected if present within the provided text.
Enable Feature
To enable Topic Detection, use the following parameter in the query string when you call Deepgram’s /read
endpoint:
topics=true
Basic Text Request
To analyze text from a file on your computer, run the following curl command in a terminal or your favorite API client.
Replace YOUR_DEEPGRAM_API_KEY
with your Deepgram API Key.
Basic URL Request
To analyze text from a hosted file, run the following curl command in a terminal or your favorite API client. (Try testing it out with the hosted file https://static.deepgram.com/examples/aura.txt)
Custom Topics Request
To tell the model to only return topics from your own custom list of topics, add custom_topic_mode=strict
and custom_topic=
followed by the list of topics. (Use the URL encoding%20
to represent a space between each word in the list.)
If you want to return your own custom list of topics in addition to Deegpram’s list of topics, set custom_intent_mode=extended
and add your custom list.
Read our Text Intelligence Getting Started guide, which will walk you through making a basic text request and a basic URL request with the Deepgram SDKs.
Query Parameters
Analyze Response
When the file is finished processing, you’ll receive a JSON response that has the following basic structure:
Use the API reference or the API Playground to view the detailed response.
The response object values for topics
are:
segments
: The list of segments of text identified by the model as containing notable topics.topic
: The name of the topic detected by the model.confidence_score
: a floating point from 0 to 1 representing the models confidence in this prediction.
API Error Responses
Unsupported Language
Status 400
If you request Topic Detection with an unsupported language by specifying a language code such as topics=true&language=es
or topics=true&detect_language=true
where the detected language is unsupported, you will get the error message below.
Token Limit Exceeded
Status 400
If the request’s input length exceeded the 150k token rate limit per request, you will get the error message below.
Missing Query Parameter
Status 400
If the request sent contained only the feature parameter (topics
) but not the language
parameter, you will receive this error.