@absoluteinterpreting/translate-ai
v0.1.2
Published
Official browser JavaScript SDK for ABS Translate AI.
Maintainers
Readme
ABS Translation AI JavaScript SDK
Browser SDK for translating approved website content through ABS Translate AI.
Install
npm install @absoluteinterpreting/translate-aiPublic browser key setup
- In ABS Translate AI → API keys, choose the website project you are integrating.
- Create or select a Public browser key. The portal automatically restricts it to that project's verified base website origin.
- Copy the full key when it is shown. It is displayed only once.
- Use that key with the same project ID in browser code served from the approved origin.
Do not use a key from another project or website. A public browser key is designed for approved browser use, but it is still project-scoped and must never be committed to a public repository.
Quick start
import { AbsTranslationClient } from "@absoluteinterpreting/translate-ai";
const client = new AbsTranslationClient({
baseUrl: "https://api.translate.absolute.co.uk",
// Public browser key for this project's verified origin only.
apiKey: "abs_public_prefix.secret",
});
const result = await client.translate({
project_id: 1,
url: "https://example.com/pricing",
text: "Continue",
source_language: "en",
target_language: "fr",
});The request is accepted only when all of the following match: the public key,
the project_id, the website's verified origin, and the project's approved
translation access. For local development, create a project whose verified
origin is your local HTTPS test address before using the SDK.
The SDK validates HTTPS configuration and payloads, uses abortable timeouts, adds an idempotency key for translation requests, and retries only transient network/429/5xx failures (maximum three attempts). It never logs or persists the installation key. The API remains responsible for entitlement, origin validation, pricing, rate limits and provider routing.
Each project has its own project_id; do not reuse one project ID across
unrelated websites or applications. Use this JavaScript SDK in a browser only
with a public browser key restricted to that project's verified origin.
Never ship a private server key to a browser, JavaScript bundle, mobile app bundle, HTML, or public repository. Private keys are for trusted backend code only; browser and mobile clients should call your backend when private server access is required.
For browser navigation or header controls, use the included display helpers:
import { formatLanguageLabel } from "@absoluteinterpreting/translate-ai";
// formatLanguageLabel("fr") returns "🇫🇷 French"