> ## 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.

# Create Speech



## OpenAPI

````yaml post /audio/speech
openapi: 3.0.0
info:
  title: Obiguard API
  description: >-
    The Obiguard REST API. Please see
    https://docs.obiguard.ai/docs/api-reference for more details.
  version: 1.0.0
  termsOfService: https://obiguard.ai/terms
servers:
  - url: https://gateway.obiguard.ai/v1
security: []
tags:
  - name: Audio
    description: Turn audio into text or text into audio.
  - name: Chat
    description: >-
      Given a list of messages comprising a conversation, the model will return
      a response.
  - name: Completions
    description: >-
      Given a prompt, the model will return one or more predicted completions,
      and can also return the probabilities of alternative tokens at each
      position.
  - name: Embeddings
    description: >-
      Get a vector representation of a given input that can be easily consumed
      by machine learning models and algorithms.
  - name: Fine-tuning
    description: Manage fine-tuning jobs to tailor a model to your specific training data.
  - name: Files
    description: >-
      Files are used to upload documents that can be used with features like
      Assistants and Fine-tuning.
  - name: Images
    description: Given a prompt and/or an input image, the model will generate a new image.
paths:
  /audio/speech:
    post:
      tags:
        - Audio
      summary: Create Speech
      operationId: createSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSpeechRequest'
      responses:
        '200':
          description: OK
          headers:
            Transfer-Encoding:
              schema:
                type: string
              description: chunked
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
      security:
        - Obiguard-API-Key: []
      servers:
        - url: https://gateway.obiguard.ai/v1
      x-code-samples:
        - lang: curl
          label: Default
          source: |
            curl https://gateway.obiguard.ai/v1/audio/speech \
              -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "model": "tts-1",
                "input": "The quick brown fox jumped over the lazy dog.",
                "voice": "alloy"
              }' \
              --output speech.mp3
        - lang: python
          label: Default
          source: |
            from pathlib import Path
            from obiguard import Obiguard

            client = Obiguard(
              obiguard_api_key="vk-obg***",  # Your Obiguard virtual key
              
            )

            speech_file_path = Path(__file__).parent / "speech.mp3"
            response = client.audio.speech.create(
              model="tts-1",
              voice="alloy",
              input="The quick brown fox jumped over the lazy dog."
            )
            response.stream_to_file(speech_file_path)
components:
  schemas:
    CreateSpeechRequest:
      type: object
      additionalProperties: false
      properties:
        model:
          description: >
            One of the available [TTS
            models](https://platform.openai.com/docs/models/tts): `tts-1` or
            `tts-1-hd`
          anyOf:
            - type: string
            - type: string
              enum:
                - tts-1
                - tts-1-hd
          x-oaiTypeLabel: string
        input:
          type: string
          description: >-
            The text to generate audio for. The maximum length is 4096
            characters.
          maxLength: 4096
        voice:
          description: >-
            The voice to use when generating the audio. Supported voices are
            `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of
            the voices are available in the [Text to speech
            guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).
          type: string
          enum:
            - alloy
            - echo
            - fable
            - onyx
            - nova
            - shimmer
        response_format:
          description: >-
            The format to audio in. Supported formats are `mp3`, `opus`, `aac`,
            `flac`, `wav`, and `pcm`.
          default: mp3
          type: string
          enum:
            - mp3
            - opus
            - aac
            - flac
            - wav
            - pcm
        speed:
          description: >-
            The speed of the generated audio. Select a value from `0.25` to
            `4.0`. `1.0` is the default.
          type: number
          default: 1
          minimum: 0.25
          maximum: 4
      required:
        - model
        - input
        - voice
  securitySchemes:
    Obiguard-API-Key:
      type: apiKey
      in: header
      name: x-obiguard-api-key

````