Skip to content

API reference

Audio

Speech generation, transcription, and translation are separate operations. Match input media and output format to the selected model.

How it fits together

  1. 01Synthesize speech and return the audio bytes
  2. 02Transcribe an uploaded recording
  3. 03Translate an uploaded recording into English

Select an action to see its complete inputs, request, response, and status codes.

Synthesize speech and return the audio bytes

POST/v1/audio/speech
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typeapplication/json

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
inputBodystringRequiredSupportedText to synthesize, bounded by service configuration.
instructionsBodystringOptionalConditionalDelivery instructions, up to 4,096 characters.
modelBodystringRequiredSupportedPublic logical speech model ID.
response_formatBodystringOptionalSupportedmp3, opus, aac, flac, wav, or pcm.
speedBodynumberOptionalConditionalPlayback rate, 0.25 to 4.0.
userBodystringOptionalSupportedProvider abuse-monitoring user identifier.
voiceBodystringRequiredSupportedProvider voice identifier.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/audio/speech' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <unique-request-id>" \
  -d '{
  "input": "probe",
  "model": "tts-1",
  "voice": "alloy"
}'

Response

This endpoint returns no JSON body or delivers binary content.

Status codes

HTTPDetails
200Synthesize speech and return the audio bytes.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.

Transcribe an uploaded recording

POST/v1/audio/transcriptions
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typemultipart/form-data

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
fileFormstring (binary)RequiredSupportedThe recording to process.
languageFormstringOptionalSupportedISO language hint, up to 16 characters.
modelFormstringRequiredSupportedPublic logical audio model ID.
promptFormstringOptionalConditionalTranscription hint, up to 4,096 characters.
response_formatFormstringOptionalSupportedjson, text, srt, verbose_json, or vtt.
temperatureFormnumberOptionalSupportedSampling temperature, 0 to 1.
timestamp_granularitiesFormarray<value>OptionalConditionalword and/or segment; requires response_format=verbose_json.
userFormstringOptionalSupportedProvider abuse-monitoring user identifier.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/audio/transcriptions' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Idempotency-Key: <unique-request-id>" \
  -F 'file=@./your-file' \
  -F 'model=whisper-1'

Response

{
  "text": "<value>"
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Transcribe an uploaded recording.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.

Translate an uploaded recording into English

POST/v1/audio/translations
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typemultipart/form-data

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
fileFormstring (binary)RequiredSupportedThe recording to process.
modelFormstringRequiredSupportedPublic logical audio model ID.
promptFormstringOptionalConditionalTranscription hint, up to 4,096 characters.
response_formatFormstringOptionalSupportedjson, text, srt, verbose_json, or vtt.
temperatureFormnumberOptionalSupportedSampling temperature, 0 to 1.
userFormstringOptionalSupportedProvider abuse-monitoring user identifier.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/audio/translations' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Idempotency-Key: <unique-request-id>" \
  -F 'file=@./your-file' \
  -F 'model=whisper-1'

Response

A representative JSON response is not available for this endpoint. Handle the documented HTTP status and inspect the returned body according to your client workflow.

Status codes

HTTPDetails
200Translate an uploaded recording into English.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.