Python
import requests
session = requests.Session()
# Call as soon as you know audio is coming (e.g. recording starts).
session.get(
"https://sync.assemblyai.com/warm",
headers={"X-AAI-Model": "universal-3-5-pro"},
timeout=10,
)
# Same session -> reuses the warmed connection; no handshake here.
with open("sample.wav", "rb") as f:
response = session.post(
"https://sync.assemblyai.com/transcribe",
headers={
"Authorization": "<YOUR_API_KEY>",
"X-AAI-Model": "universal-3-5-pro",
},
files={"audio": ("sample.wav", f, "audio/wav")},
timeout=60,
)
print(response.json()["text"])// Call as soon as you know audio is coming (e.g. recording starts).
// Node's fetch keeps the connection alive in its pool by default.
await fetch("https://sync.assemblyai.com/warm", {
headers: { "X-AAI-Model": "universal-3-5-pro" },
});
// Same process -> reuses the warmed connection; no handshake here.
const form = new FormData();
form.append("audio", audioBlob, "sample.wav");
const response = await fetch("https://sync.assemblyai.com/transcribe", {
method: "POST",
headers: {
Authorization: "<YOUR_API_KEY>",
"X-AAI-Model": "universal-3-5-pro",
},
body: form,
});
console.log((await response.json()).text);# curl opens a fresh connection per process, so chain both
# requests in one invocation with --next to share the connection:
curl https://sync.assemblyai.com/warm \
-H 'X-AAI-Model: universal-3-5-pro' \
--next \
-X POST https://sync.assemblyai.com/transcribe \
-H 'Authorization: <YOUR_API_KEY>' \
-H 'X-AAI-Model: universal-3-5-pro' \
-F 'audio=@sample.wav;type=audio/wav'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sync.assemblyai.com/warm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-AAI-Model: <x-aai-model>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sync.assemblyai.com/warm"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-AAI-Model", "<x-aai-model>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://sync.assemblyai.com/warm")
.header("X-AAI-Model", "<x-aai-model>")
.asString();require 'uri'
require 'net/http'
url = URI("https://sync.assemblyai.com/warm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-AAI-Model"] = '<x-aai-model>'
response = http.request(request)
puts response.read_body{
"warm": "toasty"
}API reference
Pre-warm a connection
GET
/
warm
Python
import requests
session = requests.Session()
# Call as soon as you know audio is coming (e.g. recording starts).
session.get(
"https://sync.assemblyai.com/warm",
headers={"X-AAI-Model": "universal-3-5-pro"},
timeout=10,
)
# Same session -> reuses the warmed connection; no handshake here.
with open("sample.wav", "rb") as f:
response = session.post(
"https://sync.assemblyai.com/transcribe",
headers={
"Authorization": "<YOUR_API_KEY>",
"X-AAI-Model": "universal-3-5-pro",
},
files={"audio": ("sample.wav", f, "audio/wav")},
timeout=60,
)
print(response.json()["text"])// Call as soon as you know audio is coming (e.g. recording starts).
// Node's fetch keeps the connection alive in its pool by default.
await fetch("https://sync.assemblyai.com/warm", {
headers: { "X-AAI-Model": "universal-3-5-pro" },
});
// Same process -> reuses the warmed connection; no handshake here.
const form = new FormData();
form.append("audio", audioBlob, "sample.wav");
const response = await fetch("https://sync.assemblyai.com/transcribe", {
method: "POST",
headers: {
Authorization: "<YOUR_API_KEY>",
"X-AAI-Model": "universal-3-5-pro",
},
body: form,
});
console.log((await response.json()).text);# curl opens a fresh connection per process, so chain both
# requests in one invocation with --next to share the connection:
curl https://sync.assemblyai.com/warm \
-H 'X-AAI-Model: universal-3-5-pro' \
--next \
-X POST https://sync.assemblyai.com/transcribe \
-H 'Authorization: <YOUR_API_KEY>' \
-H 'X-AAI-Model: universal-3-5-pro' \
-F 'audio=@sample.wav;type=audio/wav'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sync.assemblyai.com/warm",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-AAI-Model: <x-aai-model>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sync.assemblyai.com/warm"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-AAI-Model", "<x-aai-model>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://sync.assemblyai.com/warm")
.header("X-AAI-Model", "<x-aai-model>")
.asString();require 'uri'
require 'net/http'
url = URI("https://sync.assemblyai.com/warm")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-AAI-Model"] = '<x-aai-model>'
response = http.request(request)
puts response.read_body{
"warm": "toasty"
}Headers
Model identifier used for request routing. Use the same value as your /transcribe request so the warmed connection matches the path the transcription will take.
Available options:
universal-3-5-pro Response
200 - application/json
Connection established. The response body carries no information — the value of the call is the open connection left in your client's pool.
Was this page helpful?
⌘I