# Create Deployment

## API Controller

An API controller is a central component within the API layer that manages key functions and information related to its APIs.

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FPGUd9TaLCOQe4YK98LDv%2FAPI%20Builder.png?alt=media&#x26;token=985d9774-4af7-4ab8-aeaa-e3577df2a3d1" alt=""><figcaption><p>API Controller Setup</p></figcaption></figure>

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2F1uIXMaShNweN1HjKgogJ%2FScreenshot%202025-06-19%20at%2011.39.49%E2%80%AFAM.png?alt=media&#x26;token=d137a876-ebf8-442a-8cd8-15a1adc38877" alt=""><figcaption><p>API Configuration</p></figcaption></figure>

**API Address**: The controllers provide endpoints through which clients can access the managed APIs.

**API Key**: They handle API key management, enabling developers to generate, distribute, and revoke API keys for authentication and access control.

**Files**: API controllers manage files associated with API requests and responses.

**Customizable Options Offered by API Controller**:

* **Compute Type**: Choose between Lambda or Fargate for your computing needs.
* **Compute Memory**: Configure the memory allocation for optimized performance.

## API Route

API routes correspond to HTTP methods such as GET, POST, PUT, and DELETE. Developers typically define these routes within the API's configuration or routing system.

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2Fp5wx4OWPJ7EwSRDosF8v%2FScreenshot%202025-06-19%20at%2011.43.50%E2%80%AFAM.png?alt=media&#x26;token=247c0f7a-5fc6-48e3-a56b-3046ca22fa17" alt=""><figcaption><p>API Route Block</p></figcaption></figure>

Route Configuration:

Setup route name and method of the route.&#x20;

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FXrX8tiZeVWVgPlu03rVj%2FScreenshot%202025-06-19%20at%2011.45.16%E2%80%AFAM.png?alt=media&#x26;token=b64fdb94-c22e-449f-a856-0bcde2f3d443" alt=""><figcaption></figcaption></figure>

**Data Validation**:&#x20;

Data validation involves checking incoming data for correctness, completeness through payload validation and response filtering, guarding against potential security vulnerabilities.

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FckM9ykIStNAXZWgpblC7%2FScreenshot%202025-06-19%20at%2011.46.03%E2%80%AFAM.png?alt=media&#x26;token=abd515c6-73be-4804-aea7-8fcc7e160fa2" alt=""><figcaption></figcaption></figure>

**Test:**\
Add test payload - sample data to test the deployment code.

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FMGDjJciWdRFF14vZrnyN%2FScreenshot%202025-06-19%20at%2011.46.44%E2%80%AFAM.png?alt=media&#x26;token=46788adf-57e6-4693-9def-42b87c28e29c" alt=""><figcaption></figcaption></figure>

## Setting up Deployment:

Once model training is completed users can connect the trained model to deployment layer as shown below.

1. Add an API Controller block in API layer and setup required configurations - DNS name and API Key.&#x20;

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FYW3N6t3LnrrBVncsJZvX%2FScreenshot%202025-06-19%20at%2011.50.27%E2%80%AFAM.png?alt=media&#x26;token=3d916777-fc80-4894-bb46-c8c2fce3b91c" alt=""><figcaption></figcaption></figure>

2. Connect API controller to Route block and edit the configuration with Route Name to predict and Method to POST for predictions.&#x20;

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FrU4iWYSCIb5HK1of3bss%2FScreenshot%202025-06-19%20at%2011.55.46%E2%80%AFAM.png?alt=media&#x26;token=e90357b8-e19e-4a32-9269-e64f72453734" alt=""><figcaption></figcaption></figure>

3. Setup data validation to specify the expected data input format.

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FoVE68w1iWosyliYeQsrQ%2FScreenshot%202025-06-19%20at%2011.56.39%E2%80%AFAM.png?alt=media&#x26;token=904b54c5-c17d-4de8-a771-89dcc29fe2a3" alt=""><figcaption></figcaption></figure>

4. Add example test data to run test predictions and validate deployment code. This should contain all the necessary variables required for the model to generate predictions.

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2Fl0DNT9qvWfkWFNIsY0LA%2FScreenshot%202025-06-19%20at%2011.58.24%E2%80%AFAM.png?alt=media&#x26;token=e8318883-7d7e-4c7e-9346-c194eac21d47" alt=""><figcaption></figcaption></figure>

5. Here you can get either cURL or Python code for post-deployement

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2F6TjgSuLLrJJ8XHgZDAm5%2FScreenshot%202025-06-19%20at%2011.59.37%E2%80%AFAM.png?alt=media&#x26;token=c3a3b21f-7013-4452-8264-7434ecb8a8d2" alt=""><figcaption></figcaption></figure>

6. Add the prediction code that is required to run deployment predictions. In this layer users can reference the model variable from the development layer.

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FMYeP5wEC3BDDdXo0aWiK%2Fimage.png?alt=media&#x26;token=518e7329-c0c0-4a36-98a0-7f77047460e0" alt=""><figcaption><p>Attach Variable Section</p></figcaption></figure>

<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2FzgQbegfoEXJP94B9x3HC%2FScreenshot%202025-06-19%20at%2012.04.06%E2%80%AFPM.png?alt=media&#x26;token=e9d2e737-4beb-4ae7-a833-41a0e12feee4" alt=""><figcaption><p>Select the model variable needed for prediction</p></figcaption></figure>

7. Deploy the model to zerve hosted API layer.
8.

```
<figure><img src="https://1018070783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIQKNeqjEeOp9UwUcB9R9%2Fuploads%2Fp2oVz2MAn6u5VyQ4nBSj%2FScreenshot%202025-06-19%20at%2012.07.46%E2%80%AFPM.png?alt=media&#x26;token=977cfcc9-394a-4915-9f2f-57a6fd9bbdc8" alt=""><figcaption></figcaption></figure>
```

This can be accessed via the configured API address - <https://zerveai.zerve.cloud/predict>

## Redeployment:

Since the API Layer is connected to the development layer any changes to the model can be easily pushed to the APIs. Once the retraining is completed users can simply redeploy the API as shown above and the latest model version will be used for predictions. This is made possible by the variable attachment process from Step 5 above.&#x20;

## Logs:

For all the deployments users have access to both deployment logs and runtime logs to track errors and deployment usage.
