This tutorial will demonstrate how to use AssemblyAI’s LLM Gateway framework to receive AI coaching. LLM Gateway provides access to multiple LLM providers through a unified API.Documentation Index
Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Quickstart
- Python
- JavaScript
import requests
import time
base_url = "https://api.assemblyai.com"
headers = {"authorization": "<YOUR_API_KEY>"}
# Use a publicly-accessible URL:
audio_url = "https://storage.googleapis.com/aai-web-samples/meeting.mp4"
# with open("/your_audio_file.mp3", "rb") as f:
# response = requests.post(base_url + "/v2/upload", headers=headers, data=f)
# if response.status_code != 200:
# print(f"Error: {response.status_code}, Response: {response.text}")
# response.raise_for_status()
# upload_json = response.json()
# audio_url = upload_json["upload_url"]
data = {
"audio_url": audio_url,
"speech_models": ["universal-3-pro"],
}
response = requests.post(base_url + "/v2/transcript", headers=headers, json=data)
if response.status_code != 200:
print(f"Error: {response.status_code}, Response: {response.text}")
transcript_json = response.json()
transcript_id = transcript_json["id"]
polling_endpoint = f"{base_url}/v2/transcript/{transcript_id}"
while True:
transcript = requests.get(polling_endpoint, headers=headers).json()
if transcript["status"] == "completed":
print(transcript['id'])
print(f" \nFull Transcript: \n\n{transcript['text']}\n")
break
elif transcript["status"] == "error":
raise RuntimeError(f"Transcription failed: {transcript['error']}")
else:
time.sleep(3)
prompt = f"""
- You are an expert at providing valuable feedback to individuals.
- You possess exceptionally high emotional intelligence.
- You excel at analyzing the behavior of individuals in the given transcript and providing insights on how they could improve.
- You emphasize constructive criticism in your feedback.
- The feedback focuses on how people can better achieve their objectives.
- You avoid providing unjustified or unfounded feedback.
- Your communication is clear, accurate and concise, and you write with perfect English.
- Directly start with the feedback without any preamble or introduction.
"""
llm_gateway_data = {
"model": "claude-sonnet-4-5-20250929",
"messages": [
{
"role": "user",
"content": f"{prompt} Please provide feedback for this transcript: \n\n{{{{ transcript }}}}"
}
],
"transcript_id": transcript_id,
"max_tokens": 1500
}
response = requests.post(
"https://llm-gateway.assemblyai.com/v1/chat/completions",
headers=headers,
json=llm_gateway_data
)
result = response.json()
if "error" in result:
print(f"\nError from LLM Gateway: {result['error']}")
else:
response_text = result['choices'][0]['message']['content']
print(f"\nResponse ID: {result['request_id']}\n")
print(response_text)
const baseUrl = "https://api.assemblyai.com";
const headers = { authorization: "<YOUR_API_KEY>" };
// Use a publicly-accessible URL:
const audioUrl = "https://storage.googleapis.com/aai-web-samples/meeting.mp4";
// Or upload a local file:
// import fs from "fs-extra";
// const audioData = await fs.readFile("./your_audio_file.mp3");
// const uploadRes = await fetch(`${baseUrl}/v2/upload`, {
// method: "POST",
// headers,
// body: audioData,
// });
// if (!uploadRes.ok) throw new Error(`Error: ${uploadRes.status}`);
// const uploadResponse = await uploadRes.json();
// const audioUrl = uploadResponse.upload_url;
const data = {
audio_url: audioUrl,
speech_models: ["universal-3-pro"],
};
let res = await fetch(`${baseUrl}/v2/transcript`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify(data),
});
if (!res.ok) throw new Error(`Error: ${res.status}`);
const transcriptResponse = await res.json();
const transcriptId = transcriptResponse.id;
const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`;
let transcript;
while (true) {
res = await fetch(pollingEndpoint, { headers });
if (!res.ok) throw new Error(`Error: ${res.status}`);
transcript = await res.json();
if (transcript.status === "completed") {
console.log(transcript.id);
console.log(`\nFull Transcript:\n\n${transcript.text}\n`);
break;
} else if (transcript.status === "error") {
throw new Error(`Transcription failed: ${transcript.error}`);
} else {
await new Promise((resolve) => setTimeout(resolve, 3000));
}
}
const prompt = `
- You are an expert at providing valuable feedback to individuals.
- You possess exceptionally high emotional intelligence.
- You excel at analyzing the behavior of individuals in the given transcript and providing insights on how they could improve.
- You emphasize constructive criticism in your feedback.
- The feedback focuses on how people can better achieve their objectives.
- You avoid providing unjustified or unfounded feedback.
- Your communication is clear, accurate and concise, and you write with perfect English.
- Directly start with the feedback without any preamble or introduction.
`;
const llmGatewayData = {
model: "claude-sonnet-4-5-20250929",
messages: [
{
role: "user",
content: `${prompt} Please provide feedback for this transcript: \n\n{{ transcript }}`,
},
],
transcript_id: transcriptId,
max_tokens: 1500,
};
res = await fetch("https://llm-gateway.assemblyai.com/v1/chat/completions", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify(llmGatewayData),
});
if (!res.ok) throw new Error(`Error: ${res.status}`);
const result = await res.json();
if (result.error) {
console.log(`\nError from LLM Gateway: ${result.error}`);
} else {
const responseText = result.choices[0].message.content;
console.log(`\nResponse ID: ${result.request_id}\n`);
console.log(responseText);
}
Getting Started
Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for an AssemblyAI account and get your API key from your dashboard. Find more details on the current LLM Gateway pricing on the AssemblyAI pricing page.Step-by-Step Instructions
In this guide, we’ll prompt LLM Gateway to perform some AI coaching. Install the required packages:- Python
pip install requests
- Python
- JavaScript
import requests
import time
base_url = "https://api.assemblyai.com"
headers = {"authorization": "<YOUR_API_KEY>"}
const baseUrl = "https://api.assemblyai.com";
const headers = { authorization: "<YOUR_API_KEY>" };
- Python
- JavaScript
audio_url = "https://storage.googleapis.com/aai-web-samples/meeting.mp4"
# with open("/your_audio_file.mp3", "rb") as f:
# response = requests.post(base_url + "/v2/upload", headers=headers, data=f)
# if response.status_code != 200:
# print(f"Error: {response.status_code}, Response: {response.text}")
# response.raise_for_status()
# upload_json = response.json()
# audio_url = upload_json["upload_url"]
data = {
"audio_url": audio_url,
"speech_models": ["universal-3-pro"],
}
response = requests.post(base_url + "/v2/transcript", headers=headers, json=data)
if response.status_code != 200:
print(f"Error: {response.status_code}, Response: {response.text}")
transcript_json = response.json()
transcript_id = transcript_json["id"]
polling_endpoint = f"{base_url}/v2/transcript/{transcript_id}"
while True:
transcript = requests.get(polling_endpoint, headers=headers).json()
if transcript["status"] == "completed":
print(transcript['id'])
print(f" \nFull Transcript: \n\n{transcript['text']}\n")
break
elif transcript["status"] == "error":
raise RuntimeError(f"Transcription failed: {transcript['error']}")
else:
time.sleep(3)
// Use a publicly-accessible URL:
const audioUrl = "https://storage.googleapis.com/aai-web-samples/meeting.mp4";
// Or upload a local file:
// import fs from "fs-extra";
// const audioData = await fs.readFile("./your_audio_file.mp3");
// const uploadRes = await fetch(`${baseUrl}/v2/upload`, {
// method: "POST",
// headers,
// body: audioData,
// });
// if (!uploadRes.ok) throw new Error(`Error: ${uploadRes.status}`);
// const uploadResponse = await uploadRes.json();
// const audioUrl = uploadResponse.upload_url;
const data = {
audio_url: audioUrl,
speech_models: ["universal-3-pro"],
};
let res = await fetch(`${baseUrl}/v2/transcript`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify(data),
});
if (!res.ok) throw new Error(`Error: ${res.status}`);
const transcriptResponse = await res.json();
const transcriptId = transcriptResponse.id;
const pollingEndpoint = `${baseUrl}/v2/transcript/${transcriptId}`;
let transcript;
while (true) {
res = await fetch(pollingEndpoint, { headers });
if (!res.ok) throw new Error(`Error: ${res.status}`);
transcript = await res.json();
if (transcript.status === "completed") {
console.log(transcript.id);
console.log(`\nFull Transcript:\n\n${transcript.text}\n`);
break;
} else if (transcript.status === "error") {
throw new Error(`Transcription failed: ${transcript.error}`);
} else {
await new Promise((resolve) => setTimeout(resolve, 3000));
}
}
- Python
- JavaScript
prompt = f"""
- You are an expert at providing valuable feedback to individuals.
- You possess exceptionally high emotional intelligence.
- You excel at analyzing the behavior of individuals in the given transcript and providing insights on how they could improve.
- You emphasize constructive criticism in your feedback.
- The feedback focuses on how people can better achieve their objectives.
- You avoid providing unjustified or unfounded feedback.
- Your communication is clear, accurate and concise, and you write with perfect English.
- Directly start with the feedback without any preamble or introduction.
"""
const prompt = `
- You are an expert at providing valuable feedback to individuals.
- You possess exceptionally high emotional intelligence.
- You excel at analyzing the behavior of individuals in the given transcript and providing insights on how they could improve.
- You emphasize constructive criticism in your feedback.
- The feedback focuses on how people can better achieve their objectives.
- You avoid providing unjustified or unfounded feedback.
- Your communication is clear, accurate and concise, and you write with perfect English.
- Directly start with the feedback without any preamble or introduction.
`;
- Python
- JavaScript
llm_gateway_data = {
"model": "claude-sonnet-4-5-20250929",
"messages": [
{
"role": "user",
"content": f"{prompt} Please provide feedback for this transcript: \n\n{{{{ transcript }}}}"
}
],
"transcript_id": transcript_id,
"max_tokens": 1500,
"temperature": 0
}
response = requests.post(
"https://llm-gateway.assemblyai.com/v1/chat/completions",
headers=headers,
json=llm_gateway_data
)
const llmGatewayData = {
model: "claude-sonnet-4-5-20250929",
messages: [
{
role: "user",
content: `${prompt} Please provide feedback for this transcript: \n\n{{ transcript }}`,
},
],
transcript_id: transcriptId,
max_tokens: 1500,
temperature: 0,
};
const res = await fetch("https://llm-gateway.assemblyai.com/v1/chat/completions", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify(llmGatewayData),
});
if (!res.ok) throw new Error(`Error: ${res.status}`);
const response = await res.json();
- Python
- JavaScript
result = response.json()
if "error" in result:
print(f"\nError from LLM Gateway: {result['error']}")
else:
response_text = result['choices'][0]['message']['content']
print(f"\nResponse ID: {result['request_id']}\n")
print(response_text)
if (response.error) {
console.log(`\nError from LLM Gateway: ${response.error}`);
} else {
const responseText = response.choices[0].message.content;
console.log(`\nResponse ID: ${response.request_id}\n`);
console.log(responseText);
}