Asynchronously call a specific deployment of a model.
curl --request POST \
--url https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_input": {},
"webhook_endpoint": "<string>",
"priority": 0,
"max_time_in_queue_seconds": 600,
"inference_retry_config": {
"max_attempts": 3,
"initial_delay_ms": 1000,
"max_delay_ms": 5000
}
}
'import requests
url = "https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict"
payload = {
"model_input": {},
"webhook_endpoint": "<string>",
"priority": 0,
"max_time_in_queue_seconds": 600,
"inference_retry_config": {
"max_attempts": 3,
"initial_delay_ms": 1000,
"max_delay_ms": 5000
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_input: {},
webhook_endpoint: '<string>',
priority: 0,
max_time_in_queue_seconds: 600,
inference_retry_config: {max_attempts: 3, initial_delay_ms: 1000, max_delay_ms: 5000}
})
};
fetch('https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_input' => [
],
'webhook_endpoint' => '<string>',
'priority' => 0,
'max_time_in_queue_seconds' => 600,
'inference_retry_config' => [
'max_attempts' => 3,
'initial_delay_ms' => 1000,
'max_delay_ms' => 5000
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict"
payload := strings.NewReader("{\n \"model_input\": {},\n \"webhook_endpoint\": \"<string>\",\n \"priority\": 0,\n \"max_time_in_queue_seconds\": 600,\n \"inference_retry_config\": {\n \"max_attempts\": 3,\n \"initial_delay_ms\": 1000,\n \"max_delay_ms\": 5000\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_input\": {},\n \"webhook_endpoint\": \"<string>\",\n \"priority\": 0,\n \"max_time_in_queue_seconds\": 600,\n \"inference_retry_config\": {\n \"max_attempts\": 3,\n \"initial_delay_ms\": 1000,\n \"max_delay_ms\": 5000\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_input\": {},\n \"webhook_endpoint\": \"<string>\",\n \"priority\": 0,\n \"max_time_in_queue_seconds\": 600,\n \"inference_retry_config\": {\n \"max_attempts\": 3,\n \"initial_delay_ms\": 1000,\n \"max_delay_ms\": 5000\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}Authorizations
Pass your Baseten API key. Clients automatically send Authorization: Bearer <key>. Direct callers can also use Authorization: Api-Key <key>; both schemes are accepted.
Path Parameters
The alphanumeric ID of the deployment.
Body
There is a 256 KiB size limit on async predict request payloads.
JSON-serializable model input.
HTTPS URL to receive the prediction result via webhook. Both HTTP/2 and HTTP/1.1 are supported. If omitted, the model must save outputs so they can be accessed later.
Priority of the request. Lower values are higher priority.
0 <= x <= 2Maximum time in seconds a request will spend in the queue before expiring. Must be between 10 seconds and 72 hours.
10 <= x <= 259200Exponential backoff parameters for retrying predict requests.
Show child attributes
Show child attributes
Response
Async predict request enqueued.
The ID of the async request.
Was this page helpful?
curl --request POST \
--url https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_input": {},
"webhook_endpoint": "<string>",
"priority": 0,
"max_time_in_queue_seconds": 600,
"inference_retry_config": {
"max_attempts": 3,
"initial_delay_ms": 1000,
"max_delay_ms": 5000
}
}
'import requests
url = "https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict"
payload = {
"model_input": {},
"webhook_endpoint": "<string>",
"priority": 0,
"max_time_in_queue_seconds": 600,
"inference_retry_config": {
"max_attempts": 3,
"initial_delay_ms": 1000,
"max_delay_ms": 5000
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_input: {},
webhook_endpoint: '<string>',
priority: 0,
max_time_in_queue_seconds: 600,
inference_retry_config: {max_attempts: 3, initial_delay_ms: 1000, max_delay_ms: 5000}
})
};
fetch('https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_input' => [
],
'webhook_endpoint' => '<string>',
'priority' => 0,
'max_time_in_queue_seconds' => 600,
'inference_retry_config' => [
'max_attempts' => 3,
'initial_delay_ms' => 1000,
'max_delay_ms' => 5000
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict"
payload := strings.NewReader("{\n \"model_input\": {},\n \"webhook_endpoint\": \"<string>\",\n \"priority\": 0,\n \"max_time_in_queue_seconds\": 600,\n \"inference_retry_config\": {\n \"max_attempts\": 3,\n \"initial_delay_ms\": 1000,\n \"max_delay_ms\": 5000\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_input\": {},\n \"webhook_endpoint\": \"<string>\",\n \"priority\": 0,\n \"max_time_in_queue_seconds\": 600,\n \"inference_retry_config\": {\n \"max_attempts\": 3,\n \"initial_delay_ms\": 1000,\n \"max_delay_ms\": 5000\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/async_predict")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_input\": {},\n \"webhook_endpoint\": \"<string>\",\n \"priority\": 0,\n \"max_time_in_queue_seconds\": 600,\n \"inference_retry_config\": {\n \"max_attempts\": 3,\n \"initial_delay_ms\": 1000,\n \"max_delay_ms\": 5000\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}{
"error": "<string>",
"detail": "<string>"
}