Initialization Guide

The Translator class is the core component of the Lara SDK

The Translator class serves as the primary interface for all translation services, including text, document, audio and image processing. To use any Lara feature, you must first initialize this class with your authentication credentials.

Authentication

Before instantiating the class, you need your LARA_ACCESS_KEY_ID and LARA_ACCESS_KEY_SECRET, which can be generated in the API Credentials section of your Lara Account

Initialization

The SDK is designed to be idiomatic across different programming languages. Below are the standard initialization patterns for our supported environments:

from lara_sdk import Translator, Credentials

LARA_ACCESS_KEY_ID = "your-access-key-id"
LARA_ACCESS_KEY_SECRET = "your-access-key-secret"

# Initialization of the Translator class
credentials = Credentials(access_key_id=LARA_ACCESS_KEY_ID, access_key_secret=LARA_ACCESS_KEY_SECRET)
lara = Translator(credentials)
import {Credentials, Translator} from "@translated/lara";

const LARA_ACCESS_KEY_ID: string = "your-access-key-id";
const LARA_ACCESS_KEY_SECRET: string = "your-access-key-secret";

// Initialization of the Translator class
const credentials = new Credentials(LARA_ACCESS_KEY_ID, LARA_ACCESS_KEY_SECRET)
const lara: Translator = new Translator(credentials);
import com.translated.lara.Credentials;
import com.translated.lara.translator.Translator;

private static final String LARA_ACCESS_KEY_ID = "your-access-key-id";
private static final String LARA_ACCESS_KEY_SECRET = "your-access-key-secret";

// Initialization of the Translator class
Credentials credentials = new Credentials(LARA_ACCESS_KEY_ID, LARA_ACCESS_KEY_SECRET);
Translator lara = new Translator(credentials);
<?php

require 'vendor/autoload.php';

use Lara\Translator;
use Lara\LaraCredentials;

$LARA_ACCESS_KEY_ID = "your-access-key-id";
$LARA_ACCESS_KEY_SECRET = "your-access-key-secret";

// Initialization of the Translator class
$credentials = new LaraCredentials($LARA_ACCESS_KEY_ID, $LARA_ACCESS_KEY_SECRET);
$lara = new Translator($credentials);
import (
	lara_sdk "github.com/translated/lara-go/lara"  // alias "lara_sdk", can be changed or removed
)

const (
	LARA_ACCESS_KEY_ID     = "your-access-key-id"
	LARA_ACCESS_KEY_SECRET = "your-access-key-secret"
)

credentials := lara_sdk.NewCredentials(LARA_ACCESS_KEY_ID, LARA_ACCESS_KEY_SECRET)
lara := lara_sdk.NewTranslator(credentials, nil)
import com.translated.lara.Credentials
import com.translated.lara.translator.Translator

private const val LARA_ACCESS_KEY_ID = "your-access-key-id"
private const val LARA_ACCESS_KEY_SECRET = "your-access-key-secret"

// Initialization of the Translator class
val credentials = Credentials(LARA_ACCESS_KEY_ID, LARA_ACCESS_KEY_SECRET)
val lara = Translator(credentials)
string accessKeyId = "your-access-key-id";
string accessKeySecret = "your-access-key-secret";

var credentials = new Credentials(accessKeyId, accessKeySecret);
var lara = new Translator(credentials);
let LARA_ACCESS_KEY_ID = "your-access-key-id"
let LARA_ACCESS_KEY_SECRET = "your-access-key-secret"

// Initialization of the Translator class
let credentials = Credentials(accessKeyId: LARA_ACCESS_KEY_ID, accessKeySecret: LARA_ACCESS_KEY_SECRET)
let lara = Translator(credentials: credentials)

Pro Tip: We recommend instantiating the Translator class once and reusing the instance across your application to optimize performance and connection handling.

Next Step

Once initialized, the Lara instance provides access to a suite of specialized namespaces: