# Non-Streaming API

This section describes how to use the Bodhi API for non-streaming audio transcription via HTTP requests. Unlike streaming, this method handles the entire audio file as one request, ideal for batch processing or scenarios where real-time transcription is not needed.

***

### :books: Requirements

* Customer ID
* Api Key

Both can be found by creating an account [here](https://bodhi.navana.ai/)

***

### 🔧 Sample Script for Bodhi Non-Streaming API

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://bodhi.navana.ai/api/transcribe' \
--header 'x-customer-id: <BODHI_CUSTOMER_ID>' \
--header 'x-api-key: <BODHI_API_KEY>' \
--form 'transaction_id="decaffb5-3643-4be1-bba5-172810f3d04d"' \
--form 'audio_file=@"/path/to/file"' \
--form 'model="hi-banking-v2-8khz"' \
--form 'parse_number="true"'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://bodhi.navana.ai/api/transcribe"

payload = {'transaction_id': 'decaffb5-3643-4be1-bba5-172810f3d04d',
'model': 'hi-banking-v2-8khz',
'parse_number': 'true'
}
files=[
  ('audio_file',('file',open('/path/to/file','rb'),'application/octet-stream'))
]
headers = {
  'x-customer-id': '<BODHI_CUSTOMER_ID>',
  'x-api-key': '<BODHI_API_KEY>'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

{% endtab %}

{% tab title="Node" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('transaction_id', 'decaffb5-3643-4be1-bba5-172810f3d04d');
data.append('audio_file', fs.createReadStream('/path/to/file'));
data.append('model', 'hi-banking-v2-8khz');
data.append('parse_number', 'true');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://bodhi.navana.ai/api/transcribe',
  headers: { 
    'x-customer-id': '<BODHI_CUSTOMER_ID>', 
    'x-api-key': '<BODHI_API_KEY>', 
    ...data.getHeaders()
  },
  data : data
};

async function makeRequest() {
  try {
    const response = await axios.request(config);
    console.log(JSON.stringify(response.data));
  }
  catch (error) {
    console.log(error);
  }
}

makeRequest();

```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "bytes"
  "mime/multipart"
  "os"
  "path/filepath"
  "net/http"
  "io"
)

func main() {

  url := "https://bodhi.navana.ai/api/transcribe"
  method := "POST"

  payload := &bytes.Buffer{}
  writer := multipart.NewWriter(payload)
  _ = writer.WriteField("transaction_id", "decaffb5-3643-4be1-bba5-172810f3d04d")
  file, errFile2 := os.Open("/path/to/file")
  defer file.Close()
  part2,
         errFile2 := writer.CreateFormFile("audio_file",filepath.Base("/path/to/file"))
  _, errFile2 = io.Copy(part2, file)
  if errFile2 != nil {
    fmt.Println(errFile2)
    return
  }
  _ = writer.WriteField("model", "hi-banking-v2-8khz")
  _ = writer.WriteField("parse_number", "true")
  err := writer.Close()
  if err != nil {
    fmt.Println(err)
    return
  }


  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-customer-id", "<BODHI_CUSTOMER_ID>")
  req.Header.Add("x-api-key", "<BODHI_API_KEY>")

  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}

For a deeper understanding of the error and response structure, please check [this section](/bodhi/quickstart/non-streaming-api/response-structure.md). It provides detailed insights into the API's  response format, breaking down each field for better interpretation of the data returned by the Bodhi API.

For error responses see [here](/bodhi/quickstart/non-streaming-api/error-responses.md) and for strategies to improve transcription accuracy, numerical recognition and more see [here](/bodhi/quickstart/non-streaming-api/advanced-features.md).&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://navana.gitbook.io/bodhi/quickstart/non-streaming-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
