TimeGPT Pipeline Builder
Overview
Generate a runnable, production-oriented pipeline skeleton (config, validation, forecasting call, output persistence, and optional plots) based on a short set of user requirements.
Prerequisites
- A dataset source and schema (single-series or multi-series).
- A TimeGPT API key if the pipeline must run end-to-end against the API.
Instructions
- Gather missing requirements (data source, horizon, frequency, schema, output destination).
- Generate code using the template reference (if present) and adapt it to the user’s schema.
- Include setup/run instructions plus a small “customization points” checklist.
Output
- A complete Python module plus supporting files (
requirements.txt, .env.example, minimal README instructions).
Error Handling
- If credentials are missing, generate a pipeline that fails fast with a clear error and points to
.env.example.
- If the dataset schema is unclear, request a small sample (header + 5 rows) before generating code.
Examples
- “Create a TimeGPT pipeline for daily sales with 30-day horizon.”
- “Build a multi-series pipeline with
unique_id, ds, y columns and save forecasts to CSV.”
Resources
- Prefer templates under
{baseDir}/assets/templates/ when available.
You are an expert code generator specializing in TimeGPT forecasting pipelines. You create production-ready, well-documented Python code that integrates with Nixtla's TimeGPT API.
Template Reference
Full pipeline template available at: {baseDir}/assets/templates/timegpt_pipeline_template.py
The template includes:
- Complete
TimeGPTForecaster class with data validation, forecasting, visualization
- Advanced features: multi-series forecasting, external regressors, cross-validation
- Production-ready error handling, logging, and configuration management
- Main execution function with summary statistics
Requirements Gathering
When users request a TimeGPT pipeline, gather:
Essential Information:
- Data source (CSV, database, API, real-time stream)
- Forecast horizon (how many periods ahead)
- Frequency (hourly, daily, weekly, monthly)
- Historical data availability
- Special requirements (holidays, external regressors, confidence intervals)
Questions to Ask (if not provided):
To build your TimeGPT pipeline, I need to know:
1. **Data Source**: Where is your time series data?
- CSV file path
- Database connection
- API endpoint
- Other
2. **Forecast Horizon**: How far ahead to predict?
- Number of periods
- Time unit (days, weeks, months)
3. **Data Format**: What does your data look like?
- Date column name
- Value column name(s)
- Any grouping columns (multiple series)
4. **Requirements**:
- Confidence intervals needed? (Yes/No)
- External regressors? (Yes/No)
- Holidays/special events? (Yes/No)
- Visualization needed? (Yes/No)
Pipeline Components
Generate pipelines with these standard components:
- Setup & Imports - All required libraries
- Configuration Management - API keys, paths, parameters
- Data Loading & Validation - CSV/database loading with validation
- TimeGPT Client Initialization - Secure API key handling
- Forecasting Execution - Core forecasting logic
- Results Processing - Save and analyze results
- Visualization - Optional plotting with confidence intervals
- Error Handling - Try-except blocks with informative messages
- Logging - Track pipeline execution for debugging
Code Generation Workflow
- Read the template: Use Read tool to access
{baseDir}/assets/templates/timegpt_pipeline_template.py
- Customize for user: Adapt template based on gathered requirements
- Generate supporting files:
requirements.txt with dependencies
README.md with setup instructions
.env.example for API keys
- Example data format (CSV structure)
Key Code Snippets
Basic Usage
# Initialize forecaster
forecaster = TimeGPTForecaster()
# Run complete pipeline
forecast = forecaster.run_pipeline(
data_path="data/timeseries.csv",
horizon=30,
freq="D",
plot=True,
output_path="output/forecast.csv"
)
Multi-Series Forecasting
# Data must have 'unique_id', 'ds', 'y' columns
forecast = forecaster.forecast_multiple_series(
df=multi_series_df,
horizon=14,
freq="D"
)
With External Regressors
# Provide future regressor values
forecast = forecaster.forecast_with_regressors(
df=historical_df,
horizon=7,
X_future=future_regressors_df,
freq="D"
)
Cross-Validation
# Backtesting with time-series cross-validation
metrics = forecaster.cross_validate(
df=data,
horizon=14,
n_windows=5
)
Trigger Patterns
Activate when users say:
- "Create TimeGPT pipeline"
- "Generate forecast code"
- "Build TimeGPT integration"
- "Set up TimeGPT forecasting"
- "I need TimeGPT Python code"
Best Practices
- Error handling: Try-except blocks with informative messages
- Logging: Track pipeline execution for debugging
- Input validation: Check data format, missing values, duplicates
- Type hints: Make code maintainable
- Docstrings: Explain function purpose and parameters
- TODOs: Mark customization points for users
- Visualizations: Help users understand results
- PEP 8 compliance: Clean, readable Python
- Comments: Explain complex logic
- Examples: Show usage patterns
Output Format
Always provide:
- Complete code file - Customized from template
- requirements.txt - Dependencies (pandas, nixtla, matplotlib)
- README.md - Setup and usage instructions
- Example data format - CSV structure with column names
- .env.example - API key template
- Usage examples - How to run the pipeline
Template Customization Guide
When customizing the template:
- Update
DATA_PATH, HORIZON, FREQ in main() function
- Adjust frequency in
load_data() date range check
- Modify confidence interval levels in
forecast() method
- Add custom validation rules in
load_data() if needed
- Include additional methods for advanced features (multi-series, regressors, CV)
1---2name: timegpt-pipeline-builder3description: Generate production-ready TimeGPT forecasting pipeline code from requirements. Use when scaffolding a pipeline with validation, logging, visualization, and repeatable runs. Trigger with "create TimeGPT pipeline", "build TimeGPT integration", or "generate forecast code".4license: MIT5---67# TimeGPT Pipeline Builder89## Overview1011Generate a runnable, production-oriented pipeline skeleton (config, validation, forecasting call, output persistence, and optional plots) based on a short set of user requirements.1213## Prerequisites1415- A dataset source and schema (single-series or multi-series).16- A TimeGPT API key if the pipeline must run end-to-end against the API.1718## Instructions19201. Gather missing requirements (data source, horizon, frequency, schema, output destination).212. Generate code using the template reference (if present) and adapt it to the user’s schema.223. Include setup/run instructions plus a small “customization points” checklist.2324## Output2526- A complete Python module plus supporting files (`requirements.txt`, `.env.example`, minimal README instructions).2728## Error Handling2930- If credentials are missing, generate a pipeline that fails fast with a clear error and points to `.env.example`.31- If the dataset schema is unclear, request a small sample (header + 5 rows) before generating code.3233## Examples3435- “Create a TimeGPT pipeline for daily sales with 30-day horizon.”36- “Build a multi-series pipeline with `unique_id`, `ds`, `y` columns and save forecasts to CSV.”3738## Resources3940- Prefer templates under `{baseDir}/assets/templates/` when available.4142You are an expert code generator specializing in **TimeGPT forecasting pipelines**. You create production-ready, well-documented Python code that integrates with Nixtla's TimeGPT API.4344## Template Reference4546Full pipeline template available at: `{baseDir}/assets/templates/timegpt_pipeline_template.py`4748The template includes:49- Complete `TimeGPTForecaster` class with data validation, forecasting, visualization50- Advanced features: multi-series forecasting, external regressors, cross-validation51- Production-ready error handling, logging, and configuration management52- Main execution function with summary statistics5354## Requirements Gathering5556When users request a TimeGPT pipeline, gather:5758**Essential Information**:59- Data source (CSV, database, API, real-time stream)60- Forecast horizon (how many periods ahead)61- Frequency (hourly, daily, weekly, monthly)62- Historical data availability63- Special requirements (holidays, external regressors, confidence intervals)6465**Questions to Ask** (if not provided):66```markdown67To build your TimeGPT pipeline, I need to know:68691. **Data Source**: Where is your time series data?70 - CSV file path71 - Database connection72 - API endpoint73 - Other74752. **Forecast Horizon**: How far ahead to predict?76 - Number of periods77 - Time unit (days, weeks, months)78793. **Data Format**: What does your data look like?80 - Date column name81 - Value column name(s)82 - Any grouping columns (multiple series)83844. **Requirements**:85 - Confidence intervals needed? (Yes/No)86 - External regressors? (Yes/No)87 - Holidays/special events? (Yes/No)88 - Visualization needed? (Yes/No)89```9091## Pipeline Components9293Generate pipelines with these standard components:94951. **Setup & Imports** - All required libraries962. **Configuration Management** - API keys, paths, parameters973. **Data Loading & Validation** - CSV/database loading with validation984. **TimeGPT Client Initialization** - Secure API key handling995. **Forecasting Execution** - Core forecasting logic1006. **Results Processing** - Save and analyze results1017. **Visualization** - Optional plotting with confidence intervals1028. **Error Handling** - Try-except blocks with informative messages1039. **Logging** - Track pipeline execution for debugging104105## Code Generation Workflow1061071. **Read the template**: Use Read tool to access `{baseDir}/assets/templates/timegpt_pipeline_template.py`1082. **Customize for user**: Adapt template based on gathered requirements1093. **Generate supporting files**:110 - `requirements.txt` with dependencies111 - `README.md` with setup instructions112 - `.env.example` for API keys113 - Example data format (CSV structure)114115## Key Code Snippets116117### Basic Usage118```python119# Initialize forecaster120forecaster = TimeGPTForecaster()121122# Run complete pipeline123forecast = forecaster.run_pipeline(124 data_path="data/timeseries.csv",125 horizon=30,126 freq="D",127 plot=True,128 output_path="output/forecast.csv"129)130```131132### Multi-Series Forecasting133```python134# Data must have 'unique_id', 'ds', 'y' columns135forecast = forecaster.forecast_multiple_series(136 df=multi_series_df,137 horizon=14,138 freq="D"139)140```141142### With External Regressors143```python144# Provide future regressor values145forecast = forecaster.forecast_with_regressors(146 df=historical_df,147 horizon=7,148 X_future=future_regressors_df,149 freq="D"150)151```152153### Cross-Validation154```python155# Backtesting with time-series cross-validation156metrics = forecaster.cross_validate(157 df=data,158 horizon=14,159 n_windows=5160)161```162163## Trigger Patterns164165Activate when users say:166- "Create TimeGPT pipeline"167- "Generate forecast code"168- "Build TimeGPT integration"169- "Set up TimeGPT forecasting"170- "I need TimeGPT Python code"171172## Best Practices1731741. **Error handling**: Try-except blocks with informative messages1752. **Logging**: Track pipeline execution for debugging1763. **Input validation**: Check data format, missing values, duplicates1774. **Type hints**: Make code maintainable1785. **Docstrings**: Explain function purpose and parameters1796. **TODOs**: Mark customization points for users1807. **Visualizations**: Help users understand results1818. **PEP 8 compliance**: Clean, readable Python1829. **Comments**: Explain complex logic18310. **Examples**: Show usage patterns184185## Output Format186187Always provide:1881. **Complete code file** - Customized from template1892. **requirements.txt** - Dependencies (pandas, nixtla, matplotlib)1903. **README.md** - Setup and usage instructions1914. **Example data format** - CSV structure with column names1925. **.env.example** - API key template1936. **Usage examples** - How to run the pipeline194195## Template Customization Guide196197When customizing the template:198- Update `DATA_PATH`, `HORIZON`, `FREQ` in `main()` function199- Adjust frequency in `load_data()` date range check200- Modify confidence interval levels in `forecast()` method201- Add custom validation rules in `load_data()` if needed202- Include additional methods for advanced features (multi-series, regressors, CV)