Skip to main content

Telnyx Agent Toolkit — tools for building AI agents with Telnyx APIs

Project description

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

Project details


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.2.0.tar.gz (292.8 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.2.0-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: telnyx_agent_toolkit-0.2.0.tar.gz
  • Upload date:
  • Size: 292.8 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.2.0.tar.gz
Algorithm Hash digest
SHA256 07f68fe7badc937932ca6147504a655e4b1fee6329e28119875abec6cac4f835
MD5 ca0d373088e7025e1d24856ab74d9a0e
BLAKE2b-256 147925fb6c499db1fd37d7e5eedff69300fa340e51d4a940be74ac3ec746b0e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: telnyx_agent_toolkit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.3 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab38eecab72d643bbe399daf02bb91bfe5172a53db00c33f53356f91107d61f4
MD5 b56ae31c6bfa77b2d84d45a1d9234b3e
BLAKE2b-256 6140146cde59b780c3f6e3960c4de6046495ccc9ab5938ab9fd87237a1cd0c1e

See more details on using hashes here.

Supported by

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