Create API
You can deploy your models in a click for real-time inference.
Creating an API requires you to save a model. Learn how to save a machine learning model here.

Creating an API

There are 4 steps to take in order to Create an API:

1. Add the Create API block to your page

Open the / menu and search for 'API' or type /api to find the Create API block.

2. Give your API a name

Click on the text at the top left that says Untitled to name your API, choose a name that's related to the model you'll be serving.

3. Select a model to serve

4. Deploy!

You have everything you need now, you can hit Deploy and you should see the progress bar as the model is getting packaged, containerized and deployed. Deploying usually takes 5-10 seconds before the endpoint is ready and being served.

Using your API

Once your API is deployed, it should look like this:
  • The API is now available as a REST endpoint, it can be queried from other websites and apps using a POST request.
  • The incoming request will need to include an Authorization header with the bearer token.
  • You can click on the Paste sample request button at the bottom left to paste a code block below the API block with sample code on querying the API

Customizing your API

You may need to add some additional code for any pre and post processing for the model. For example, you may need to parse JSON input fields, query a feature store, as a step before you call the model's predict function. You may also want to customize the output before your API returns. You can do these things by clicking on Customize next to the model dropdown. Here you're given an area to write any additional code to execute before and after the predict.

Updating your API with a new model

One common use case is retraining a model, saving it with a new version, and updating the API to use the new model. To do this, simply click on the model dropdown, select your new model and click Redeploy at the top right. Your API endpoint and bearer token will remain the same for anyone consuming it, but it will now serve the new model!

Deactivating your API

You can deactivate your API by clicking the Deactivate button on the top right. When you deactivate an API, it will be taken down and it will not receive incoming requests.

Where can I find all my deployed APIs?

Every API created in the workspace is available in the APIs database in your workspace. Learn more about how the workspace database organization works. From there you'll be able to access the API, deactivate it, update its model, customize it further, and share a link to it.
You can navigate there by going to the workspace sidebar and clicking on APIs.