> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Speech-to-Text

> Use Prisma AIRS AI Gateway's AI gateway to transcribe and translate audio using speech-to-text models across all supported providers.

## Transcription & Translation Usage

The AI Gateway supports both `Transcription` and `Translation` methods for STT models and follows the OpenAI signature where you can send the file (in `flac`, `mp3`, `mp4`, `mpeg`, `mpga`, `m4a`, `ogg`, `wav`, or `webm` formats) as part of the API request.

Here's an example:

<Tabs>
  <Tab title="OpenAI NodeJS">
    ```js theme={"system"}
    import fs from "fs";
    import OpenAI from "openai";

    const openai = new OpenAI({
      apiKey: "PORTKEY_API_KEY", // Replace with your standard API Key or a dummy string
      baseURL: "https://aigw.portkey.ai/v1",
    });

    // Transcription

    async function transcribe() {
      const transcription = await openai.audio.transcriptions.create({
        file: fs.createReadStream("/path/to/file.mp3"),
        model: "@openai/whisper-1",
      });

      console.log(transcription.text);
    }
    transcribe();

    // Translation

    async function translate() {
        const translation = await openai.audio.translations.create({
            file: fs.createReadStream("/path/to/file.mp3"),
            model: "@openai/whisper-1",
        });
        console.log(translation.text);
    }
    translate();
    ```
  </Tab>

  <Tab title="OpenAI Python">
    ```py theme={"system"}
    from openai import OpenAI

    client = OpenAI(
        api_key="PORTKEY_API_KEY", # Replace with your standard API Key or a dummy string
        base_url="https://aigw.portkey.ai/v1",
    )

    audio_file= open("/path/to/file.mp3", "rb")

    # Transcription

    transcription = client.audio.transcriptions.create(
      model="@openai/whisper-1",
      file=audio_file
    )
    print(transcription.text)

    # Translation

    translation = client.audio.translations.create(
      model="@openai/whisper-1",
      file=audio_file
    )
    print(translation.text)
    ```
  </Tab>

  <Tab title="cURL">
    For Transcriptions:

    ```sh theme={"system"}
    curl "https://aigw.portkey.ai/v1/audio/transcriptions" \
      -H "Authorization: Bearer $PORTKEY_API_KEY" \
      -H 'Content-Type: multipart/form-data' \
      --form file=@/path/to/file/audio.mp3 \
      --form model=@openai/whisper-1
    ```

    For Translations:

    ```sh theme={"system"}
    curl "https://aigw.portkey.ai/v1/audio/translations" \
      -H "Authorization: Bearer $PORTKEY_API_KEY" \
      -H 'Content-Type: multipart/form-data' \
      --form file=@/path/to/file/audio.mp3 \
      --form model=@openai/whisper-1
    ```
  </Tab>
</Tabs>

On completion, the request will get logged in the logs UI where you can see transcribed or translated text, along with the cost and latency incurred.


## Related topics

- [Text-to-Speech](/docs/aigw/integrations/llms/vertex-ai/text-to-speech.md)
- [ElevenLabs](/docs/aigw/integrations/llms/elevenlabs.md)
- [Lemonfox-AI](/docs/aigw/integrations/llms/lemon-fox.md)
- [Lepton AI](/docs/aigw/integrations/llms/lepton.md)
