cd /news/ai-tools/extract-structured-json-from-messy-t… · home topics ai-tools article
[ARTICLE · art-40015] src=github.com ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Extract structured JSON from messy text with Telnyx AI Inference

Telnyx launched a new AI Inference feature that extracts structured JSON from unstructured text such as support tickets, emails, leads, and incident reports. The tool uses a Flask API to validate requests and leverages Telnyx's AI models to return structured data, enabling developers to automate data extraction and processing.

read2 min views1 publishedJun 25, 2026
Extract structured JSON from messy text with Telnyx AI Inference
Image: source
name extract-structured-json-with-ai
title Extract Structured JSON with AI
description Extract structured JSON from support tickets, emails, leads, or incident reports with Telnyx AI Inference.
language python
framework flask
telnyx_products

Extract structured JSON from support tickets, emails, leads, or incident reports with Telnyx AI Inference.

AI Inference:POST /v2/ai/chat/completions

-API reference

  Unstructured text
        |
        v
  Flask API validates request
        |
        v
  Telnyx AI Inference extracts JSON
        |
        v
  Structured JSON response

Copy .env.example

to .env

and fill in:

Variable Type Example Required Description Where to get it
TELNYX_API_KEY
string
KEY0123456789ABCDEF
yes
Telnyx API v2 key

AI_MODEL

string

moonshotai/Kimi-K2.6

ModelsHOST

string

127.0.0.1

PORT

integer

5000

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/extract-structured-json-with-ai-python
cp .env.example .env
pip install -r requirements.txt
python app.py

Extract structured data from text. If you do not provide a schema, the app uses a default support-ticket schema.

curl -X POST http://localhost:5000/extract \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Account: Acme Health. Production verification jobs started failing after an API key rotation. Users cannot finish signup. Logs show 401 errors."
  }'

Response:

{
  "model": "moonshotai/Kimi-K2.6",
  "result": {
    "company": "Acme Health",
    "category": "authentication",
    "priority": "urgent",
    "summary": "Production verification jobs are failing after an API key rotation.",
    "affected_environment": "production",
    "affected_region": "unknown",
    "customer_impact": "Users cannot finish signup.",
    "error_codes": ["401"],
    "suspected_cause": "The new API key may be invalid or missing required permissions.",
    "requested_action": "Check API key configuration and permissions."
  }
}

Returns sample text and the default schema.

Returns service status and configured model.

Issue Cause Fix
401 Unauthorized
Invalid or missing Telnyx API key Verify TELNYX_API_KEY in .env
400 Bad Request
Missing text or invalid schema
Send a non-empty text string and a JSON object schema
502 Model response was not valid JSON
The selected model did not return parseable JSON Retry with the default model or simplify the schema

Run LLM Inference (Python)Build RAG with Telnyx Inference (Python)Fax to Structured Data Pipeline (Python)

Telnyx is an AI Communications Infrastructure platform - voice, messaging, SIP, AI, and IoT on one private, global network.

── more in #ai-tools 4 stories · sorted by recency
── more on @telnyx 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/extract-structured-j…] indexed:0 read:2min 2026-06-25 ·