# Submit now, collect later with async jobs in TimeGPT

Canonical: https://www.nixtla.io/blog/timegpt-async-jobs
Published: 2026-12-01

Fine-tuning TimeGPT on a few hundred series is often the step that moves accuracy the most. It is also the step most likely to outgrow a single API request. A synchronous call has a fixed amount of time to return, and a deep fine-tune over a large panel can take longer than that.

The Nixtla client is the open-source Python library you use to call TimeGPT. Version 0.9.0 adds **asynchronous jobs** for exactly this case. Instead of holding one request open until the work is done, you submit the work, get a handle back right away, and collect the result when it's ready. 

Fine-tuning is where jobs matter most, because a fine-tune can't be split into smaller requests the way a forecast can. But any long call can run as a job (see the full list below). A job can run for up to 5 minutes by default, about twice what a single request allows.

## The problem: one request, one time limit

To make this concrete with an example, we use the M4 hourly benchmark: 414 hourly series, each between 748 and 1,008 observations long.

```python
import pandas as pd
from nixtla import NixtlaClient

client = NixtlaClient()  # reads NIXTLA_API_KEY from the environment

df = pd.read_parquet("https://datasets-nixtla.s3.amazonaws.com/m4-hourly.parquet")
df.head()
```

| unique_id | ds | y |
|:----------|---:|----:|
| H1 | 1 | 605 |
| H1 | 2 | 586 |
| H1 | 3 | 586 |
| H1 | 4 | 559 |
| H1 | 5 | 511 |

We fine-tune TimeGPT on all 414 series with 1,500 steps at the deepest fine-tuning depth:

```python
client.finetune(df=df, freq=1, finetune_steps=1500, finetune_depth=5)
```

With the client's default settings, this call gives up after 60 seconds, retries, and eventually raises a `ReadTimeout`. Raising the client timeout only moves the failure to the server, which ends the request when it reaches the synchronous limit. In our run, that was after 148 seconds:

```bash
ApiError: status_code: 504, body: {'detail': 'The request timed out. Please try again, or reduce the number of series or the forecasting horizon and retry.', ...}
```

Until now, the options were to shrink the problem: fewer series, fewer fine-tuning steps, or a shallower depth. Each one trades away accuracy you were trying to buy.

## The fix: submit a job, collect the result

Every long-running method now has a counterpart under `client.jobs` that takes the same arguments as the blocking method, apart from `num_partitions`, and adds an optional `job_timeout_seconds` (covered below). For most calls, moving over is a one-word change:

```python
job = client.jobs.finetune(df=df, freq=1, finetune_steps=1500, finetune_depth=5)

print(job.job_id)
print(job.status)
```

```bash
ft-7521f90a71a24061b0f42d4aa1aa5f6b
JobStatus.PENDING
```

The call returns as soon as the server accepts the work. Inputs are still validated locally first, so a malformed DataFrame fails immediately rather than producing a job that fails later.

When you need the result, `wait()` polls until the job finishes and returns exactly what the blocking method would have returned. For `finetune()`, that is the ID of the fine-tuned model:

```python
model_id = job.wait()
```

```bash
5f96f56b-e037-45d4-96fe-414509ca9d46
```

This job took 193 seconds: comfortably past the synchronous limit, and well within what a job is allowed to run. The model is then used like any other fine-tuned model:

```python
fcst = client.forecast(df=df, h=48, freq=1, finetuned_model_id=model_id)
fcst.head()
```

| unique_id | ds | TimeGPT |
|:----------|---:|--------:|
| H1 | 749 | 620.97 |
| H1 | 750 | 566.82 |
| H1 | 751 | 521.24 |
| H1 | 752 | 490.38 |
| H1 | 753 | 464.39 |

Six methods are available as jobs:

| Job method | Mirrors | `wait()` returns |
|:---|:---|:---|
| `jobs.forecast()` | `forecast()` | Forecasts as a DataFrame |
| `jobs.cross_validation()` | `cross_validation()` | Cross-validation results as a DataFrame |
| `jobs.finetune()` | `finetune()` | The fine-tuned model ID |
| `jobs.detect_anomalies()` | `detect_anomalies_online()` | Anomalies as a DataFrame |
| `jobs.simulate()` | `simulate()` | Sample paths as a DataFrame |
| `jobs.explain()` | `explain()` | Feature weights as a DataFrame |

Forecast, simulate, and explain are available only on dedicated deployments.

The rest of this post covers three things you'll want to do as soon as you start using jobs: run several at once, cap how long they take, and cancel the ones you no longer need.

## Three ways to use async jobs
### Run several jobs at once

Submitting does not block, so independent work can run side by side. Here, a fine-tune and a cross-validation of the base model run at the same time:

```python
jobs = {
    "finetune": client.jobs.finetune(df=df, freq=1, finetune_steps=1500, finetune_depth=5),
    "cross_validation": client.jobs.cross_validation(df=df, h=48, freq=1, n_windows=3),
}

for name, job in jobs.items():
    print(f"{name}: {job.job_id}")

results = {name: job.wait() for name, job in jobs.items()}
```

```bash
finetune: ft-91d2e49b368f47d496c8ac578f1242be
cross_validation: cv-63773a2a2f414f4d8365b95e85cd749e
```

Both results were ready 195 seconds later, about the time the fine-tune needs on its own. The cross-validation ran in the shadow of the longer job instead of after it:

```python
results["cross_validation"].head()
```

| unique_id | ds | cutoff | y | TimeGPT |
|:----------|---:|-------:|----:|--------:|
| H1 | 605 | 604 | 622 | 610.31 |
| H1 | 606 | 604 | 558 | 553.39 |
| H1 | 607 | 604 | 513 | 507.89 |
| H1 | 608 | 604 | 476 | 475.07 |
| H1 | 609 | 604 | 449 | 453.27 |

A team can have a limited number of jobs pending or running at once, so a submission beyond that limit is rejected with HTTP 429. The client retries it for you (`max_retries`, `retry_interval`) and raises `ApiError` only if the limit doesn't free up in time, so very large batches are still better submitted in waves.

### Cap how long a job can take

Two separate clocks apply to a job, and it pays to keep them apart:

- **`job_timeout_seconds`**, set at submission, caps how long the **server** may spend on the job. It defaults to your deployment's per-task limit and cannot exceed it.
- **`poll_timeout`**, set on `wait()`, caps how long **your code** waits for an answer. It defaults to one hour.

Each one fails in its own way, so you can handle them separately:

```python
from nixtla import JobError, JobTimeoutError

job = client.jobs.finetune(
    df=df, freq=1, finetune_steps=1500, finetune_depth=5, job_timeout_seconds=60
)

try:
    model_id = job.wait(poll_timeout=600)
except JobError as e:
    print(f"the job failed: {e}")
except JobTimeoutError as e:
    print(f"gave up waiting: {e}")
```

```bash
the job failed: finetune job 'ft-eb4a55a187164cb8abf6675360a35184' failed: SandboxTimeoutError: Application error
```

Our 60-second budget was too small for this fine-tune, so the server stopped it. The job's status is `failed`, and `wait()` raised `JobError` carrying the server's reason. If instead `poll_timeout` had run out first, you would get `JobTimeoutError`. By default, giving up also cancels the job so it stops using compute; pass `cancel_on_timeout=False` to leave it running and call `wait()` again later.

Asking for more time than your deployment allows fails at submission, before any work starts:

```python
client.jobs.finetune(df=df, freq=1, job_timeout_seconds=900)
```

```bash
ApiError: status_code: 422, body: {'detail': 'Requested timeout_seconds=900 exceeds the maximum allowed for this task (300s).', ...}
```

The error message tells you the exact limit for that task on your deployment. If you're on a dedicated deployment and your workloads need a longer timeout, let our team know and we'll update it accordingly.

### Cancel what you no longer need

A job keeps running on the server even if your script stops caring about it. When you no longer need the result, cancel the job:

```python
from nixtla import JobCancelledError

job = client.jobs.finetune(df=df, freq=1, finetune_steps=1500, finetune_depth=5)
job.cancel()

try:
    job.wait()
except JobCancelledError as e:
    print(e)
```

```bash
job_id: ft-8f2f4b0417f4464f8fb5e8f7ac44ae6b was cancelled
```

Remembering to call `cancel()` on every error path is tedious, so a job also works as a context manager. If an exception leaves the block while the job is still running, including a Ctrl-C, the job is cancelled for you:

```python
with client.jobs.finetune(df=df, freq=1, finetune_steps=1500, finetune_depth=5) as job:
    model_id = job.wait()
```

When we raised a `KeyboardInterrupt` inside a block like this one, the job reported `cancelled` within seconds. A block that exits normally cancels nothing.

## When to use jobs, and when not to

Jobs are not instant. Each one is scheduled onto its own worker, which adds startup time. In our tests, small requests that returned in one to three seconds as blocking calls took roughly 20 to 45 seconds as jobs. That gives a simple rule:

| Your workload | Use |
|:---|:---|
| Finishes well within a single request | The blocking method. It is faster and simpler. |
| Takes longer than a single request allows | `client.jobs`. This is what jobs are for. |
| Would exceed the job limit too | The blocking method with `num_partitions` (see below). |
| Needs to run alongside other work, or be cancellable | `client.jobs`, even for medium-sized work. |

`num_partitions` splits one large request into several smaller ones. It is available on the blocking `forecast()`, `cross_validation()`, `detect_anomalies_online()` and `simulate()`, but not on jobs. `finetune()` has no partitioned path, so a fine-tune that outgrows the job limit needs fewer steps or a shallower depth.

## Get started

Asynchronous jobs are available from Nixtla client 0.9.0:

```bash
pip install -U nixtla
```

The [asynchronous jobs guide](https://www.nixtla.io/docs/jobs/asynchronous_jobs) walks through every option step by step, and the [SDK reference](https://www.nixtla.io/docs/reference/sdk_reference) lists the full signatures of `Job`, `JobStatus`, and the error types.

If you hit a limit or a behavior we did not cover here, let us know on [GitHub](https://github.com/Nixtla/nixtla/issues). Five minutes is where we started, so if it's too short for your workloads, tell us.
