Skip to main content

Your First Prediction

This guide walks you through making your first prediction with the Kanva API.

Understanding the Prediction Endpoint

The prediction endpoint accepts input features and returns model predictions:

POST /api/v1/projects/{id}/predict

Input Format

Input data is sent as a JSON object where each feature is an array of values:

{
"input": {
"date": ["2024-01-15"],
"category": ["A"],
"value": [123.45]
}
}
tip

Each feature value must be wrapped in an array, even for single predictions. This format supports batch predictions.

Synchronous vs Asynchronous

The API supports two modes:

ModeQuery ParameterResponse
Sync?sync=trueWaits for result
Async(default)Returns job ID

For quick predictions (under 60 seconds), use synchronous mode. For longer-running predictions, use async mode with polling or webhooks.

Learn more: Sync vs Async

Example Response

{
"success": true,
"data": {
"predictions": ["predicted_value"],
"probabilities": [0.85, 0.15] // classification only
}
}

Error Handling

If something goes wrong, you'll receive an error response:

{
"success": false,
"error": "Invalid input: missing required feature 'date'"
}

See Error Handling for a complete list of error codes.