> 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. # Create POST https://api.sarvam.ai/text-to-speech/pronunciation-dictionary Content-Type: multipart/form-data Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**. The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples. The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket). **Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size. Reference: https://docs.sarvam.ai/api-reference/pronunciation-dictionary/create ## Authentication - `api-subscription-key` header (required) — API Key authentication via header ## Request ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `file` (file, required) ## Response ### 200 Successful Response - `dictionary_id` (string, required) — Unique identifier for the created dictionary (e.g. `p_5cb7faa6`). Use this as the `dict_id` parameter in text-to-speech requests. ## Errors ### 400 Bad Request Error Bad Request — Invalid JSON, missing required fields, or bad schema. - `error` (Sarvam_Model_API_ErrorDetails, required) — Error details ### 403 Forbidden Error Forbidden - `error` (Sarvam_Model_API_ErrorDetails, required) — Error details ### 413 Content Too Large Error Payload Too Large — File size exceeds the 1 MB limit. - `error` (Sarvam_Model_API_ErrorDetails, required) — Error details ### 422 Unprocessable Entity Error Unprocessable Entity — Word limit exceeded (>100 words per dictionary) or dictionary limit exceeded (>10 dictionaries per user). - `error` (Sarvam_Model_API_ErrorDetails, required) — Error details ### 429 Too Many Requests Error Quota Exceeded - `error` (Sarvam_Model_API_ErrorDetails, required) — Error details ### 500 Internal Server Error Internal Server Error - `error` (Sarvam_Model_API_ErrorDetails, required) — Error details ## Types ### Sarvam_Model_API_ErrorDetails - `request_id` (string, required, nullable) - `message` (string, required) — Message describing the error - `code` (enum, required) — Error code for the specific error that has occurred. Refer to the error code documentation for more details. - Allowed values: `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`, `model_call_error`, `gateway_timeout_error`, `billing_service_unavailable_error` ## Examples **Request** ```json { "file": "" } ``` **Response** ```json { "dictionary_id": "p_5cb7faa6" } ``` **SDK Code** ```typescript pronunciationDictionary_create_example import { SarvamAIClient } from "sarvamai"; import fs from "fs"; const client = new SarvamAIClient({ apiSubscriptionKey: process.env.SARVAM_API_KEY, }); const response = await client.pronunciationDictionary.create({ file: fs.createReadStream("pronunciations.json"), }); ``` ```swift pronunciationDictionary_create_example import Foundation let url = URL(string: "https://api.sarvam.ai/text-to-speech/pronunciation-dictionary")! let boundary = "Boundary-\(UUID().uuidString)" var request = URLRequest(url: url) request.httpMethod = "POST" request.setValue("YOUR_SARVAM_API_KEY", forHTTPHeaderField: "api-subscription-key") request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type") // Upload the pronunciation JSON as a file (not as a raw string). let fileURL = URL(fileURLWithPath: "pronunciations.json") let fileData = try Data(contentsOf: fileURL) var body = Data() body.append("--\(boundary)\r\n".data(using: .utf8)!) body.append("Content-Disposition: form-data; name=\"file\"; filename=\"pronunciations.json\"\r\n".data(using: .utf8)!) body.append("Content-Type: application/json\r\n\r\n".data(using: .utf8)!) body.append(fileData) body.append("\r\n".data(using: .utf8)!) body.append("--\(boundary)--\r\n".data(using: .utf8)!) request.httpBody = body let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error:", error) return } if let data = data, let json = String(data: data, encoding: .utf8) { print(json) } } task.resume() ``` ```python pronunciationDictionary_create_example import requests url = "https://api.sarvam.ai/text-to-speech/pronunciation-dictionary" files = { "file": "open('string', 'rb')" } headers = {"api-subscription-key": ""} response = requests.post(url, files=files, headers=headers) print(response.json()) ``` ```go pronunciationDictionary_create_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.sarvam.ai/text-to-speech/pronunciation-dictionary" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-subscription-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby pronunciationDictionary_create_example require 'uri' require 'net/http' url = URI("https://api.sarvam.ai/text-to-speech/pronunciation-dictionary") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["api-subscription-key"] = '' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java pronunciationDictionary_create_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.sarvam.ai/text-to-speech/pronunciation-dictionary") .header("api-subscription-key", "") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php pronunciationDictionary_create_example request('POST', 'https://api.sarvam.ai/text-to-speech/pronunciation-dictionary', [ 'multipart' => [ [ 'name' => 'file', 'filename' => 'string', 'contents' => null ] ] 'headers' => [ 'api-subscription-key' => '', ], ]); echo $response->getBody(); ``` ```csharp pronunciationDictionary_create_example using RestSharp; var client = new RestClient("https://api.sarvam.ai/text-to-speech/pronunciation-dictionary"); var request = new RestRequest(Method.POST); request.AddHeader("api-subscription-key", ""); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```