Skip to content

Deployment

Prerequisites

This page uses the wait_for_task helper defined in API Overview.

Once you have a trained model and a feature list, you can deploy them to serve predictions in production.

Create a Deployment

import featurebyte as fb

client = fb.Configurations().get_client()

response = client.post(
    "/deployment",
    json={
        "name": "Daily Sales Forecast - Production",
        "feature_list_id": feature_list_id,
        "ml_model_id": ml_model_id,
        "use_case_id": use_case_id,
    },
)
task_id = response.json()["id"]
task = wait_for_task(client, task_id)

deployment_id = task.get("payload", {}).get("output_document_id")

Parameters:

Parameter Type Required Description
name string Yes Display name for the deployment
feature_list_id string Yes ID of the feature list to deploy
ml_model_id string Yes ID of the trained model to deploy
use_case_id string Yes ID of the use case this deployment serves

Enable or Disable a Deployment

A newly created deployment is disabled by default. Enable it to start serving predictions:

# Enable
response = client.patch(
    f"/deployment/{deployment_id}",
    json={"enabled": True},
)
task_id = response.json()["id"]
wait_for_task(client, task_id)

# Disable
response = client.patch(
    f"/deployment/{deployment_id}",
    json={"enabled": False},
)
task_id = response.json()["id"]
wait_for_task(client, task_id)

List Deployments

response = client.get(
    "/catalog/deployment",
    params={"page": 1, "page_size": 20},
)
deployments = response.json()["data"]

Response fields (each item in data):

Field Type Description
id string Deployment ID
name string Deployment name
feature_list_id string Deployed feature list ID
ml_model_id string Deployed model ID
use_case_id string Associated use case ID
enabled boolean Whether the deployment is currently active

Generate Deployment SQL

Generate SQL queries that can be scheduled in your data warehouse to compute features:

response = client.post(
    "/deployment_sql",
    json={"deployment_id": deployment_id},
)
task_id = response.json()["id"]
wait_for_task(client, task_id)

response = client.get(
    "/deployment_sql",
    params={"deployment_id": deployment_id},
)
sql = response.json()

Parameters:

Parameter Type Required Description
deployment_id string Yes ID of the deployment to generate SQL for

Response fields (GET /deployment_sql):

Field Type Description
deployment_id string ID of the deployment
sql_queries array List of SQL query strings to execute in your warehouse

The generated SQL can be used with your warehouse's scheduling system (e.g., Snowflake Tasks, dbt, Airflow) to compute features on a schedule without depending on the FeatureByte server at inference time.