This project sets up Amazon's Chronos2 time series forecasting model and makes it accessible through LM Studio via an OpenAI-compatible API.
Chronos2 is a family of pretrained time series forecasting models developed by Amazon. It uses a language model architecture (T5) adapted for time series prediction, achieving state-of-the-art zero-shot forecasting performance.
pip install -r requirements.txtThis will install:
- PyTorch
- Transformers
- Chronos-forecasting
- FastAPI and Uvicorn (for the API server)
python chronos_server.pyThe server will:
- Download the Chronos model from Hugging Face (first run only)
- Start an OpenAI-compatible API server on
http://localhost:8000 - Automatically use GPU if available, otherwise CPU
- Open LM Studio
- Go to the "Developer" tab or "Local Server" section
- Look for "Add External Server" or "Custom OpenAI Endpoint"
- Add a new server with these settings:
- Name: Chronos2
- Base URL:
http://localhost:8000/v1 - API Key: (leave empty or use any text)
- Model:
amazon/chronos-t5-small
In LM Studio's chat interface:
- Select the "Chronos2" model
- Send time series data for forecasting
User: [120, 135, 128, 145, 142, 155, 160, 148, 165, 172]
Chronos2 will forecast the next 12 time steps by default.
System: prediction_length: 24
User: [10.5, 11.2, 10.8, 12.1, 11.9, 12.5, 13.2, 12.8, 13.5, 14.1]
User: Monthly sales data: 1500, 1620, 1580, 1720, 1850, 1920, 2100, 2050, 2200, 2350, 2280, 2450
POST http://localhost:8000/v1/chat/completions
OpenAI-compatible endpoint for forecasting.
GET http://localhost:8000/v1/models
Returns available models.
GET http://localhost:8000/health
Check server status and model loading.
You can modify chronos_server.py to use different Chronos2 variants:
amazon/chronos-t5-tiny- Fastest, least accurateamazon/chronos-t5-mini- Good balanceamazon/chronos-t5-small- Default, recommendedamazon/chronos-t5-base- Higher accuracyamazon/chronos-t5-large- Best accuracy, slower
Change the model_name variable in chronos_server.py.
prediction_length: N- Number of future steps to forecast (default: 12)num_samples: N- Number of sample paths to generate (default: 20)
System: prediction_length: 6
System: num_samples: 50
User: [1.2, 1.5, 1.3, 1.8, 1.6, 2.1, 2.3, 2.0, 2.5, 2.8]
If the model fails to download, ensure you have internet connectivity and enough disk space (~200MB for the small model).
The server will automatically fall back to CPU. Check your PyTorch CUDA installation if you have a GPU.
Change the port in chronos_server.py (last line) from 8000 to another port.
Ensure the Chronos server is running before trying to connect from LM Studio.
- Architecture: T5-based language model adapted for time series
- Training: Pretrained on diverse time series datasets
- Inference: Zero-shot forecasting (no fine-tuning needed)
- Output: Probabilistic forecasts with confidence intervals