# 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="/files/OXTyDcNFsKAJtUfDTjEc" alt=""><figcaption><p>API Controller Setup</p></figcaption></figure>

<figure><img src="/files/6i5MoHS4BexyHnJC1rgE" 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="/files/iyXeC6v72541RIjvIOo5" alt=""><figcaption><p>API Route Block</p></figcaption></figure>

Route Configuration:

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

<figure><img src="/files/l97M2M2wNKTouh2laNwl" 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="/files/JlUAVvNbwhzmMJGg4bhf" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/Cm5ZpS4VOaRYPDUX12nR" 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="/files/T1OegMLsAPKfMGwCcPgv" 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="/files/nOVXpiPRmzQgoX573P9a" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/199LZhGF9WL5vDEpFKfl" 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="/files/KYodGpevS69RsFl8R5tx" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/AtGBLWlF3WXipcnrdD0C" 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="/files/JF9M3OnXncep8UfrvqCN" alt=""><figcaption><p>Attach Variable Section</p></figcaption></figure>

<figure><img src="/files/Be10NplnKAKzx1x6p4G0" 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="/files/OUnj6SmybD5SO1kz8AYV" 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zerve.ai/guide/canvas-view/layers-overview/deployment/create-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
