# Create Model

## POST /v1/forecasts/models

> Create Model

```json
{"openapi":"3.1.0","info":{"title":"PredictHQ Forecasts API (Public Preview)","version":"1.0.0"},"tags":[{"name":"Models"}],"servers":[{"url":"https://api.predicthq.com"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"$API_KEY","description":"Enter your PredictHQ API key. The Bearer prefix is added automatically.\n\nWhen calling the API directly, send: `Authorization: Bearer <YOUR_API_KEY>` as documented at [https://docs.predicthq.com/api/overview/authenticating](https://docs.predicthq.com/api/overview/authenticating)\n"}},"schemas":{"CreateModelRequest":{"type":"object","properties":{"name":{"description":"Name for the forecast model.","type":"string","minLength":1},"external_id":{"description":"External identifier for the forecast model. If you have an ID for the location/store/property/product-group in your other platforms, use the same ID here to easily connect this specific forecast model.","type":"string","minLength":1},"forecast_window":{"description":"Number of days into the future to forecast.","$ref":"#/components/schemas/ForecastWindowDay"},"generate_baseline":{"description":"When true, generates a baseline model using historical demand data only - without PredictHQ demand intelligence - for benchmarking accuracy against the enhanced model.","type":"boolean","default":false,"title":"Generate Baseline Model"},"label":{"description":"Set of labels you can use to better identify or group your forecast models.","type":"array","items":{"type":"string","minLength":1},"minItems":1},"location":{"description":"Location of your business so we can identify relevant events around the\nlocation impacting the demand.\n\n\nPlease create a Saved Location first, that can be reused across multiple forecast\nmodels if needed.","$ref":"#/components/schemas/Location"},"algo":{"description":"Currently we offer one algorithm based on XGBoost. In the future we may offer additional algos.","type":"string","default":"phq-xgboost","const":"phq-xgboost"},"demand_type":{"$ref":"#/components/schemas/InputDemandType"}},"additionalProperties":false,"required":["name","location"],"title":"CreateModelRequest"},"ForecastWindowDay":{"type":"string","enum":["1d","7d","14d","28d","30d","60d","90d"],"title":"ForecastWindowDay"},"Location":{"type":"object","properties":{"saved_location_id":{"type":"string","minLength":1,"title":"Saved Location ID"}},"required":["saved_location_id"],"title":"Location"},"InputDemandType":{"type":"object","properties":{"interval":{"$ref":"#/components/schemas/InputInterval"},"industry":{"$ref":"#/components/schemas/Industry"}},"title":"InputDemandType"},"InputInterval":{"type":"string","const":"day","title":"InputInterval"},"Industry":{"description":"Choosing the right industry is important as this will determine the type of features used in the training and forecasting and will impact the accuracy of the results. We will use the applicable Predicted Impact Patterns for the specified industry.","type":"string","enum":["accommodation","cpg","tourism","marketing","parking","restaurants","retail","transportation","other"],"title":"Industry"},"CreateModelResponse":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"string"},"default":[],"title":"Errors"},"warnings":{"type":"array","items":{"type":"string"},"default":[],"title":"Warnings"},"model_id":{"type":"string","minLength":1,"title":"Model Id"}},"required":["model_id"],"title":"CreateModelResponse"},"HTTPValidationError":{"type":"object","properties":{"detail":{"type":"array","items":{"$ref":"#/components/schemas/ValidationError"},"title":"Detail"}},"title":"HTTPValidationError"},"ValidationError":{"type":"object","properties":{"loc":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/forecasts/models":{"post":{"operationId":"create_model","summary":"Create Model","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateModelRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateModelResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Models"]}}}}
```

## OpenAPI Spec

The OpenAPI spec for Forecasts API can be [found here](https://api.predicthq.com/docs/?urls.primaryName=Forecasts+API).

## Guides

* [Getting Started with Forecasts API](https://docs.predicthq.com/getting-started/guides/forecasts-api-guides/getting-started)
* [Understanding Forecast Accuracy Metrics](https://docs.predicthq.com/getting-started/guides/forecasts-api-guides/understanding-forecast-accuracy-metrics)
* [Troubleshooting Guide for Forecasts API](https://docs.predicthq.com/getting-started/guides/forecasts-api-guides/troubleshooting)


---

# 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.predicthq.com/api/forecasts/models/create-model.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.
