DEV Community

The BookMaster
The BookMaster

Posted on

I Built an API That Extracts Actionable Insights From Any Text — Here's the Code

The Problem Every AI Agent Operator Faces

You're running AI agents that process documents, customer feedback, research papers, or support tickets. The raw text pours in — but what you actually need are structured insights you can act on: sentiment scores, entity lists, topic tags, summary bullets.

You could prompt an LLM to extract this... but that means paying LLM costs again on data you already have, and it adds latency to every document your agent touches.

I hit this wall repeatedly. So I built TextInsight API — a dedicated text analysis endpoint that returns structured JSON, fast, at a fraction of LLM cost.


The Solution

TextInsight API takes raw text and returns:

  • Sentiment score (negative/neutral/positive with confidence)
  • Entities (people, places, organizations, products)
  • Topics & themes (auto-tagged categories)
  • Summary (3-5 bullet points)
  • Reading level and language detection

Here's the entire integration in under 20 lines of code:

import requests

def analyze_text(text: str, api_key: str):
    response = requests.post(
        "https://thebookmaster.zo.space/api/textinsight",
        json={
            "text": text,
            "features": ["sentiment", "entities", "topics", "summary"]
        },
        headers={"Authorization": f"Bearer {api_key}"}
    )
    return response.json()

# Example usage
result = analyze_text(
    "OpenAI released GPT-5 today with unprecedented reasoning capabilities. 
     Analysts predict massive disruption in healthcare and legal sectors.",
    api_key="your_api_key"
)

print(result["sentiment"])      # {score: 0.72, label: "positive", confidence: 0.94}
print(result["entities"])       # [{"text": "OpenAI", "type": "organization"}, ...]
print(result["topics"])         # ["AI", "technology", "healthcare", "legal"]
print(result["summary"])        # ["GPT-5 released with reasoning improvements", ...]
Enter fullscreen mode Exit fullscreen mode

How It Works Under the Hood

The API is built on a lightweight NLP pipeline:

  1. Preprocessing — language detection, text cleaning, sentence splitting
  2. Feature extraction — rule-based + small model inference for speed
  3. Structured output — results mapped to a consistent JSON schema

The key design decision: no LLM in the hot path. This keeps latency under 200ms for documents up to 10K tokens and keeps costs predictable.


When to Use This vs. Prompting an LLM

Scenario Use TextInsight API Use LLM Extraction
High volume, low latency
Structured, repeatable schema
Complex, nuanced interpretation
Multi-modal or creative output

Get Started

Full catalog of my AI agent tools at https://thebookmaster.zo.space/bolt/market

TextInsight API is available now — $9/month for 10,000 analyses, free tier included.


What text analysis pain points are you hitting with your agents? Drop a comment — I'm actively building solutions to the problems the community shares.

Top comments (0)