> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt.
> For full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Transliteration

POST https://api.sarvam.ai/transliterate
Content-Type: application/json

**Transliteration** converts text from one script to another while preserving the original pronunciation. For example, **'नमस्ते'** becomes **'namaste'** in English, and **'how are you'** can be written as **'हाउ आर यू'** in Devanagari. This process ensures that the sound of the original text remains intact, even when written in a different script.

Transliteration is useful when you want to represent words phonetically across different writing systems, such as converting **'मैं ऑफिस जा रहा हूँ'** to **'main office ja raha hun'** in English letters.

**Translation**, on the other hand, converts text from one language to another while preserving the meaning rather than pronunciation. For example, **'मैं ऑफिस जा रहा हूँ'** translates to **'I am going to the office'** in English, changing both the script and the language while conveying the intended message.
### Examples of **Transliteration**:
- **'Good morning'** becomes **'गुड मॉर्निंग'** in Hindi, where the pronunciation is preserved but the meaning is not translated.
- **'सुप्रभात'** becomes **'suprabhat'** in English.

Available languages:
- **`en-IN`**: English
- **`hi-IN`**: Hindi
- **`bn-IN`**: Bengali
- **`gu-IN`**: Gujarati
- **`kn-IN`**: Kannada
- **`ml-IN`**: Malayalam
- **`mr-IN`**: Marathi
- **`od-IN`**: Odia
- **`pa-IN`**: Punjabi
- **`ta-IN`**: Tamil
- **`te-IN`**: Telugu

For hands-on practice, you can explore the notebook tutorial on [Transliterate API Tutorial](https://github.com/sarvamai/sarvam-ai-cookbook/blob/main/notebooks/transliterate/Transliterate_API_Tutorial.ipynb).

Reference: https://docs.sarvam.ai/api-reference-docs/text/transliterate-text

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: ''
  version: 1.0.0
paths:
  /transliterate:
    post:
      operationId: transliterate
      summary: Transliterate Text
      description: >-
        **Transliteration** converts text from one script to another while
        preserving the original pronunciation. For example, **'नमस्ते'** becomes
        **'namaste'** in English, and **'how are you'** can be written as **'हाउ
        आर यू'** in Devanagari. This process ensures that the sound of the
        original text remains intact, even when written in a different script.


        Transliteration is useful when you want to represent words phonetically
        across different writing systems, such as converting **'मैं ऑफिस जा रहा
        हूँ'** to **'main office ja raha hun'** in English letters.


        **Translation**, on the other hand, converts text from one language to
        another while preserving the meaning rather than pronunciation. For
        example, **'मैं ऑफिस जा रहा हूँ'** translates to **'I am going to the
        office'** in English, changing both the script and the language while
        conveying the intended message.

        ### Examples of **Transliteration**:

        - **'Good morning'** becomes **'गुड मॉर्निंग'** in Hindi, where the
        pronunciation is preserved but the meaning is not translated.

        - **'सुप्रभात'** becomes **'suprabhat'** in English.


        Available languages:

        - **`en-IN`**: English

        - **`hi-IN`**: Hindi

        - **`bn-IN`**: Bengali

        - **`gu-IN`**: Gujarati

        - **`kn-IN`**: Kannada

        - **`ml-IN`**: Malayalam

        - **`mr-IN`**: Marathi

        - **`od-IN`**: Odia

        - **`pa-IN`**: Punjabi

        - **`ta-IN`**: Tamil

        - **`te-IN`**: Telugu


        For hands-on practice, you can explore the notebook tutorial on
        [Transliterate API
        Tutorial](https://github.com/sarvamai/sarvam-ai-cookbook/blob/main/notebooks/transliterate/Transliterate_API_Tutorial.ipynb).
      tags:
        - subpackage_text
      parameters:
        - name: api-subscription-key
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sarvam_Model_API_TransliterationResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sarvam_Model_API_ErrorMessage'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sarvam_Model_API_ErrorMessage'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sarvam_Model_API_ErrorMessage'
        '429':
          description: Quota Exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sarvam_Model_API_ErrorMessage'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Sarvam_Model_API_ErrorMessage'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Sarvam_Model_API_TransliterationRequest'
servers:
  - url: https://api.sarvam.ai
    description: Production
components:
  schemas:
    Sarvam_Model_API_TransliterateSourceLanguage:
      type: string
      enum:
        - auto
        - bn-IN
        - en-IN
        - gu-IN
        - hi-IN
        - kn-IN
        - ml-IN
        - mr-IN
        - od-IN
        - pa-IN
        - ta-IN
        - te-IN
      title: Sarvam_Model_API_TransliterateSourceLanguage
    Sarvam_Model_API_TranslatiterateTargetLanguage:
      type: string
      enum:
        - bn-IN
        - en-IN
        - gu-IN
        - hi-IN
        - kn-IN
        - ml-IN
        - mr-IN
        - od-IN
        - pa-IN
        - ta-IN
        - te-IN
      title: Sarvam_Model_API_TranslatiterateTargetLanguage
    Sarvam_Model_API_NumeralsFormat:
      type: string
      enum:
        - international
        - native
      title: Sarvam_Model_API_NumeralsFormat
    Sarvam_Model_API_SpokenFormNumeralsFormat:
      type: string
      enum:
        - english
        - native
      title: Sarvam_Model_API_SpokenFormNumeralsFormat
    Sarvam_Model_API_TransliterationRequest:
      type: object
      properties:
        input:
          type: string
          description: The text you want to transliterate.
        source_language_code:
          $ref: '#/components/schemas/Sarvam_Model_API_TransliterateSourceLanguage'
          description: >+
            The language code of the input text. This specifies the source
            language for transliteration.



             Note:  The source language should either be an Indic language or English. As we supports both Indic-to-English and English-to-Indic transliteration.

        target_language_code:
          $ref: '#/components/schemas/Sarvam_Model_API_TranslatiterateTargetLanguage'
          description: >+
            The language code of the transliteration text. This specifies the
            target language for transliteration.



             Note:The target language should either be an Indic language or English. As we supports both Indic-to-English and English-to-Indic transliteration.

        numerals_format:
          $ref: '#/components/schemas/Sarvam_Model_API_NumeralsFormat'
          description: >-
            `numerals_format` is an optional parameter with two options:


            - **`international`** (default): Uses regular numerals (0-9).

            - **`native`**: Uses language-specific native numerals.


            ### Example:

            - If `international` format is selected, we use regular numerals
            (0-9). For example: `मेरा phone number है: 9840950950`.

            - If `native` format is selected, we use language-specific native
            numerals, like: `मेरा phone number है: ९८४०९५०९५०`.
        spoken_form_numerals_language:
          $ref: '#/components/schemas/Sarvam_Model_API_SpokenFormNumeralsFormat'
          description: >+
            `spoken_form_numerals_language` is an optional parameter with two
            options and only works when spoken_form is true:


            - **`english`** : Numbers in the text will be spoken in English.

            - **`native(default)`**: Numbers in the text will be spoken in the
            native language.


            ### Examples:

            - **Input:** "मेरे पास ₹200 है"
              - If `english` format is selected: "मेरे पास टू हन्डर्ड रूपीस है"
              - If `native` format is selected: "मेरे पास दो सौ रुपये है"

        spoken_form:
          type: boolean
          default: false
          description: |2
              - Default: `False`
              - Converts text into a natural spoken form when `True`.
              - **Note:** No effect if output language is `en-IN`.

            ### Example:
            - **Input:** `मुझे कल 9:30am को appointment है`
              - **Output:** `मुझे कल सुबह साढ़े नौ बजे को अपॉइंटमेंट है`
      required:
        - input
        - source_language_code
        - target_language_code
      title: Sarvam_Model_API_TransliterationRequest
    Sarvam_Model_API_TransliterationResponse:
      type: object
      properties:
        request_id:
          type:
            - string
            - 'null'
        transliterated_text:
          type: string
          description: Transliterated text result in the requested target language.
        source_language_code:
          type: string
          description: Detected or provided source language of the input text.
      required:
        - request_id
        - transliterated_text
        - source_language_code
      title: Sarvam_Model_API_TransliterationResponse
    Sarvam_Model_API_ErrorCode:
      type: string
      enum:
        - invalid_request_error
        - internal_server_error
        - unprocessable_entity_error
        - insufficient_quota_error
        - invalid_api_key_error
        - authentication_error
        - not_found_error
        - rate_limit_exceeded_error
      title: Sarvam_Model_API_ErrorCode
    Sarvam_Model_API_ErrorDetails:
      type: object
      properties:
        request_id:
          type:
            - string
            - 'null'
        message:
          type: string
          description: Message describing the error
        code:
          $ref: '#/components/schemas/Sarvam_Model_API_ErrorCode'
          description: >-
            Error code for the specific error that has occurred. Refer to the
            error code documentation for more details.
      required:
        - request_id
        - message
        - code
      title: Sarvam_Model_API_ErrorDetails
    Sarvam_Model_API_ErrorMessage:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Sarvam_Model_API_ErrorDetails'
          description: Error details
      required:
        - error
      title: Sarvam_Model_API_ErrorMessage
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-subscription-key

```

## Examples



**Request**

```json
{
  "input": "मैं ऑफिस जा रहा हूँ",
  "source_language_code": "hi-IN",
  "target_language_code": "en-IN"
}
```

**Response**

```json
{
  "request_id": "a1b2c3d4-e5f6-7890-ab12-cd34ef567890",
  "transliterated_text": "main office ja raha hun",
  "source_language_code": "hi-IN"
}
```

**SDK Code**

```typescript
import { SarvamAIClient } from "sarvamai";

async function main() {
    const client = new SarvamAIClient({
        apiSubscriptionKey: "YOUR_API_KEY_HERE",
    });
    await client.text.transliterate({
        input: "मैं ऑफिस जा रहा हूँ",
        source_language_code: "hi-IN",
        target_language_code: "en-IN",
    });
}
main();

```

```python
from sarvamai import SarvamAI

client = SarvamAI(
    api_subscription_key="YOUR_API_KEY_HERE",
)

client.text.transliterate(
    input="मैं ऑफिस जा रहा हूँ",
    source_language_code="hi-IN",
    target_language_code="en-IN",
)

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sarvam.ai/transliterate"

	payload := strings.NewReader("{\n  \"input\": \"मैं ऑफिस जा रहा हूँ\",\n  \"source_language_code\": \"hi-IN\",\n  \"target_language_code\": \"en-IN\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api-subscription-key", "<apiSubscriptionKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.sarvam.ai/transliterate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-subscription-key"] = '<apiSubscriptionKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"मैं ऑफिस जा रहा हूँ\",\n  \"source_language_code\": \"hi-IN\",\n  \"target_language_code\": \"en-IN\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.sarvam.ai/transliterate")
  .header("api-subscription-key", "<apiSubscriptionKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"मैं ऑफिस जा रहा हूँ\",\n  \"source_language_code\": \"hi-IN\",\n  \"target_language_code\": \"en-IN\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sarvam.ai/transliterate', [
  'body' => '{
  "input": "मैं ऑफिस जा रहा हूँ",
  "source_language_code": "hi-IN",
  "target_language_code": "en-IN"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'api-subscription-key' => '<apiSubscriptionKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.sarvam.ai/transliterate");
var request = new RestRequest(Method.POST);
request.AddHeader("api-subscription-key", "<apiSubscriptionKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"मैं ऑफिस जा रहा हूँ\",\n  \"source_language_code\": \"hi-IN\",\n  \"target_language_code\": \"en-IN\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "api-subscription-key": "<apiSubscriptionKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "input": "मैं ऑफिस जा रहा हूँ",
  "source_language_code": "hi-IN",
  "target_language_code": "en-IN"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sarvam.ai/transliterate")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```