# Getting Started

Guide to deploying models using the CX CLI.

## Contents

1. [Prerequisites](#prerequisites)
2. [Installation](#installation)
3. [Logging In](#logging-in)
   * [Updating Your Password](#updating-your-password)
   * [Password Policy](#password-policy)
4. [Set Up an Account on CX](#set-up-an-account-on-cx)
5. [Access Publicly Available Postman Collection](#access-publicly-available-postman-collection)
6. [API Interface](#api-interface)
   * [Using the API](#using-the-api)

## Prerequisites

* **MacOS** or **Linux** Operating system
* **Docker**. CX CLI uses Docker to package images. Get it from [here](https://docs.docker.com/get-docker/).
* **pip**. for installing the CX CLI
* **python 3.8**. Or higher

### Installation

Install the CX CLI using pip:

```bash
$ pip install computex-cli
```

### Logging In

Log in to the CLI using the CX credentials

```shell
$ cx login --username {username} --password {password}
```

## Set up an account on CX

Sign up for an account on [computex.ai](https://www.computex.ai/). You will receive a confirmation email with you access key.

### Updating your password

When you first create an account on CX, you'll be prompted to change your password. You can also update your password anytime by following the steps below:

#### Using the CX CLI

Login to the CX CLI using your CX credentials, then run the `change-password` command.

```shell
$ cx login --username {username} --password {password}
$ cx change-password
```

#### Using the API

1. Endpoint: Send a POST request to the /users/change\_password endpoint.
2. Command

```shell
$ curl -X 'POST' \
    'https://api.computex.co/api/v1/users/change_password' \
    -H 'accept: application/json' \
    -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
    -H 'Content-Type: application/json' \
    -d '{
    "old_password": "original-password",
    "new_password": "new-password",
    "confirm_new_password": "new-password"
}'
```

Replace YOUR\_ACCESS\_TOKEN with your access token, and ensure you input the correct old\_password and desired new\_password.

### Password Policy

When creating or updating your password on CX, please ensure your password adheres to the following criteria:

1. **Length**: Your password must be between 8 and 32 characters long.
2. **Uppercase Letters**: Your password must contain at least one uppercase letter (A-Z).
3. **Lowercase Letters**: Your password must contain at least one lowercase letter (a-z).
4. **Numbers**: Your password must contain at least one number (0-9).

## API Interface

The CX API ([api.computex.ai](https://api.computex.ai/docs)) has all of the tools to interact with backend CX infrastructure.

Functionality includes:

* Deploying Serverless AI models
* Deploying AI models on Always-on Servers
* Spawning Virtual Servers
* Checking logs from deployments
* Running Inference on deployed models
* Geting billing information

## Access Publicly Available Postman Collection

To access the publicly available Postman Workspace, click [here](https://api.postman.com/collections/29419592-6e34dd33-0935-4b2b-a5de-68b23710f18e?access_key=PMAT-01HAQRE3PPZQ9QYYZXQV2Z0X6N).

This collection can be cloned and imported into your own Postman Workspace.

### Using the API

To interact with the API, start off by authenticating. The API is secured with JWT Bearer Auth. Enter the following to receive the JWT Token:

```bash
curl -X 'POST' \
  'http://api.computex.ai/api/v1/users/login' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "your-email@email.com",
  "password": "your-password"
}'
```

**Successful Response:**

```
{
    "token": "ey...",
    "refresh_token": "ey..."
}
```

Use the token generated from the response to pass in the headers of all subsequent API calls. For example:

```bash
curl -X 'GET' \
  'http://api.computex.ai/api/v1/deployments/deployments' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer ey...'
```
