deepgram-rust-text-intelligence
Use when a user asks for Deepgram text intelligence from Rust. Route to raw HTTP guidance because this crate does not currently expose a dedicated /v1/read…
npx skills add https://github.com/deepgram/deepgram-rust-sdk --skill deepgram-rust-text-intelligenceUsing Deepgram Text Intelligence (Rust SDK)
Use this skill when the request is about summarization, sentiment, topics, or intents for text input rather than audio.
When to use this product
- Analyzing plain text via Deepgram's
/v1/readAPI. - Building text summarization, topic detection, intent recognition, or sentiment analysis.
- Analyzing a transcript, document, chat log, or email you already have, rather than audio.
Authentication
Text intelligence lives behind the read Cargo feature. It is HTTP-only, so it
needs none of the WebSocket dependencies the listen and speak features pull
in and can be enabled on its own.
[dependencies]
deepgram = { version = "0.12", default-features = false, features = ["read"] }
tokio = { version = "1", features = ["full"] }
read is also part of the crate's default features, so a plain
cargo add deepgram includes it.
use deepgram::Deepgram;
let dg_client = Deepgram::new(&std::env::var("DEEPGRAM_API_KEY")?)?;
let text_intelligence = dg_client.text_intelligence();
Quick start: analyze a block of text
use deepgram::{read::options::Options, Deepgram, DeepgramError};
#[tokio::main]
async fn main() -> Result<(), DeepgramError> {
let api_key = std::env::var("DEEPGRAM_API_KEY").expect("DEEPGRAM_API_KEY");
let dg_client = Deepgram::new(&api_key)?;
let options = Options::builder()
.sentiment(true)
.summarize(true)
.topics(true)
.intents(true)
.build();
let response = dg_client
.text_intelligence()
.analyze_text(
"Customer is asking to cancel the subscription next month.",
&options,
)
.await?;
if let Some(text) = response.results.summary.as_ref().and_then(|s| s.text.as_deref()) {
println!("summary: {text}");
}
if let Some(sentiments) = &response.results.sentiments {
println!("average sentiment: {:?}", sentiments.average);
}
if let Some(topics) = &response.results.topics {
println!("topic segments: {}", topics.segments.len());
}
if let Some(intents) = &response.results.intents {
println!("intent segments: {}", intents.segments.len());
}
Ok(())
}
Analyze a hosted document
analyze_url takes the URL of a plain-text document; everything else is the
same as analyze_text.
let response = dg_client
.text_intelligence()
.analyze_url("https://example.com/transcript.txt", &options)
.await?;
Callbacks
For long inputs, have Deepgram deliver the result to a webhook instead of
holding the connection open. The call returns as soon as the request is
accepted, with the request_id to correlate against; the full analysis arrives
at the callback URL.
use deepgram::read::options::{CallbackMethod, Options};
let options = Options::builder()
.sentiment(true)
.callback_method(CallbackMethod::POST)
.build();
let ack = dg_client
.text_intelligence()
.analyze_text_callback(text, &options, "https://example.com/hook")
.await?;
println!("request id: {}", ack.request_id);
analyze_url_callback is the hosted-document equivalent.
Key parameters
- Input:
analyze_text(text, &options)for inline text,analyze_url(url, &options)for a hosted plain-text document. - Analysis flags on
Options::builder():sentiment,summarize,topics,intents. - Custom taxonomies:
custom_topics/custom_topic_modeandcustom_intents/custom_intent_mode. languagedefaults to English, the only language/v1/readaccepts; the builder sends it for you because the endpoint returns 400 without it.tagattaches request tags for usage reporting.- Callbacks:
analyze_text_callback/analyze_url_callbackpluscallback_method.
Escape hatch
make_read_request_builder and make_read_callback_request_builder return the
underlying reqwest::RequestBuilder before it is sent, for appending query
parameters the typed options do not cover yet.
API reference (layered)
- In-repo
src/read/—rest.rs(the four request methods),options.rs(the query builder),response.rs(Response,ReadMetadata,ReadResults)README.mdfor install/auth patterns
- OpenAPI
- Raw spec:
https://developers.deepgram.com/openapi.yaml - Endpoint reference:
https://developers.deepgram.com/reference/text-intelligence/analyze-text
- Raw spec:
- AsyncAPI
- Not applicable for
/v1/read
- Not applicable for
- Context7
/llmstxt/developers_deepgram_llms_txt
- Product docs
https://developers.deepgram.com/docs/text-intelligence
Gotchas
- This is different from audio intelligence. Audio intelligence is piggybacked on STT and configured through the transcription
Options; text intelligence is its own/v1/readAPI with its ownread::options::Options. The twoOptionstypes are not interchangeable. - Every analysis result is optional.
results.sentiments,summary,topics, andintentsareOption, populated only for the flags you enabled. Match on them rather than unwrapping.Summary::textis itself anOption<String>, because the reference marks it optional, so reaching the summary text means unwrapping twice. - Every metadata field is optional too. Each field of
ReadMetadata(includingrequest_id, anOption<Uuid>, andcreated) and every field ofAnalysisInfois anOption, matching the reference, so logging the request id means unwrapping first rather than reading it straight offresponse.metadata. - English only.
/v1/readaccepts English; the builder sendslanguage=enby default because the endpoint rejects a request without it. readcan be enabled alone. If a consumer hasdefault-features = false, text intelligence needsfeatures = ["read"]— it is not covered bylisten.- API keys use
Token. This API does not useBearerfor standard API keys.Deepgram::newhandles the header for you.
Example files in this repo
examples/read/analyze_text.rs— runnable end-to-end analysis, registered as theanalyze_textexample (cargo run --features read --example analyze_text).
Central product skills
For cross-language Deepgram product knowledge — the consolidated API reference, documentation finder, focused runnable recipes, third-party integration examples, and MCP setup — install the central skills:
npx skills add deepgram/skills
This SDK ships language-idiomatic code skills; deepgram/skills ships cross-language product knowledge (see api, docs, recipes, examples, starters, setup-mcp).