> ## Documentation Index
> Fetch the complete documentation index at: https://freelance-4888ed08.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Forecast

> Submit feature values and receive a demand prediction with confidence score and model metadata

Generates a demand forecast for a single data point. Requires API key authentication.

### Authentication

**X-API-Key** `string` *required*

API key for authentication. Verified server-side using Argon2id hashing with constant-time comparison.

### Parameters

**features** `object` *required*

Dictionary of input features for the model.

**Feature fields**

**hr** `integer` *required*

Hour of the day (0–23).

**temp** `float` *required*

Normalized temperature (0–1).

**hum** `float` *required*

Normalized humidity (0–1).

**weathersit** `integer` *required*

Weather condition code (1–4): 1=Clear, 2=Mist, 3=Light rain, 4=Heavy rain.

**weekday** `integer` *required*

Day of week (0=Sunday, 6=Saturday).

**windspeed** `float`

Normalized wind speed (0–1). Optional.

### Response

**prediction** `float` *required*

Predicted bike rental count for the given conditions.

**confidence** `float` *required*

Prediction confidence score (0.50–0.95).

**model\_version** `string` *required*

Always `"production"` for the primary model.

**model\_id** `string` *required*

Identifier for the model that served the request (e.g., `"production"` or `"challenger"`).

**timestamp** `string` *required*

ISO 8601 timestamp of when the prediction was generated.

```bash cURL theme={null}
curl -X POST http://localhost:8000/predict \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "features": {
      "hr": 14,
      "temp": 0.5,
      "hum": 0.6,
      "weathersit": 1,
      "weekday": 2
    }
  }'
```

```python Python theme={null}
import requests

response = requests.post(
    "http://localhost:8000/predict",
    headers={"X-API-Key": "your-api-key"},
    json={
        "features": {
            "hr": 14, "temp": 0.5, "hum": 0.6,
            "weathersit": 1, "weekday": 2
        }
    }
)
print(response.json())
```

```json 200 theme={null}
{
  "prediction": 145.2,
  "confidence": 0.75,
  "model_version": "production",
  "model_id": "production",
  "timestamp": "2025-01-15T14:30:00"
}
```

```json 401 theme={null}
{
  "detail": "Invalid or missing API key"
}
```

```json 429 theme={null}
{
  "detail": "Rate limit exceeded. Try again in 60 seconds."
}
```


## OpenAPI

````yaml POST /predict
openapi: 3.0.0
info:
  title: Demand Forecasting API
  version: 1.0.0
  description: API for retrieving demand forecasts and monitoring system health.
servers:
  - url: http://localhost:8000
    description: Local Model Server
security: []
paths:
  /predict:
    post:
      summary: Generate Forecast
      description: >-
        Predicts bike demand for a given set of features. Requires 'temp',
        'humidity', 'wind_speed', 'hour', 'day_of_week'.
      operationId: generateForecast
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                features:
                  type: object
                  description: Key-value pairs of features
                  example:
                    temp: 0.5
                    humidity: 0.6
                    wind_speed: 0.2
                    hour: 14
                    day_of_week: 3
      responses:
        '200':
          description: Successful prediction
          content:
            application/json:
              schema:
                type: object
                properties:
                  prediction:
                    type: number
                    example: 452.3
                  confidence:
                    type: number
                    example: 0.85
                  model_version:
                    type: string
                    example: production
                  timestamp:
                    type: string
                  model_id:
                    type: string
        '422':
          description: Validation Error (e.g., missing features)
        '503':
          description: Model not loaded

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.