import urllib3
import os

model_id = ""
env_name = "staging"

# Read secrets from environment variables

baseten_api_key = os.environ["BASETEN_API_KEY"]

resp = urllib3.request(
"POST",
f"https://model-{model_id}.api.baseten.co/environments/{env_name}/predict",
headers={"Authorization": f"Api-Key {baseten_api_key}"},
json={}, # JSON-serializable model input
)

print(resp.json())

{}
Use this endpoint to call the deployment associated with the specified environment.
https://model-{model_id}.api.baseten.co/environments/{env_name}/predict"

Parameters

model_id
string
required
The ID of the model you want to call.
env_name
string
required
The name of the model’s environment you want to call.
Authorization
string
required
Your Baseten API key, formatted with prefix Api-Key (e.g. {"Authorization": "Api-Key abcd1234.abcd1234"}).

Body

Model input
json
required
JSON-serializable model input.
import urllib3
import os

model_id = ""
env_name = "staging"

# Read secrets from environment variables

baseten_api_key = os.environ["BASETEN_API_KEY"]

resp = urllib3.request(
"POST",
f"https://model-{model_id}.api.baseten.co/environments/{env_name}/predict",
headers={"Authorization": f"Api-Key {baseten_api_key}"},
json={}, # JSON-serializable model input
)

print(resp.json())

{}