Pydantic AI Telegram
Wrap any Pydantic AI agent with Telegram in one line of code.
Why? Pydantic AI makes building AI agents simple. This library lets you expose them via Telegram instantly — perfect for personal assistants, prototypes, or internal tools - Image, documents and voice memos are supported natively.
Installation
pip install pydantic-ai-telegram
With local voice transcription (requires ffmpeg):
pip install pydantic-ai-telegram[whisper]
Quick Start
Option 1: CLI Configuration
Run the interactive setup:
pydantic-ai-telegram-config
This creates a .env file with your configuration.
Option 2: Manual Configuration
Create a .env file:
# Required
TELEGRAM_BOT_TOKEN=your_token_from_botfather
# Optional - Access control
TELEGRAM_ALLOWED_CHAT_IDS=123456789,987654321
TELEGRAM_ALLOWED_USERNAMES=alice,bob
# Optional - Voice transcription (local whisper)
TRANSCRIPTION_SERVICE=local
WHISPER_MODEL=turbo
# Optional - OpenAI (for agent or transcription)
OPENAI_API_KEY=sk-...
# Optional - Conversation history limit
MAX_HISTORY_MESSAGES=50
Minimal Example
import os
from dotenv import load_dotenv
from pydantic_ai import Agent
from pydantic_ai_telegram import TelegramAgent
load_dotenv()
# Your Pydantic AI agent
agent = Agent(
"openai:gpt-4o-mini",
system_prompt="You are a helpful assistant.",
)
# Wrap it with Telegram
bot = TelegramAgent(
bot_token=os.getenv("TELEGRAM_BOT_TOKEN"),
agent=agent,
)
bot.run()
That's it. Your agent is now accessible via Telegram.
Voice Transcription
Local transcription uses OpenAI Whisper running on your machine:
from pydantic_ai_telegram import TelegramAgent, LocalWhisperTranscription
transcription = LocalWhisperTranscription(model_name="turbo")
bot = TelegramAgent(
bot_token=os.getenv("TELEGRAM_BOT_TOKEN"),
agent=agent,
transcription_service=transcription,
)
Note: Cloud transcription (OpenAI API) is planned for a future release.
License
MIT
Metadata
Release files for pydantic-ai-telegram 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pydantic_ai_telegram-0.1.2.tar.gz | 27.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_ai_telegram-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.6 kB
Release files / pydantic_ai_telegram-0.1.2.tar.gz
| Download URL | pydantic_ai_telegram-0.1.2.tar.gz |
|---|---|
| Size | 27.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a348de16f27dc04203a0dc2c17e6948c7b1485b65c798ef74765f6eeca21f7f
|
|
BLAKE2b-256 checksum How to use checksums |
9d773f5d689bad04ac2192b9fb9632b41057520df12c3fcbc6743fdf5645fdc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2025.
Transparency logRelease files / pydantic_ai_telegram-0.1.2-py3-none-any.whl
| Download URL | pydantic_ai_telegram-0.1.2-py3-none-any.whl |
|---|---|
| Size | 27.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd485d6ecbe458671be1eafb8f56f85acfabf47467b1e10857504edabab1d382
|
|
BLAKE2b-256 checksum How to use checksums |
28247b6cd31eceae22150909c6217aa660aa1def11eaa1e80b180057ca32cb9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2025.
Transparency logSecurity for pydantic-ai-telegram 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pydantic_ai_telegram-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.