Bodhi Docs
Bodhi Docs
  • Bodhi Overview
  • Developer Quickstart
    • Streaming - Websocket
    • Non-Streaming API
    • Error and Response
  • Starter Apps
Powered by GitBook
On this page
  1. Developer Quickstart

Non-Streaming API

PreviousStreaming - WebsocketNextError and Response

Last updated 6 days ago

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.

To integrate with Bodhi’s non-streaming API, follow this process:

  • Authentication

    Authenticate using x-api-key and x-customer-id headers in your request. Here’s how to set up:

If you don’t have your API key and Customer ID, please sign up on Bodhi by following the instructions .

🔧 Sample Script for Bodhi Non-Streaming API

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"'
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)
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();
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))
}

For a deeper understanding of the error and response structure, please check . It provides detailed insights into the API's error handling and response format, breaking down each field for better interpretation of the data returned by the Bodhi API.

this section
here