> ## Documentation Index
> Fetch the complete documentation index at: https://docs.epigos.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Predictions

> Run inference on an image and retrieve predictions.

Epigos offers an API that allows you to make predictions from your model.
This API is accessible within the Epigos Node SDK.

<Note>
  You'll need to [Create an API Key](/workspace/api-keys) to
  [Authentication](/api-reference/introduction#authentication) with Epigos AI.
</Note>

# Image classification

You can predict the class or label of an image using the `predict()` function when you load a classification model.

## classification()

Loads classification model deployed on the platform.

| Param      | Type   | Description                                        |
| ---------- | ------ | -------------------------------------------------- |
| `model_id` | string | The unique ID of your model deployed on Epigos AI. |

```ts theme={null}
import { Epigos } from "@epigosai/epigos-sdk";

const client = new Epigos({ apiKey: "api_key_123" });

// load classification model
const model = client.classification("modelId");
```

### predict()

Makes predictions for the classification model.

| Param     | Type | Description                                 |
| --------- | ---- | ------------------------------------------- |
| `payload` | dict | Dictionary containing prediction parameters |

#### Payload

| Param         | Type   | Description                                                   |
| ------------- | ------ | ------------------------------------------------------------- |
| `imageUrl`    | string | Optional remote url pointing to image the                     |
| `imageBase64` | string | Optional Base64-encoded string of the image                   |
| `confidence`  | number | Optional confidence threshold used to filter out predictions. |

<Note>
  The function expects either `imageUrl` or `imageBase64` to provided else it
  will raise validation errors.
</Note>

#### Example prediction

```python theme={null}
// make predictions
results = await model.predict({ imageUrl: 'path/to/your/image.jpg' })

console.log(results)
{
   "category" : "cat",
   "confidence" : 0.854,
   "predictions" : [
      {
         "category" : "cat",
         "confidence" : 0.854
      },
      {
         "category" : "dog",
         "confidence" : 0.146
      }
   ]
}
```

# Object detection

You can detect objects in an image using the `detect()` function when you load an object detection model.

## objectDetection()

Loads an object detection model deployed on the platform.

| Param      | Type   | Description                                        |
| ---------- | ------ | -------------------------------------------------- |
| `model_id` | string | The unique ID of your model deployed on Epigos AI. |

```ts theme={null}
import { Epigos } from "@epigosai/epigos-sdk";

const client = new Epigos({ apiKey: "api_key_123" });

// load object detection model
const model = client.objectDetection("modelId");
```

### detect()

Makes detection for the object detection model.

| Param     | Type | Description                                 |
| --------- | ---- | ------------------------------------------- |
| `payload` | dict | Dictionary containing prediction parameters |

### Payload

| Param         | Type   | Description                                                   |
| ------------- | ------ | ------------------------------------------------------------- |
| `imageUrl`    | string | Optional remote url pointing to image the                     |
| `imageBase64` | string | Optional Base64-encoded string of the image                   |
| `confidence`  | number | Optional confidence threshold used to filter out predictions. |
| `options`     | object | Optional options to customize image annotation.               |

### Options

| Param         | Type    | Description                                                                          |
| ------------- | ------- | ------------------------------------------------------------------------------------ |
| `annotate`    | boolean | Optional annotate flag to specify whether to annotate the image or not.              |
| `showProb`    | boolean | Optional show\_prob to specify whether detection confidence are shown on the labels. |
| `strokeWidth` | number  | Optional stroke width to specify bounding box border width.                          |

<Note>
  The function expects either `imageUrl` or `imageBase64` to provided else it
  will raise validation errors.
</Note>

#### Example detection

```python theme={null}
// make detections
results = await model.detect({ imageUrl: 'path/to/your/image.jpg' })

console.log(results)
{
   "detections": [
        {
            "label": "car",
            "confidence": 0.954,
            "x": 281,
            "y": 187,
            "width": 46,
            "height": 36
        }
    ],
    "image": "<base64 image>",
    "labelsCount": [
        {
            "label": "car",
            "total": 1
        }
    ]
}
```

#### Example detection with annotation options

```python theme={null}
// make detections
results = await model.detect({ imageUrl: 'path/to/your/image.jpg', options: {annotate: true, strokeWidth: 3} })

console.log(results)
{
   "detections": [
        {
            "label": "car",
            "confidence": 0.954,
            "x": 281,
            "y": 187,
            "width": 46,
            "height": 36
        }
    ],
    "image": "<base64 image>",
    "labelsCount": [
        {
            "label": "car",
            "total": 1
        }
    ]
}
```

***

Checkout the code on [Github](https://github.com/Epigos-AI/epigos-ts)
