APIs
Deploy your model or code as an API that other systems can call.
Deploy a model or other code as an API, so other systems can send it data and get results back, such as predictions from a trained model.
Deploying an API from a notebook
Open Deploy and choose FastAPI or Flask under API Services. Zerve gives you an example script to start from. To use a variable from your notebook, such as a trained model, use variable():
from zerve import variable
model = variable("train_model", "model")Set the DNS name and instance type, then start a preview and use the HTTP Playground tab to send test requests. When it works, select Deploy.
If your API needs extra packages, choose an environment that includes them. See Environments and packages.
See Deployments overview for settings, instance types and costs.
Calling your API
Once your API is active, call it at its address. For example, with Python:
import requests
url = "https://my-model.api.example.zerve.cloud/predict"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
data = {"payload": {"price": [194.03], "capacity": [2]}}
response = requests.post(url, json=data, headers=headers)
print(response.json())Replace the address, route and data with your own.
Building APIs in the canvas
In the canvas view, you can also build an API from blocks in a deployment layer. See Layers.
API Controller
Sets up the API: its address, its API key, the files it needs, its environment, and its compute. Choose Lambda, with memory from 128 MB to 10,240 MB, or Fargate, with an instance size.
API Route
Defines one endpoint: its name, its method (GET, POST, PUT or DELETE), the data it expects, and a test payload
SageMaker endpoint
Deploys a model as an AWS SageMaker endpoint
Connect an API Controller to one or more API Route blocks, then add the code each route runs. Route code can use variables from the development layer, such as a trained model, so redeploying after retraining uses the new model.
APIs on Lambda are limited to 15 minutes per request. See Compute types.
Logs
Every deployment has logs, for both building and running, to help you track errors and usage.
Last updated
Was this helpful?
