Introduction

Welcome to the Lahajati AI API documentation. Here you'll find all the information you need to integrate our advanced text-to-speech, speech-to-speech, and voice cloning technology into your applications.

Making Requests

Authentication

Lahajati AI API uses API keys to authenticate requests. You can obtain your API key from your account dashboard.

All API requests must include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Requests without authentication will fail with status code `401 Unauthorized`.

Error Handling (General)

Lahajati API uses standard HTTP status codes to indicate the success or failure of an API request. Generally: Codes in the `2xx` range indicate success. Codes in the `4xx` range indicate an error caused by the information provided by the client (e.g., a required parameter was missing, authentication failed, etc.). Codes in the `5xx` range indicate an error from our servers.

  • `400 Bad Request`: The server could not understand the request due to invalid syntax. Check the request body format or query parameters.
  • `401 Unauthorized`: Your API key is missing, invalid, or expired. Make sure to include a valid `Authorization: Bearer YOUR_API_KEY` header.
  • `403 Forbidden`: You don't have permission to access this resource or perform this operation (e.g., trying to modify a resource you don't own, or exceeding package limits).
  • `404 Not Found`: The requested resource was not found (e.g., `id_voice` doesn't exist).
  • `422 Unprocessable Entity`: The request was well-formed but could not be followed due to semantic errors (input validation failure). The response body will usually include an `errors` object with details of which fields failed validation.
  • `429 Too Many Requests`: You have exceeded the rate limit (RPM) allowed for your subscription package. Try again later. See the Rate Limits section.
  • `500 Internal Server Error` / `502 Bad Gateway` / `503 Service Unavailable`: An unexpected error occurred on the server side or the service is temporarily unavailable. If the problem persists, please contact support.

Rate Limits (RPM)

Lahajati AI API enforces limits on the number of requests that can be made per minute (RPM) based on your subscription package. These limits are designed to ensure stable and fair performance for all users. Exceeding these limits will result in a `429 Too Many Requests` error response.

Package Requests Per Minute (RPM)
Starter Package 100
Content Creator Package 250
Premium Package 400
Business Package 500

Concurrent Request Limits

In addition to RPM limits, there are restrictions on the number of concurrent requests your account can run at the same time. This helps maintain system stability.

Package Maximum Concurrent Requests
Starter Package 5
Content Creator Package 10
Premium Package 15
Business Package 20

Voice Cloning Best Practices

To get the best results when using the voice cloning feature, it's essential to provide high-quality audio samples. Here are guidelines and recommendations to help you prepare your audio files:

Audio Quality Guidelines

  • Single speaker only: Ensure the recording clearly contains one person's voice (no other voices or background music).
  • Consistent performance: Maintain consistent volume, tone, and emotion levels throughout the recording as much as possible.
  • Natural pauses: Include short, natural pauses between sentences (0.5 seconds recommended).
  • Quiet environment: Record in a place free from background noise and echo as much as possible.
  • Professional quality (ideal): If possible, use professional recording equipment (good microphone) and in an acoustically treated environment (reduced room echo).

Ideal Audio Sample Characteristics

  • Recommended duration: For the best quality and performance variety (such as the ability to express different emotions), provide an audio sample longer than 60 seconds.
  • For consistent performance: If you're targeting consistent, specific performance (like news reading), a sample between 30-50 seconds with clear voice and consistent performance may be sufficient.
  • Clarity and purity: The audio sample should be completely free from noise and distortion (avoid clipping or distortion). Clear, clean audio is key.
  • Smart training: Our AI system will analyze and train itself on the voice's accent, tone, and performance style (whether happy, enthusiastic, formal, etc.) from the provided sample.

Supported File Formats

We accept a variety of audio file formats (as specified in the `audio_file` parameter for the create cloned voice endpoint).

Text To Speech

These endpoints provide precise and advanced control over the speech generation process. You can specify dialect and performance style separately or provide custom text prompts to get exactly the audio output you need.

GETGET Get Absolute Control Voices

https://lahajati.ai/api/v1/voices-absolute-control

Retrieves a list of voices available specifically for use with the "Generate Speech with Absolute Control" endpoint.

Query Parameters

Optional parameters for filtering, sorting, and paginating results.

Parameter Type Required Description
page integer No (default 1) The page number of results to retrieve.
per_page integer No (default 15, max 100) Number of voices to return per page.
gender string No Filter by gender. Allowed values: `1` (male), `2` (female), `3` (children).
voice_name string (text) No Filter by voice name

Successful Response (200 OK)

Returns a paginated list of compatible voice objects.

GETGET Get Performance Styles

https://lahajati.ai/api/v1/performance-absolute-control

Retrieves a list of available performance styles (such as dramatic, news, advertising) that can be used to guide the speech generation model.

Query Parameters

Parameter Type Required Description
page integer No (default 1) The page number of results to retrieve.
per_page integer No (default 15, max 100) Number of voices to return per page.
performance_name string (text) No Filter by performance name

Successful Response (200 OK)

Returns a paginated list of performance style objects.

GETGET Get Dialects

https://lahajati.ai/api/v1/dialect-absolute-control

Retrieves a list of available dialects (such as Egyptian, Saudi Najdi) that can be used to guide the speech generation model.

Query Parameters

Parameter Type Required Description
page integer No (default 1) The page number of results to retrieve.
per_page integer No (default 15, max 100) Number of voices to return per page.
dialect_name string (text) No Filter by dialect name

Successful Response (200 OK)

Returns a paginated list of dialect objects.

POSTPOST Generate Speech with Absolute Control

https://lahajati.ai/api/v1/text-to-speech-absolute-control

Generates speech from text using a specified voice and precise performance control via two modes: structured mode (using performance and dialect IDs) or custom prompt mode.

Request Body Parameters (JSON)

Parameter Type Required Description
text string Yes The text to be converted to speech.
id_voice string (ID) Yes GET Get Absolute Control Voices: The unique identifier of the desired voice performer. Can be obtained via the Get Voices endpoint.
input_mode string ("0" or "1") Yes Specifies the control mode. `0` for structured mode (using IDs), `1` for custom prompt mode.
performance_id string (ID) No (required if `input_mode` is `0`) Performance style identifier. Obtained from the Get Performance Styles endpoint.
dialect_id string (ID) No (required if `input_mode` is `0`) Dialect identifier. Obtained from the Get Dialects endpoint.
custom_prompt_text string No (required if `input_mode` is `1`) A detailed custom text prompt describing the desired performance.
temperature numeric Value between 0.1 - 2 A setting that controls how creative and varied the output voice is; lower values make it more consistent, higher values increase its variety

Successful Response

On success (`200 OK`), the response body will contain raw audio data. The `Content-Type` header will be `audio/mpeg`.

Error Responses

In addition to the general errors, you may encounter the following errors specific to this endpoint:

  • 401 You don't have the permission or package required to use this voice.
  • 401 Your points balance is insufficient to complete the voice generation operation.
  • 404 The specified `id_voice` does not exist.
  • 422 Input validation failed. Make sure the required parameters for each `input_mode` are present.

POSTPOST Convert Speech with Absolute Control

https://lahajati.ai/api/v1/speech-to-speech-absolute-control

Converts an audio file to speech with another specified voice with advanced control over quality and performance parameters.

Request Body Parameters (JSON)

Parameter Type Required Description
audio_file file (audio file) Yes The audio file to be converted. Supported types: `mp3, wav, aac, ogg`. Maximum size: 50 MB (20 minutes).
id_voice string (ID) Yes The unique identifier of the desired voice performer. Can be obtained via the <a href="#get-voices">Get Voices</a> endpoint.
professional_quality boolean No (default `0`) Set to `1` to enable enhanced processing for professional-quality audio output.
stability numeric No (default `50`) Controls the stability of the output voice. Range: `0` to `100`.
similarity_boost numeric No (default `95`) Enhances similarity to the target voice. Range: `0` to `100`.
style numeric No (default `0`) Affects the style and strength of performance. Range: `0` to `100`.

Successful Response

On success (`200 OK`), the response body will contain raw audio data. The `Content-Type` header will be `audio/mpeg`.

Error Responses

In addition to the general errors, you may encounter the following errors specific to this endpoint:

  • 400 Invalid request, usually due to missing `audio_file` or incorrect `Content-Type`.
  • 401 You don't have the permission or package required to use this voice.
  • 402 Insufficient points balance to perform the conversion operation.
  • 404 The specified `id_voice` does not exist.
  • 422 Input validation failed. Make sure the required parameters for each `input_mode` are present.

Large Language Model (LLM)

These endpoints provide AI conversational and text processing capabilities in Arabic with support for customization and performance control.

POSTPOST Chat Completions

https://lahajati.ai/api/v1/chat/completions

Generates intelligent responses to text messages using large language models specialized for Arabic with advanced customization capabilities.

Request Body Parameters (JSON)

Parameter Type Required Description
message string Yes The text or question to be sent to the AI model.
custom_prompt_message string No Additional instructions to customize the model's behavior and response style.
temperature numeric No (default `1.0`) Controls the creativity and variability of the response. Range: `0.1` to `2.0`.
model string (model) No (default `lahajati_llm_basic`) The model to use. Allowed values: `lahajati_llm_basic`, `lahajati_llm_pro`.

Successful Response (200 OK)

On success, the model's response is returned in the `message` field.

Error Responses

In addition to the general errors, you may encounter the following errors specific to this endpoint:

  • 401 You do not have a subscription package to use this feature. Subscribe to use the feature.
  • 401 Your points balance is insufficient to complete the voice generation operation.
  • 422 Input validation failed. Make sure the required parameters for each `input_mode` are present.
  • 500 The AI model failed to execute your request after several attempts.

Voice Cloning

These endpoints provide advanced voice cloning capabilities for creating, managing, and deleting custom voices.

POSTPOST Create Cloned Voice

https://lahajati.ai/api/v1/voices/cloned

Allows creating a new cloned voice by uploading an audio file for training and providing necessary metadata. The cloned voice will be available for use in text-to-speech after processing is complete.

Request Parameters (Form Data)

Parameter Type Required Description
voice_name string Yes The name to be given to the cloned voice. (Maximum: 25 characters).
gender integer Yes Voice gender. Allowed values: `1` (male), `2` (female), `3` (child).
model string Yes The cloning model to use. Allowed values: `lahajati-classic`, `lahajati-neural`, `lahajati-adaptive`.
audio_file file (audio file) Yes A single audio file for voice cloning training. Supported types: `mp3, wav, aac, ogg, flac, m4a`. Maximum size: 50 MB. (Good quality and clarity without background noise gives the best results).
enhance_audio boolean No (default `false`) Set to `true` to enhance the quality of the training audio file before sending it to the cloning model (may increase processing time).
voice_tags string No Optional keywords or classifications for the cloned voice, separated by commas (example: "calm, formal"). (Maximum: 255 characters).

Successful Response (201 Created)

On successful creation, details of the created cloned voice are returned. The voice may take some time to become fully active.

Error Responses (Create Cloned Voice)

In addition to the general errors, you may encounter the following errors specific to this endpoint:

  • 403 Maximum allowed number of cloned voices has been reached.
  • 422 Input validation failed (e.g., missing name, invalid file type, file too large).
  • 500 Error while contacting external voice cloning service or failed to process the request there.

POSTPUT Update Cloned Voice

https://lahajati.ai/api/v1/voices/cloned/{id_voice}

Allows updating metadata of an existing cloned voice (such as name, gender, image, tags). The original training audio sample cannot be modified.

Path Parameter

Parameter Type Required Description
{id_voice} string (ID) Yes The unique identifier of the cloned voice to be updated (starting with `lvc_`). Passed as part of the URL path.

Optional Request Parameters (Form Data / JSON)

All parameters in the request body are optional. Send only those you want to update.

Parameter Type Required Description
voice_name string No The name to be given to the cloned voice. (Maximum: 25 characters).
gender integer No Voice gender. Allowed values: `1` (male), `2` (female), `3` (child).

Successful Response (200 OK)

On successful update, details of the updated cloned voice are returned.

Error Responses (Update Cloned Voice)

  • 404 Cloned voice not found, or you don't have permission to update it.
  • 422 Input validation failed (e.g., missing name, invalid file type, file too large).

DELETEDELETE Delete Cloned Voice

https://lahajati.ai/api/v1/voices/cloned/{id_voice}

Permanently deletes a cloned voice from the system and from any associated external services.

Path Parameter

Parameter Type Required Description
{id_voice} string (ID) Yes The unique identifier of the cloned voice to be updated (starting with `lvc_`). Passed as part of the URL path.

Successful Response (200 OK)

Confirmation message of successful deletion.

Error Responses (Delete Cloned Voice)

  • 404 Cloned voice not found, or you don't have permission to update it.
  • 500 Failed to delete cloned voice (may be due to external service issue).