Metadata-Version: 2.3
Name: tsfm-client
Version: 0.1.0
Summary: Python client library for TSFM Inference Platform
License: MIT
Keywords: time-series,forecasting,foundation-models,api-client
Author: Andrei Chernov
Author-email: chernov.andrey.998@gmail.com
Requires-Python: >=3.8
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Dist: httpx (>=0.25.0,<0.26.0)
Requires-Dist: numpy (>=1.24.0,<2.0.0)
Requires-Dist: pandas (>=2.0.0,<3.0.0)
Requires-Dist: pydantic (>=2.5.0,<3.0.0)
Requires-Dist: typing-extensions (>=4.8.0,<5.0.0)
Project-URL: Homepage, https://github.com/S-FM/tsfm-python-client
Project-URL: Repository, https://github.com/S-FM/tsfm-python-client
Description-Content-Type: text/markdown

# TSFM Python Client

A simple Python client for the TSFM (Time Series Foundation Model) Inference Platform.

## Installation

```bash
git clone git@github.com:S-FM/tsfm-python-client.git
cd tsfm-python-client
poetry install
```

## Quick Start

### 1. Set up your API key

```bash
export TSFM_API_KEY="your_api_key_here"
```

### 2. Make predictions

```python
from tsfm_client import predict

# Simple prediction
data = [10, 12, 13, 15, 17, 16, 18, 20, 22, 25]
response = predict(data=data, forecast_horizon=5)
print(f"Forecast: {response.forecast}")
```

## Supported Models

- **chronos-t5-small**: Fast CPU inference for time series forecasting

## API Reference

### predict() function

```python
predict(
    data: Union[List[float], pd.Series, TimeSeriesData],
    model: str = "chronos-t5-small",
    forecast_horizon: int = 12,
    confidence_intervals: bool = False,
    base_url: str = "http://localhost:8000"
) -> PredictionResponse
```

### TSFMClient class

```python
from tsfm_client import TSFMClient

client = TSFMClient()  # Uses TSFM_API_KEY environment variable

# Make predictions
response = client.predict(data=[1, 2, 3, 4, 5], forecast_horizon=3)

# List models
models = client.list_models()

# Get model info
info = client.get_model_info("chronos-t5-small")

# Health check
health = client.health_check()

client.close()
```

## Examples

### With Pandas

```python
import pandas as pd
from tsfm_client import predict

# Create time series data
dates = pd.date_range('2024-01-01', periods=30, freq='D')
ts_data = pd.Series([100, 102, 98, 105, 107, ...], index=dates)

# Make prediction
response = predict(
    data=ts_data,
    forecast_horizon=7,
    confidence_intervals=True
)
```

### Using Context Manager

```python
from tsfm_client import TSFMClient

with TSFMClient() as client:
    response = client.predict(data=[1, 2, 3, 4, 5])
    print(f"Forecast: {response.forecast}")
```

### Error Handling

```python
from tsfm_client import TSFMClient, AuthenticationError, APIError

try:
    client = TSFMClient()
    response = client.predict(data=[1, 2, 3])
except AuthenticationError:
    print("Invalid API key")
except APIError as e:
    print(f"API error: {e}")
```

## Response Format

```python
class PredictionResponse:
    model_name: str
    forecast: List[float]
    confidence_intervals: Optional[Dict]
    metadata: Dict[str, Any]
```

## Requirements

- Python >= 3.11
- Valid TSFM API key
- Running TSFM server

