telnyxdocs.com

Command Palette

Search for a command to run...

Find Telnyx AI Models by Region with Python

Last updated: 10/6/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.

Find Telnyx AI Models by Region with Python

GET /v2/ai/models lists the models available through Telnyx inference, including the regions each model lists, its context length, and whether it supports vision. This guide filters that list by region with a standard-library Python script.

What you will build

A script that takes a region code and prints every text-generation model whose regions list includes it, with context length and vision support.

GET /v2/ai/models  (Bearer token)
        |
        v
filter: region in model.regions  AND  task is text generation
        |
        v
one line per model: id, context length, vision/text, regions

AI Prompt

Using the Telnyx REST API from Python, list the AI models that list a given region and print each model's id, context length, vision support, and regions.

Requirements:
- Call GET https://api.telnyx.com/v2/ai/models with an Authorization: Bearer header. Read the key from TELNYX_API_KEY. The endpoint returns 401 without a valid key.
- Use only the Python standard library (urllib and json).
- Each model object includes `id`, `task`, `context_length`, `is_vision_supported`, and `regions` (a list of region codes, possibly empty).
- The `task` field is spelled both `text-generation` and `text generation` across models, so match both.
- Do not rely on query-string filters. A `filter[owned_by]` parameter did not narrow the results, so filter on the client.
- Run the verification step below before finishing.

Prerequisites

  • Python 3.9 or later. No third-party packages.
  • A Telnyx API key:
export TELNYX_API_KEY="<your Telnyx API key>"

Note: The model list changes over time. The models and counts below are from the day this guide was tested.

1. Save the script

Save this as models_by_region.py:

import json
import os
import sys
import urllib.request

region = sys.argv[1] if len(sys.argv) > 1 else "EU"

request = urllib.request.Request(
    "https://api.telnyx.com/v2/ai/models",
    headers={"Authorization": f"Bearer {os.environ['TELNYX_API_KEY']}"},
)
with urllib.request.urlopen(request) as response:
    models = json.load(response)["data"]

matches = [
    m for m in models
    if region in m["regions"] and m["task"] in ("text-generation", "text generation")
]

print(f"{len(matches)} of {len(models)} models list region {region}")
for m in sorted(matches, key=lambda m: m["id"]):
    vision = "vision" if m["is_vision_supported"] else "text"
    print(f"{m['id']:<48} {m['context_length']:>9} tokens  {vision}  regions={','.join(m['regions'])}")

2. Run it for a region

python3 models_by_region.py EU

Real output:

4 of 34 models list region EU
deepseek-ai/DeepSeek-V4.1-Flash                    1048576 tokens  vision  regions=EU,USA
moonshotai/Kimi-K2.6                                262144 tokens  vision  regions=AUS,EU,UAE,USA
zai-org/GLM-5.3                                    1048576 tokens  text  regions=AUS,EU,USA
zai-org/GLM-5.3-Flash                              1048576 tokens  vision  regions=AUS,EU,UAE,USA

3. Try other regions

python3 models_by_region.py AUS
4 of 34 models list region AUS
moonshotai/Kimi-K2.5                                256000 tokens  vision  regions=AUS,USA
moonshotai/Kimi-K2.6                                262144 tokens  vision  regions=AUS,EU,UAE,USA
zai-org/GLM-5.3                                    1048576 tokens  text  regions=AUS,EU,USA
zai-org/GLM-5.3-Flash                              1048576 tokens  vision  regions=AUS,EU,UAE,USA

An unknown region prints an empty result:

python3 models_by_region.py MARS
0 of 34 models list region MARS

Verify the result

Check the script's claim against the raw response by counting the models whose regions list contains EU:

curl -s https://api.telnyx.com/v2/ai/models \
  -H "Authorization: Bearer $TELNYX_API_KEY" \
  | python3 -c "import json,sys; m=json.load(sys.stdin)['data']; print(sum('EU' in x['regions'] for x in m), 'of', len(m))"

Expected: the count printed matches the first number reported by python3 models_by_region.py EU for text-generation models, and the second number equals the total model count. On the day of testing, the raw count for EU was 4 of 34. The numbers change as the catalog changes.

How it works

The endpoint returns one object per model. Region support is the regions list on each object, and a separate regions_by_service_tier object groups regions by service tier (the keys seen were default, priority, and flex). The script filters on regions only. Regions seen across the catalog were USA, AUS, EU, and UAE.

Common issues

Many models have an empty regions list

Sixteen of the 34 models returned an empty regions list, including anthropic/claude-haiku-4-5, google/gemini-2.5-flash, and each of the openai/ models. A region filter excludes all of them. An empty list means no region is listed. It does not by itself say whether the model can be called.

Authentication is required

GET /v2/ai/models without an Authorization header returns HTTP 401, and so does a malformed key.

Query-string filters did not narrow the list

A request with filter[owned_by]=openai returned all 34 models, from five owned_by values. Filter in your own code.

The task value is spelled two ways

The catalog contained 18 models with text-generation, 14 with text generation, one with text-to-text, and one with speech-to-speech. The script matches the first two spellings, so the last two task types are excluded.

Pricing fields read zero

Thirty models reported "input": "0.000000" in pricing, and four had an empty pricing object ({}). Treat these values as unreliable for cost estimates and confirm prices on the Telnyx pricing page.

Next steps

  • Search for phone numbers to pair with a voice assistant: 01-search-available-phone-numbers-with-the-telnyx-cli.md.
  • Receive and verify webhooks from voice and messaging events: 04-verify-telnyx-webhook-signatures-in-python.md.

verification:
  status: verified
  tested_at: "2026-10-06"
  product_version: "Telnyx REST API v2, Python 3.9.6"
  command: "python3 models_by_region.py EU"
  expected_result: "A header line 'N of M models list region EU' followed by N text-generation models that list EU. Counts vary as the model catalog changes."

Related Articles