Official Python SDK for the Langbly translation API — a drop-in replacement for Google Translate v2, powered by LLMs.
5-10x cheaper than Google Translate · Better quality · Switch in one PR
pip install langblyfrom langbly import Langbly
client = Langbly(api_key="your-api-key")
# Translate text
result = client.translate("Hello world", target="nl")
print(result.text) # "Hallo wereld"
# Batch translate
results = client.translate(["Hello", "Goodbye"], target="nl")
for r in results:
print(r.text)
# Detect language
detection = client.detect("Bonjour le monde")
print(detection.language) # "fr"
# List supported languages
languages = client.languages(target="en")Already using google-cloud-translate? Switching takes 2 minutes:
# Before (Google Translate)
from google.cloud import translate_v2 as translate
client = translate.Client()
result = client.translate("Hello", target_language="nl")
# After (Langbly) — same concepts, better translations, 5x cheaper
from langbly import Langbly
client = Langbly(api_key="your-key")
result = client.translate("Hello", target="nl")→ Full migration guide: langbly.com/docs/migrate-google
- Google Translate v2 API compatible — same endpoint format
- Auto-retry — exponential backoff on 429/5xx with Retry-After support
- Typed errors —
RateLimitError,AuthenticationError,LangblyError - Batch translation — translate multiple texts in one request
- Language detection — automatic source language identification
- HTML support — translate HTML while preserving tags
- Context manager — use
withfor automatic cleanup
from langbly import Langbly, RateLimitError, AuthenticationError
client = Langbly(api_key="your-key")
try:
result = client.translate("Hello", target="nl")
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited — retry after {e.retry_after}s")Create a client instance.
api_key(str): Your Langbly API key — get one freebase_url(str, optional): Override the API URL (default:https://api.langbly.com)timeout(float, optional): Request timeout in seconds (default: 30)max_retries(int, optional): Retries for transient errors (default: 2)
text(str | list[str]): Text(s) to translatetarget(str): Target language code (e.g., "nl", "de", "fr")source(str, optional): Source language code (auto-detected if omitted)format(str, optional): "text" or "html"
text(str): Text to analyze
target(str, optional): Language code to return names in
MIT