I have been playing with a pattern that feels useful for small AI tools:
- accept a request
- call an AI model
- cache the result close to where the request runs
- 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"}'
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
}
Call the same URL again and the response comes back with:
{
"cached": true
}
The Telnyx AI call
The app calls:
POST /v2/ai/chat/completions
The current sample uses:
zai-org/GLM-5.2
The model is prompted to return JSON only:
{
"bullets": ["point 1", "point 2", "point 3"]
}
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
Set your Telnyx API key:
telnyx-edge auth api-key set <YOUR_API_KEY>
telnyx-edge secrets add TELNYX_API_KEY "KEY0123..."
Install and deploy:
npm install
telnyx-edge ship
Test the deployment:
curl -sS --retry 30 --retry-delay 5 \
https://edge-url-summarizer-<id>.telnyxcompute.com/health/liveness
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"}'
Check cache stats:
curl https://edge-url-summarizer-<id>.telnyxcompute.com/stats
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:
- Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/edge-url-summarizer
- Stateful Actors Quick Start: https://developers.telnyx.com/docs/edge-compute/stateful-actors/quick-start
- Telnyx AI Inference docs: https://developers.telnyx.com/docs/inference
- Chat Completions API: https://developers.telnyx.com/api/inference/chat-completions
- Telnyx AI skills and toolkits: https://github.com/team-telnyx/ai
Top comments (0)