# Audio
(*audio*)

## Overview

### Available Operations

* [createTranscription](#createtranscription) - Transcribe Audio to Text
* [createTranslation](#createtranslation) - Translate Audio to Text

## createTranscription

Transcribe Audio to Text

### Example Usage

```typescript
import { FireworksAI } from "@simplesagar/fireworksai";
import { openAsBlob } from "node:fs";

const fireworksAI = new FireworksAI({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const result = await fireworksAI.audio.createTranscription({
    file: await openAsBlob("example.file"),
    language: "English",
  });

  // Handle the result
  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { FireworksAICore } from "@simplesagar/fireworksai/core.js";
import { audioCreateTranscription } from "@simplesagar/fireworksai/funcs/audioCreateTranscription.js";
import { openAsBlob } from "node:fs";

// Use `FireworksAICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fireworksAI = new FireworksAICore({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const res = await audioCreateTranscription(fireworksAI, {
    file: await openAsBlob("example.file"),
    language: "English",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [models.BodyTranscriptionsV1AudioTranscriptionsPost](../../models/bodytranscriptionsv1audiotranscriptionspost.md)                                                              | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[models.TranscriptionResponse](../../models/transcriptionresponse.md)\>**

### Errors

| Error Type                 | Status Code                | Content Type               |
| -------------------------- | -------------------------- | -------------------------- |
| models.BadRequest          | 400                        | application/json           |
| models.Unauthorized        | 401                        | application/json           |
| models.Forbidden           | 403                        | application/json           |
| models.NotFound            | 404                        | application/json           |
| models.HTTPValidationError | 422                        | application/json           |
| models.TooManyRequests     | 429                        | application/json           |
| models.InternalServerError | 500                        | application/json           |
| models.ServiceUnavailable  | 503                        | application/json           |
| models.SDKError            | 4XX, 5XX                   | \*/\*                      |

## createTranslation

Translate Audio to Text

### Example Usage

```typescript
import { FireworksAI } from "@simplesagar/fireworksai";
import { openAsBlob } from "node:fs";

const fireworksAI = new FireworksAI({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const result = await fireworksAI.audio.createTranslation({
    file: await openAsBlob("example.file"),
  });

  // Handle the result
  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { FireworksAICore } from "@simplesagar/fireworksai/core.js";
import { audioCreateTranslation } from "@simplesagar/fireworksai/funcs/audioCreateTranslation.js";
import { openAsBlob } from "node:fs";

// Use `FireworksAICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fireworksAI = new FireworksAICore({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const res = await audioCreateTranslation(fireworksAI, {
    file: await openAsBlob("example.file"),
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [models.BodyTranslationsV1AudioTranslationsPost](../../models/bodytranslationsv1audiotranslationspost.md)                                                                      | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[models.TranslationsV1AudioTranslationsPostResponseTranslationsV1AudioTranslationsPost](../../models/translationsv1audiotranslationspostresponsetranslationsv1audiotranslationspost.md)\>**

### Errors

| Error Type                 | Status Code                | Content Type               |
| -------------------------- | -------------------------- | -------------------------- |
| models.BadRequest          | 400                        | application/json           |
| models.Unauthorized        | 401                        | application/json           |
| models.Forbidden           | 403                        | application/json           |
| models.NotFound            | 404                        | application/json           |
| models.HTTPValidationError | 422                        | application/json           |
| models.TooManyRequests     | 429                        | application/json           |
| models.InternalServerError | 500                        | application/json           |
| models.ServiceUnavailable  | 503                        | application/json           |
| models.SDKError            | 4XX, 5XX                   | \*/\*                      |