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

Metadata

Release files for telnyx-agent-toolkit 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for telnyx-agent-toolkit 0.3.0
File Size Uploaded
telnyx_agent_toolkit-0.3.0.tar.gz 302.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for telnyx-agent-toolkit 0.3.0
File Interpreter ABI Platform
telnyx_agent_toolkit-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 342.2 kB

Release files / telnyx_agent_toolkit-0.3.0.tar.gz

Download URL telnyx_agent_toolkit-0.3.0.tar.gz
Size 302.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5fd8db2cae53f90084d14872c6ad5996c81ec8453262e49f3d94e15726e1f7bc
BLAKE2b-256 checksum
How to use checksums
44f43fd7f32e9b26f08608ea1e2f24857be0198a01674a48b905f000ca266dd8
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / telnyx_agent_toolkit-0.3.0-py3-none-any.whl

Download URL telnyx_agent_toolkit-0.3.0-py3-none-any.whl
Size 39.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
719e5e9186631326b65c5d97c0bd42fc579a585ee6242bb7754ac0d196a4a0b0
BLAKE2b-256 checksum
How to use checksums
7d06967d2071d589417d39c5a2d5c4b4199003ceb2a0518439f74cd6647d1849
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page