Skip to main content
Version: 1.2.1

Translation Service Documentation

This is the Translation Service

Paths

/translation/api/v1/healthz

GET /translation/api/v1/healthz

Summary: Health

Description: Return Health Status.

Responses:

  • 200: Successful Response
    • Content: application/json
    • Schema: Msg

/translation/api/v1/docs

POST /translation/api/v1/docs

Summary: Generate Translation

Description: Generate translation for the provided source text into the specified target language.

Request Body:

TypeParameterDescriptionData Typeis_optional
Query Parametersource_textText to be translated.stringmandatory
Query ParametermodelModel to be used for translation.string (enum)mandatory
Query Parametertarget_languageLanguage to translate the text into.string (enum)mandatory
Query Parameterfile_nameName of the file being translated.stringoptional

Sample Code:

import requests

# Define the API endpoint and the payload
url = "https://api-genai-dev.learningmate.co/translation/api/v1/text"
headers = {
"accept": "application/json",
"Authorization": "Bearer {Your Token Here}", # Replace {Your Token Here} with your actual token
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"source_text": "Hello, How are you?",
"target_language": "Hindi",
"model": "gpt-4o-mini"
}

# Make the POST request
response = requests.post(url, headers=headers, data=data)

# Print the response
if response.status_code == 200:
print("Response Data:", response.json())
else:
print("Failed to call the API. Status Code:", response.status_code)
print("Response Text:", response.text)

Example response:

{
"status_code": 200,
"message": "Success: Translation generated successfully.",
"translation": "Translated text here"
}

Responses:

Status CodeDescriptionContent-TypeDetails
200Translation generatedapplication/jsonSuccessful Response - Status retrieved successfully
400Bad Requestapplication/jsonBad Request - Invalid format
401Authentication failedapplication/jsonUnauthorized - Invalid or missing authentication token
404Model not foundapplication/jsonModel not found - Invalid model.
422Validation Errorapplication/jsonSchema: HTTPValidationError
500Internal server errorapplication/jsonAn error occurred while generating the translation : [error details].

Components

Schemas

  • Msg
  • TranslationRequest
  • HTTPValidationError