Skip to content

Python: [Feature]: Add Telnyx provider sample (OpenAI-compatible endpoint) #5925

@gbattistel

Description

@gbattistel

Description

Add a provider sample showing how to use Telnyx as an OpenAI-compatible endpoint with the existing OpenAIChatCompletionClient and OpenAIEmbeddingClient, following the same pattern as the existing Ollama sample.

Problem it solves:

Telnyx provides an OpenAI-compatible API at https://api.telnyx.com/v2/ai/openai that supports chat completions, embeddings, and function/tool calling. Users who want to use Telnyx as their inference provider currently have no reference sample showing how to configure the OpenAI clients with a custom base_url.

This follows the same pattern as the existing Ollama provider sample (python/samples/02-agents/providers/ollama/ollama_with_openai_chat_client.py).

Expected behavior:

Add a python/samples/02-agents/providers/telnyx/ directory with:

  1. telnyx_chat_completion.py — Basic chat completion using OpenAIChatCompletionClient with Telnyx endpoint
  2. telnyx_embeddings.py — Embeddings using OpenAIEmbeddingClient with Telnyx endpoint
  3. telnyx_chat_completion_with_tools.py — Chat completion with function calling, demonstrating Telnyx telecom tools (SMS, number lookup, verify) via telnyx-agent-toolkit
  4. README.md — Setup instructions, environment variables, and usage

All samples use the existing OpenAI provider clients — no new provider code is needed. The configuration is simply setting base_url and api_key:

client = OpenAIChatCompletionClient(
    model="Kimi-K2.5",
    api_key=os.getenv("TELNYX_API_KEY"),
    base_url="https://api.telnyx.com/v2/ai/openai",
)

No public API changes. Pure docs + runnable samples only.

I checked the repository and did not find existing Telnyx issues, PRs, or sample references. If this direction fits the project, I can send a PR that follows python/samples/SAMPLE_GUIDELINES.md and the Python sample validation flow.

Code Sample

import asyncio
import os

from agent_framework import Agent
from agent_framework.openai import OpenAIChatCompletionClient


async def main() -> None:
    client = OpenAIChatCompletionClient(
        model="Kimi-K2.5",
        api_key=os.getenv("TELNYX_API_KEY"),
        base_url="https://api.telnyx.com/v2/ai/openai",
    )

    agent = Agent(chat_client=client, instructions="You are a helpful assistant.")

    result = await agent.run("What is the capital of France?")
    print(result)


if __name__ == "__main__":
    asyncio.run(main())

Language/SDK

Python

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions