DEV Community

Sonam
Sonam

Posted on

Build a URL Summarizer at the Edge with Telnyx AI Inference

I have been playing with a pattern that feels useful for small AI tools:

  1. accept a request
  2. call an AI model
  3. cache the result close to where the request runs
  4. avoid building extra infrastructure until you actually need it

This example applies that pattern to URL summarization using Telnyx Edge Compute Stateful Actors.

Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/edge-url-summarizer

What it builds

The app is a Node.js / TypeScript Edge Compute example.

You send it a URL:

curl -X POST https://edge-url-summarizer-<id>.telnyxcompute.com/summarize \
  -H "Content-Type: application/json" \
  -d '{"url":"https://telnyx.com/blog"}'
Enter fullscreen mode Exit fullscreen mode

On the first request, it:

  • fetches the page
  • extracts text from the HTML
  • sends the text to Telnyx AI Inference
  • asks for exactly three bullet points
  • stores the result in Stateful Actor storage

On repeat requests for the same URL, it returns the cached summary.

API routes

The example includes:

  • POST /summarize - summarize a URL
  • GET /summarize/cached?url=... - read a cached summary
  • POST /summarize/refresh - invalidate a cached URL
  • GET /stats - view cache hit/miss stats
  • GET /cached - list cached URLs
  • GET /health/liveness - liveness check
  • GET /health/readiness - readiness check

Example response

{
  "url": "https://example.com/article",
  "title": "Example Article",
  "bullets": [
    "The article explains the main problem.",
    "The implementation uses an edge function and AI model.",
    "Cached results make repeat requests faster."
  ],
  "word_count": 1234,
  "generated_at": "2026-08-04T12:00:00Z",
  "cached": false
}
Enter fullscreen mode Exit fullscreen mode

Call the same URL again and the response comes back with:

{
  "cached": true
}
Enter fullscreen mode Exit fullscreen mode

The Telnyx AI call

The app calls:

POST /v2/ai/chat/completions
Enter fullscreen mode Exit fullscreen mode

The current sample uses:

zai-org/GLM-5.2
Enter fullscreen mode Exit fullscreen mode

The model is prompted to return JSON only:

{
  "bullets": ["point 1", "point 2", "point 3"]
}
Enter fullscreen mode Exit fullscreen mode

That keeps the app response easy to consume from a dashboard, workflow, or internal tool.

The Stateful Actor part

The cache lives in a Telnyx Stateful Actor.

The actor stores:

  • summaries by URL
  • cache hits
  • cache misses
  • total requests
  • unique URL count

That means the app can remember previous summaries without adding Redis or a database just for the demo.

Run it

Clone the repo:

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/edge-url-summarizer
Enter fullscreen mode Exit fullscreen mode

Set your Telnyx API key:

telnyx-edge auth api-key set <YOUR_API_KEY>
telnyx-edge secrets add TELNYX_API_KEY "KEY0123..."
Enter fullscreen mode Exit fullscreen mode

Install and deploy:

npm install
telnyx-edge ship
Enter fullscreen mode Exit fullscreen mode

Test the deployment:

curl -sS --retry 30 --retry-delay 5 \
  https://edge-url-summarizer-<id>.telnyxcompute.com/health/liveness
Enter fullscreen mode Exit fullscreen mode

Summarize a page:

curl -X POST https://edge-url-summarizer-<id>.telnyxcompute.com/summarize \
  -H "Content-Type: application/json" \
  -d '{"url":"https://telnyx.com/blog"}'
Enter fullscreen mode Exit fullscreen mode

Check cache stats:

curl https://edge-url-summarizer-<id>.telnyxcompute.com/stats
Enter fullscreen mode Exit fullscreen mode

What I would add before production

For a production version, I would add:

  • authentication
  • rate limiting
  • URL allowlists or SSRF protections
  • URL normalization
  • TTL-based cache expiration
  • better HTML extraction
  • retries and observability

But as a runnable example, this is a clean way to see Edge Compute, Stateful Actors, and Telnyx AI Inference working together.

Resources:

Top comments (0)