This example is only compatible with CLI v1.20 and later. Should you be making
use of an older version of the CLI, please run
pip install --upgrade cerebrium to upgrade it to the latest version.Basic Setup
Developing on Cerebrium is similar to a virtual machine or Google Colab. Install the Cerebrium package and log in before proceeding. See the installation docs for details. First, create your project:cerebrium.toml:
main.py file. This implementation fits in a single file. Start by defining the request object:
prompt and url parameters are required; all others are optional. Missing required parameters trigger an automatic error message.
Instantiate model
The SDXL model loads outside thepredict function since it only needs to load once at startup. The model downloads during initial deployment and is automatically cached in persistent storage for subsequent use.
Predict Function
Thepredict function takes parameters from the request, passes them to the SDXL model, and returns base64-encoded images for direct JSON-serializable responses.
Deploy
Deploy the model using this command: