import requests
import os

model_id = ""
request_id = ""
# Read secrets from environment variables
baseten_api_key = os.environ["BASETEN_API_KEY"]

resp = requests.get(
    f"https://model-{model_id}.api.baseten.co/async_request/{request_id}",
    headers={"Authorization": f"Api-Key {baseten_api_key}"}
)

print(resp.json())
{
  "request_id": "<string>",
  "model_id": "<string>",
  "deployment_id": "<string>",
  "status": "<string>",
  "webhook_status": "<string>",
  "created_at": "<string>",
  "status_at": "<string>",
  "errors": [
    {
      "code": "<string>",
      "message": "<string>"
    }
  ]
}

Parameters

model_id
string
required

The ID of the model.

request_id
string
required

The ID of the async request.

Headers

Authorization
string
required

Your Baseten API key, formatted with prefix Api-Key (e.g. {"Authorization": "Api-Key abcd1234.abcd1234"}).

Response

request_id
string
required

The ID of the async request.

model_id
string
required

The ID of the model that executed the request.

deployment_id
string
required

The ID of the deployment that executed the request.

status
string
required

An enum representing the status of the request.

Available options: QUEUED, IN_PROGRESS, SUCCEEDED, FAILED, EXPIRED, CANCELED, WEBHOOK_FAILED

webhook_status
string
required

An enum representing the status of sending the predict result to the provided webhook.

Available options: PENDING, SUCCEEDED, FAILED, CANCELED, NO_WEBHOOK_PROVIDED

created_at
string
required

The time in UTC at which the async request was created.

status_at
string
required

The time in UTC at which the async request’s status was updated.

errors
object[]
default:[]
required

Any errors that occurred in processing the async request. Empty if no errors occurred.

{
  "request_id": "<string>",
  "model_id": "<string>",
  "deployment_id": "<string>",
  "status": "<string>",
  "webhook_status": "<string>",
  "created_at": "<string>",
  "status_at": "<string>",
  "errors": [
    {
      "code": "<string>",
      "message": "<string>"
    }
  ]
}

Rate limits

Calls to the get async request status endpoint are limited to 20 requests per second. If this limit is exceeded, subsequent requests will receive a 429 status code.

To avoid hitting this rate limit, we recommend configuring a webhook endpoint to receive async predict results instead of frequently polling this endpoint for async request statuses.

import requests
import os

model_id = ""
request_id = ""
# Read secrets from environment variables
baseten_api_key = os.environ["BASETEN_API_KEY"]

resp = requests.get(
    f"https://model-{model_id}.api.baseten.co/async_request/{request_id}",
    headers={"Authorization": f"Api-Key {baseten_api_key}"}
)

print(resp.json())