Skip to main content

tarjamli

A small Python client for Tarjamli translation through the Sawalni API. Translate text, convert Darija between Arabic and Latin scripts, and give the translation context about tone, gender or address forms.

Python 3.10+. No runtime dependencies.

Install

pip install tarjamli

Set your Sawalni API key:

export SAWALNI_API_KEY="your-key"

Translate

from tarjamli import Tarjamli

client = Tarjamli()
result = client.translate(
    "واش تقدر تصيفط ليا الدوسي؟",
    source="ary_Arab",
    target="fra_Latn",
    instructions="Address one person formally using vous.",
)
print(result.text)

Pass your own text. Remove instructions for ordinary translation, or change it to supply context. The API field is instructions; tone and gender are not separate parameters.

Convert Darija scripts

result = client.translate(
    "سلام، كيف داير؟",
    source="ary_Arab",
    target="ary_Latn",
)
print(result.text)

Reverse the source and target for Latin → Arabic. Use client.languages() to list supported language and script codes, including shi_Latn for Tachelhit and zgh_Tfng for Tamazight in Tifinagh.

CLI

tarjamli translate --text 'واش تقدر تصيفط ليا الدوسي؟' --source ary_Arab --target fra_Latn --instructions 'Address one person formally using vous.'
tarjamli languages

Use --text - to read standard input. Add --json for the full API response.

Configuration and results

Tarjamli(api_key=None, timeout=180) reads SAWALNI_API_KEY when no key is passed. Keep keys in server-side code or your terminal environment. The package does not load .env files.

translate(text, *, source, target, instructions="", model="tarjamli-mini-v4") returns a Translation with text, source, target, model, and raw (the full response, including usage when supplied). This release supports the checked Mini model only.

Each call sends one request to POST https://api.sawalni.com/v1/language/translate. Live requests use your API balance. There are no automatic retries.

Errors

from tarjamli import AuthenticationError, RateLimitError, TranslationError

try:
    result = client.translate("Hello", source="eng_Latn", target="ary_Arab")
except AuthenticationError:
    # Check your key and model access.
    raise
except RateLimitError:
    # Decide when to retry in your application.
    raise
except TranslationError:
    # Includes incomplete responses, connection errors and unexpected identities.
    raise

Invalid local input raises ValueError. Incomplete output raises IncompleteTranslationError, a subclass of TranslationError. The client checks the returned model and language codes before returning a result.

More examples · API documentation · MIT license.

Metadata

Release files for tarjamli 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tarjamli 0.1.2
File Size Uploaded Provenance Actions
tarjamli-0.1.2.tar.gz 8.1 kB With provenance Details for tarjamli-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tarjamli 0.1.2
File Interpreter ABI Platform Actions
tarjamli-0.1.2-py3-none-any.whl Python 3 none any Details for tarjamli-0.1.2-py3-none-any.whl

Total release size: 15.7 kB

Release files / tarjamli-0.1.2.tar.gz

Download URL tarjamli-0.1.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6b458f06397fdf95f5975aabcc0ba81e7580725ebe5d71ce98dd8d49ed8cfc47
BLAKE2b-256 checksum
How to use checksums
27443b3b6a6268e1b1e5bc4d2dff1cb6459ddbfda295e17de18517fdcc04bb1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 11, 2026.

Transparency log

Release files / tarjamli-0.1.2-py3-none-any.whl

Download URL tarjamli-0.1.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a2f14da3ba78e7047b3fb1cdb9dc1f7740cfc1448165cd3c9a15eef2bf1b2c5
BLAKE2b-256 checksum
How to use checksums
056814cba77929a3861c4764d377e596637f0346f47e78552937d2c5d80b4a5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 11, 2026.

Transparency log

Security for tarjamli 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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tarjamli-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 11, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page