Skip to main content

Telnyx Agent Toolkit

Python SDK for building AI agents with Telnyx APIs. Works with OpenAI, LangChain, and CrewAI.

Installation

# Core (no framework dependency)
pip install telnyx-agent-toolkit

# With OpenAI support
pip install telnyx-agent-toolkit[openai]

# With LangChain support
pip install telnyx-agent-toolkit[langchain]

# With CrewAI support
pip install telnyx-agent-toolkit[crewai]

# Everything
pip install telnyx-agent-toolkit[all]

Quick Start

OpenAI

import os
from openai import OpenAI
from telnyx_agent_toolkit import TelnyxAgentToolkit

toolkit = TelnyxAgentToolkit(
    api_key=os.environ["TELNYX_API_KEY"],
    configuration={
        "actions": {
            "messaging": {"send_sms": True},
            "numbers": {"list": True, "search": True},
            "account": {"get_balance": True},
        }
    },
)

client = OpenAI()
tools = toolkit.get_openai_tools()
executor = toolkit.get_openai_tool_executor()

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "What's my Telnyx balance?"}],
    tools=tools,
)

# Execute tool calls
for tool_call in response.choices[0].message.tool_calls:
    result = executor.execute(tool_call)
    print(result)

LangChain

from telnyx_agent_toolkit import TelnyxAgentToolkit

toolkit = TelnyxAgentToolkit(api_key="KEY...")
tools = toolkit.get_langchain_tools()

# Use with any LangChain agent
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o")
llm_with_tools = llm.bind_tools(tools)

CrewAI

from crewai import Agent
from telnyx_agent_toolkit import TelnyxAgentToolkit

toolkit = TelnyxAgentToolkit(api_key="KEY...")
tools = toolkit.get_crewai_tools()

agent = Agent(
    role="Telecom Specialist",
    goal="Help manage phone numbers and messaging",
    tools=tools,
)

Configuration

Control which tools are available to the agent:

toolkit = TelnyxAgentToolkit(
    api_key="KEY...",
    configuration={
        "actions": {
            # Messaging
            "messaging": {
                "send_sms": True,            # Send SMS/MMS
                "list_messaging_profiles": True,
                "create_messaging_profile": True,
            },
            # Phone Numbers
            "numbers": {
                "list": True,    # List account numbers
                "search": True,  # Search available numbers
                "buy": True,     # Purchase numbers (charges account)
            },
            # Account
            "account": {
                "get_balance": True,
            },
            # Voice
            "voice": {
                "make_call": True,
                "list_connections": True,
            },
            # AI
            "ai": {
                "chat": True,              # Chat completions
                "embed": True,             # Embeddings
                "list_ai_assistants": True,
                "create_ai_assistant": True,
            },
            # Fax
            "fax": {
                "send_fax": True,
            },
            # Lookup
            "lookup": {
                "lookup_number": True,     # Carrier/CNAM lookup
            },
            # IoT
            "iot": {
                "list_sim_cards": True,
            },
            # Verification
            "verify": {
                "verify_phone": True,      # Send verification code
                "verify_code": True,       # Check verification code
            },
        }
    },
)

No configuration = all tools enabled. Use configuration to restrict which tools the agent can access.

Available Tools

Tool Category Description
send_sms Messaging Send an SMS or MMS message
list_messaging_profiles Messaging List messaging profiles
create_messaging_profile Messaging Create a messaging profile
list_phone_numbers Numbers List phone numbers on the account
search_phone_numbers Numbers Search available numbers to buy
buy_phone_number Numbers Purchase a phone number
get_balance Account Check account balance
make_call Voice Initiate an outbound call
list_connections Voice List voice connections
ai_chat AI Chat completion via Telnyx inference
ai_embed AI Generate embeddings
list_ai_assistants AI List AI assistants
create_ai_assistant AI Create an AI assistant
send_fax Fax Send a fax
lookup_number Lookup Phone number lookup
list_sim_cards IoT List IoT SIM cards
verify_phone Verify Start phone verification
verify_code Verify Check verification code

Async Support

All tools support async execution natively:

# Async execution
result = await executor.execute_async(tool_call)

# Direct tool execution
result = await toolkit.core.run_tool_async("get_balance", {})

API Client

Access the underlying HTTP client directly:

# Async
data = await toolkit.api_client.get_async("/phone_numbers")

# Sync
data = toolkit.api_client.get("/phone_numbers")

Requirements

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint
ruff check .

# Type check
pyright

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telnyx_agent_toolkit-0.3.0.tar.gz (302.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telnyx_agent_toolkit-0.3.0-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file telnyx_agent_toolkit-0.3.0.tar.gz.

File metadata

  • Download URL: telnyx_agent_toolkit-0.3.0.tar.gz
  • Upload date:
  • Size: 302.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for telnyx_agent_toolkit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5fd8db2cae53f90084d14872c6ad5996c81ec8453262e49f3d94e15726e1f7bc
MD5 e40288aa2bd331184b1c03dda4df40e3
BLAKE2b-256 44f43fd7f32e9b26f08608ea1e2f24857be0198a01674a48b905f000ca266dd8

See more details on using hashes here.

File details

Details for the file telnyx_agent_toolkit-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: telnyx_agent_toolkit-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for telnyx_agent_toolkit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 719e5e9186631326b65c5d97c0bd42fc579a585ee6242bb7754ac0d196a4a0b0
MD5 15581dcbffca8a0ff5843f9f1c44d28b
BLAKE2b-256 7d06967d2071d589417d39c5a2d5c4b4199003ceb2a0518439f74cd6647d1849

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page