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

# Speech-to-Text

> Obiguard's AI gateway enables speech-to-text using models such as OpenAI Whisper.

## Using Transcription and Translation

Obiguard provides both `Transcription` and `Translation` options for speech-to-text (STT) models,
following the OpenAI API format. You can submit audio files in formats such as `flac`, `mp3`, `mp4`, `mpeg`, `mpga`, `m4a`, `ogg`, `wav`, or `webm` as part of your API request.

Example:

<Tabs>
  <Tab title="Python SDK">
    ```
    from pathlib import Path
    from obiguard import Obiguard

    # Initialize the Obiguard client
    client = Obiguard(
      virtual_key="vk-obg***"   # Your Obiguard virtual key here
    )
    audio_file= open("/path/to/file.mp3", "rb")

    # Transcription
    transcription = client.audio.transcriptions.create(
      model="whisper-1",
      file=audio_file
    )
    print(transcription.text)

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

  <Tab title="OpenAI Python">
    ```
    from openai import OpenAI
    from obiguard import OBIGUARD_GATEWAY_URL, createHeaders

    client = OpenAI(
      api_key="dummy" #We are using Virtual Key from Obiguard
      base_url=OBIGUARD_GATEWAY_URL,
      default_headers=createHeaders(
        api_key="vk-obg***",  # Your Obiguard virtual key here
      )
    )

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

    # Transcription
    transcription = client.audio.transcriptions.create(
      model="whisper-1",
      file=audio_file
    )
    print(transcription.text)

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

  <Tab title="cURL">
    For Transcriptions:

    ```
    curl "https://gateway.obiguard.ai/v1/audio/transcriptions" \
      -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
      -H "x-obiguard-provider: openai" \
      -H "Authorization: Bearer $OPENAI_API_KEY" \
      -H 'Content-Type: multipart/form-data' \
        --form file=@/path/to/file/audio.mp3 \
        --form model=whisper-1
    ```

    For Translations:

    ```
    curl "https://gateway.obiguard.ai/v1/audio/translations" \
    -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
    -H "x-obiguard-provider: openai" \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -H 'Content-Type: multipart/form-data' \
      --form file=@/path/to/file/audio.mp3 \
      --form model=whisper-1
    ```
  </Tab>
</Tabs>

After completion, your request will appear in the logs UI, displaying the transcribed or translated text, as well as the associated cost and latency.

## Supported Providers and Models

Currently, the following providers are supported for speech-to-text.
More providers will be added soon.

| Provider | Model     | Functions                  |
| -------- | --------- | -------------------------- |
| OpenAI   | whisper-1 | Transcription, Translation |
