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

# Fetch Sound and Music Run Results (Bulk)

> Retrieve multiple generated audio files for completed Sound and Music tasks using multiple run IDs.

This endpoint retrieves audio outputs generated from multiple previously completed Sound and Music tasks in a single request. It allows you to efficiently fetch results for several text-to-sound generation runs simultaneously, making it ideal for batch processing workflows and applications that need to handle multiple audio files at once.

Unlike the single result endpoint that takes a run ID as a URL parameter, this bulk endpoint accepts multiple run IDs in the request body, providing a more efficient way to retrieve results when working with multiple text-to-sound tasks.

## How It Works

The endpoint processes an array of run IDs and returns corresponding results for each completed task. This batch approach offers several advantages over making individual requests for each result:

**Efficiency Benefits:**

* Reduces the number of HTTP requests needed
* Minimizes network overhead when fetching multiple results
* Simplifies client-side code for handling multiple audio files
* Provides better performance for applications processing many audio generations

**Practical Applications:**

* Batch processing of multiple text-to-sound requests
* Building audio libraries from multiple text prompts
* Creating soundtracks or audio collections
* Processing results from parallel text-to-sound tasks

## Request Format

The endpoint expects a JSON payload containing an array of run IDs that you want to retrieve results for:

```json theme={null}
// Note: Replace with your actual Run IDs
{
  "run_ids": [
    "12345",
    "678910",
    "112233"
  ]
}
```

Each run ID should correspond to a previously initiated and completed text-to-sound task. The endpoint will process all provided run IDs and return results for those that have completed successfully.

## Response Structure

The response contains an array of results, where each item corresponds to one of the requested run IDs. Each result includes a presigned URL that points directly to the generated audio file:

```json theme={null}
[
    12345: {
      "output_url": "https://storage.example.com/audio/12345.wav"
    },
    678910: {
      "output_url": "https://storage.example.com/audio/678910.wav"
    },
    112233: {
      "output_url": "https://storage.example.com/audio/112233.wav"
    }
]

```

## Example Usage

### Basic Bulk Request

```bash theme={null}
curl -X POST "https://client.camb.ai/apis/text-to-sound-results" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "run_ids": [
    "12345",
    "678910",
    "112233"
  ]
  }'
```

### Processing the Response

```javascript theme={null}
// Example JavaScript code for handling the bulk response
const response = await fetch('/text-to-sound-results', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    run_ids: [
      "12345",
      "678910",
      "112233"
    ]
  })
});

const data = await response.json();

// Process each result
data.results.forEach(result => {
    console.log(`Audio ready for ${result}: ${result.output_url}`);
    // Download or process the audio file
});
```

## Workflow Integration

This bulk endpoint fits naturally into larger audio processing workflows. Consider this typical pattern:

1. **Initiate Multiple Tasks**: Submit several text-to-sound requests using the creation endpoint
2. **Store Run IDs**: Keep track of all returned run IDs from your requests
3. **Process Completed Results**: Download and handle audio files for completed tasks
4. **Retry or Handle Failures**: Manage any failed tasks or retry processing tasks

## Technical Considerations

**File Format and Quality:**
The generated audio files are delivered in WAV format, providing high audio quality suitable for professional applications. Keep in mind that WAV files are larger than compressed formats but offer the best fidelity for your generated sound effects.

**URL Expiration:**
The presigned URLs returned in the response are temporary and will expire after a certain period. Make sure to download and store important audio files promptly to avoid losing access to your generated content.

**Rate Limiting:**
While this endpoint allows bulk retrieval, be mindful of the fact that this endpoint allows providing a maximum of 5 run IDs per request. The bulk approach is more efficient than individual requests, but extremely large batches should be broken down into manageable chunks.

**Memory and Storage:**
When downloading multiple audio files, consider the memory and storage requirements on your system. Implement appropriate streaming or chunked download strategies for large batches to avoid overwhelming your application's resources.

By leveraging this bulk results endpoint, you can build more efficient applications that handle multiple text-to-sound generations seamlessly, enabling creative workflows that scale with your audio production needs.


## OpenAPI

````yaml post /text-to-sound-results
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://client.camb.ai/apis
security: []
paths:
  /text-to-sound-results:
    post:
      tags:
        - APIs
        - Text-to-Sound
      summary: Get Sound and Music Results
      operationId: get_text_to_sound_results_text_to_sound_results_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunIDsRequestPayload'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkTextToSoundRunsResults'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    RunIDsRequestPayload:
      properties:
        run_ids:
          items:
            type: integer
            exclusiveMinimum: 0
          type: array
          maxItems: 5
          minItems: 2
          uniqueItems: true
          title: Run IDs
          description: >-
            An array of unique positive integers, each representing the ID of a
            specific run. You must provide between 2 and 5 IDs, and all IDs must
            correspond to the same run type (e.g., all text-to-speech or all
            dubbing runs).
          example:
            - 12345
            - 6789
      type: object
      required:
        - run_ids
      title: RunIDsRequestPayload
    BulkTextToSoundRunsResults:
      type: object
      title: BulkTextToSoundRunsResults
      additionalProperties:
        $ref: '#/components/schemas/AudioOutputFileURLResponse'
      minProperties: 1
      maxProperties: 5
      description: >-
        An object containing the results of one to five text-to-sound runs. Each
        key in the object is a unique identifier for a run, and the
        corresponding value is the output for text-to-sound.
      example:
        '1234':
          output_url: https://audio-storage.camb.ai/files/audio_1234.flac
        '5678':
          output_url: https://audio-storage.camb.ai/files/audio_5678.flac
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AudioOutputFileURLResponse:
      type: object
      properties:
        output_url:
          title: Output URL
          type: string
          description: A presigned URL that points to the output audio file.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        The `x-api-key` is a custom header required for authenticating requests
        to our API. Include this header in your request with the appropriate API
        key value to securely access our endpoints. You can find your API key(s)
        in the 'API' section of our studio website.

````