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.1.0.tar.gz (295.3 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.1.0-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: telnyx_agent_toolkit-0.1.0.tar.gz
  • Upload date:
  • Size: 295.3 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.1.0.tar.gz
Algorithm Hash digest
SHA256 f5afb47ece348beaa8dad1f8a8e44fa2b3e10afd660e9ada28e1ee4ffd6fbeac
MD5 182d70abe8d01fa6aad5077cc688744a
BLAKE2b-256 a7c0437c122a1b197ca2b7f199b0e27fcc7ed5a33231faabb3c0b07ce6b8083b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: telnyx_agent_toolkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.2 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b30b58067562b435b2f3ed447cee96f757b534b762150a82735ea55dd89b423b
MD5 3f0b8a58fed71f46c3935e9ba03be667
BLAKE2b-256 2a08a1c0ac01497392ef567ee8c7f1910b6b767b4855c4a5a1e6b22b673fe2d9

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