Skip to main content
This analyzer enriches a prompt with structured linguistic signals — sentiment scores, named entities, topic categories, and a moderation verdict. It is a signal analyzer; it produces metrics you can use as termination thresholds in a combined policy, but it does not by itself make safety decisions (that’s Safety & Responsible AI).

What it provides

Four independent sub-analyses, each toggleable:
  • Sentiment — overall sentiment (-1.0 very negative to +1.0 very positive) with a magnitude.
  • Entity extraction — named entities (people, organizations, locations, etc.).
  • Topic classification — high-level categories (requires text ≥ 20 bytes).
  • Content moderation — categories like Toxic, Insult, Profanity, Derogatory, Sexual, Violent, Death, Harm & Tragedy, Firearms & Weapons, Illicit Drugs.

How it works

Calls Google Cloud Natural Language API:
  • v1 (classification, entities) for topic and entity extraction.
  • v2 (sentiment, moderation) for sentiment and moderation scores.
Each sub-analysis is a separate API call. Disabling sub-analyses you do not need is the most effective latency lever.

Parameters

(Topic classification has no toggle; it always runs when input is ≥ 20 bytes.)

Outputs and metrics

Termination signals

Combine moderation_flagged with max_moderation_confidence >= 0.65 for stricter control than the default 0.5 cutoff.

Limits and cost

Cost is Google Cloud Natural Language pricing — see the NL pricing page.

Typical latency

500–3000 ms depending on enabled analyses and input length. The biggest saving you can make is disabling sub-analyses you do not need; each one is its own API call.

When to use it

  • Best as a flag, not a block. Sentiment and entity counts are noisy. Use them to enrich your analysis log; reach for safety guardrails or YARA when you actually want to block.
  • Use moderation as a secondary signal. It overlaps with ShieldGemma but uses a different model family; agreement between the two raises confidence on a violation.
  • Disable what you do not use. If you do not need topic classification, the include_* toggles already disable sentiment, entities, and moderation; topic always runs but is fast.

Failure modes

  • NL API error → analyzer ERROR status; surfaced in analyzer_results.
  • Empty input → topic classification skipped; other sub-analyses produce empty results.

Next