Telegram Auto-Translate
A Telegram userbot that automatically translates your outgoing messages using conversation context.
| Before | After |
|---|---|
How It Works
Your message → Detect languages → Translate with Claude → Clean output → Edit in place
- Watch - Monitors your outgoing messages
- Analyze - Gathers recent chat context (default: 10 messages)
- Detect - Uses GPT-5.6 Luna to identify the target language based on who you're replying to
- Skip if unnecessary - Won't translate if your message is already in the target language
- Translate - Claude translates with full conversation context, matching the chat's tone and style
- Clean - Strips any LLM artifacts (preambles, quotes) from the output
- Edit - Replaces your original message with the translation
Installation
Via PyPI (Recommended)
pip install telegram-auto-translate
From Source
git clone https://github.com/aimoda/telegram-auto-translate
cd telegram-auto-translate
pip install -e .
Quick Start
# Set required environment variables
# Get TG_API_ID and TG_API_HASH from https://my.telegram.org/apps
export TG_API_ID="your_api_id"
export TG_API_HASH="your_api_hash"
export BEDROCK_AWS_PROFILE="your_aws_profile"
# Run
telegram-auto-translate
On first run, Telethon will prompt for your phone number and login code.
Prerequisites
- Python 3.10+
- Telegram API credentials - Get
API_IDandAPI_HASHfrom my.telegram.org - AWS account with Amazon Bedrock access to both the Anthropic (Claude) and OpenAI (GPT) models, plus appropriate IAM permissions
Configuration
Telegram
| Variable | Description |
|---|---|
TG_API_ID |
Your Telegram API ID (required) |
TG_API_HASH |
Your Telegram API hash (required) |
TG_SESSION_NAME |
Session file name (default: translator_session) |
AWS Bedrock (Claude + GPT)
Both models run on Amazon Bedrock, authenticated with SigV4 request signing from a single AWS profile — there is no separate OpenAI API key. They use different Bedrock endpoints:
- Claude goes through
bedrock-runtime(InvokeModel), so it can use theglobal.cross-region inference profile — dynamic routing with no regional pricing premium. - GPT goes through the regional Mantle endpoint
(
https://bedrock-mantle.<region>.api.aws), which is the only way OpenAI models are served on Bedrock.
- Create an IAM user with programmatic access, then attach an IAM policy with Bedrock invoke permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowBedrockModelInvocationInAUSCANNZUKUS",
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Condition": {
"StringEquals": {
"aws:RequestedRegion": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ca-central-1",
"ca-west-1",
"eu-west-2",
"ap-southeast-2",
"ap-southeast-4",
"unspecified"
]
}
},
"Resource": [
"arn:aws:bedrock:*::foundation-model/*",
"arn:aws:bedrock:*:*:provisioned-model/*",
"arn:aws:bedrock:*:*:imported-model/*",
"arn:aws:bedrock:*:*:inference-profile/*"
]
}
]
}
- Add credentials to
~/.aws/credentials:
[telegram-translator-bedrock]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
- Set the profile:
export BEDROCK_AWS_PROFILE="telegram-translator-bedrock"
export BEDROCK_AWS_REGION="us-east-1" # optional, us-east-1 is default
- Enable model access for both
global.anthropic.claude-opus-5andopenai.gpt-5.6-luna. Claude routes globally via the inference profile, but GPT is served per-region — see model support by AWS Region and setBEDROCK_AWS_REGIONto one that servesopenai.gpt-5.6-luna.
Usage
telegram-auto-translate [options]
Command-Line Flags
| Flag | Description | Default |
|---|---|---|
--dry-run |
Log translations without editing messages | Off |
--debug |
Verbose logging of API calls | Off |
--context-messages N |
Number of previous messages for context | 10 |
--bedrock-profile NAME |
AWS profile for Bedrock | $BEDROCK_AWS_PROFILE |
--bedrock-region REGION |
AWS region for Bedrock | us-east-1 |
--anthropic-model MODEL |
Claude model ID | global.anthropic.claude-opus-5 |
--openai-model MODEL |
GPT model for detection/cleaning | openai.gpt-5.6-luna |
Environment Variables Reference
| Variable | Required | Description |
|---|---|---|
TG_API_ID |
Yes | Telegram API ID |
TG_API_HASH |
Yes | Telegram API hash |
BEDROCK_AWS_PROFILE |
Yes | AWS credentials profile (used for both Claude and GPT) |
BEDROCK_AWS_REGION |
No | AWS region (default: us-east-1) |
TG_SESSION_NAME |
No | Session file name |
ANTHROPIC_MODEL |
No | Claude model override |
OPENAI_MODEL |
No | GPT model override |
CONTEXT_MESSAGES |
No | Context message count |
Examples
Test without editing messages:
telegram-auto-translate --dry-run --debug
Use more context for better translations:
telegram-auto-translate --context-messages 20
Run in a different Bedrock region:
BEDROCK_AWS_REGION="us-east-2" telegram-auto-translate
Troubleshooting
"TG_API_ID and TG_API_HASH are required"
Set both environment variables or pass --api-id and --api-hash flags.
"BEDROCK_AWS_PROFILE is required"
Set BEDROCK_AWS_PROFILE to your AWS credentials profile name. The same profile
signs requests for both the Claude and GPT models.
Translation not happening
- Check that there are previous messages in the chat (the bot needs context)
- Your message might already be in the detected target language
- Use
--debugto see detection results
"AccessDeniedException" from Bedrock
Verify your IAM policy includes bedrock:InvokeModel permission and that both
global.anthropic.claude-opus-5 and openai.gpt-5.6-luna are enabled for your
account and region.
First run hangs
Telethon is waiting for your phone number. Enter it in the terminal.
Development Setup
For local development and contributions:
Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install the package
# Install in editable mode for development
pip install -e .
Run the application
# Option 1: Use the installed command
telegram-auto-translate
# Option 2: Run as module (without installing)
PYTHONPATH=src python -m telegram_auto_translate
Why Bedrock?
Everything runs on Amazon Bedrock: Claude Opus 5 for translation, GPT-5.6 Luna
for language detection and output cleaning. One AWS account, one credentials
profile, one set of data-handling terms. Claude uses the global. inference
profile for cross-region routing without the regional pricing premium.
| Task | Model | Why |
|---|---|---|
| Translation | Claude Opus 5 | Adaptive thinking for nuanced, context-aware translations |
| Language Detection | GPT-5.6 Luna | Excellent structured output performance |
| Output Cleaning | GPT-5.6 Luna | Reliable artifact removal |
We prefer Bedrock for its data handling policies:
- Inputs and outputs are not logged by default
- Zero operator access for the GPT models, which are served through Mantle
- Configurable data retention, including zero data retention on eligible accounts
Metadata
Release files for telegram-auto-translate 0.1.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| telegram_auto_translate-0.1.16.tar.gz | 51.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| telegram_auto_translate-0.1.16-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.3 kB
Release files / telegram_auto_translate-0.1.16.tar.gz
| Download URL | telegram_auto_translate-0.1.16.tar.gz |
|---|---|
| Size | 51.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af71d11ed26e855a8e6bbaafbe3c3e3add0b60f6d1c42d3a7efdf17de7608b82
|
|
BLAKE2b-256 checksum How to use checksums |
e84b7f9fbd9515a4661db702cf441e4de333a5f34264431bc4d888f434225490
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 5, 2026.
Transparency logRelease files / telegram_auto_translate-0.1.16-py3-none-any.whl
| Download URL | telegram_auto_translate-0.1.16-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
829e2de40b496ea1d61688d320b2dcf90e64ccfcfa2bed0ae5714dbf6258e403
|
|
BLAKE2b-256 checksum How to use checksums |
f4c80fef6c07813507ac11221cee8f7caa3dea62c302f6ca06eccd1c3efb326b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 5, 2026.
Transparency log