timesfm-ts - v1.0.0
    Preparing search index...

    Public interface for TimesFMModel.

    Enables dependency injection and testing while maintaining a stable contract.

    Implements

    Index

    Accessors

    Methods

    • Create a TimesFM model from a pretrained ONNX checkpoint.

      The model architecture is resolved from the model-descriptor.json co-located with the ONNX file. When no descriptor is found, the engine falls back to the canonical TimesFM 2.5 200M config.

      Parameters

      • options: ModelLoadOptions
        • modelPath: string

          Path to ONNX model file. Required.

        • OptionalexecutionProvider?: "cpu" | "cuda" | "dml"

          Execution provider: 'cpu' | 'cuda' | 'dml' (default 'cpu').

        • Optionalprecision?: ModelPrecision

          Hint for which precision variant to load. The engine itself does not branch on precision — ONNX Runtime transparently executes QDQ (INT8) graphs. This field is informational metadata forwarded from the model descriptor for logging and diagnostics.

        • Optionalengine?: IInferenceEngine

          Optional pre-built inference engine for dependency injection.

          When provided, the engine is used as-is (already loaded). When omitted, @agentix-e/timesfm-node is dynamically imported to create the default engine. Install @agentix-e/timesfm-node for the Node.js ONNX Runtime backend,

          Web use case: Pass a TimesFMWebInferenceEngine from @agentix-e/timesfm-web to run TimesFM in the browser with onnxruntime-web.

          Testing use case: Inject a mock engine for isolated unit testing.

          import { TimesFMWebInferenceEngine } from '@agentix-e/timesfm-web';

          const webEngine = new TimesFMWebInferenceEngine(modelConfig);
          await webEngine.load('https://example.com/timesfm-2.5.onnx');

          const model = await TimesFMModel.fromPretrained({
          modelPath: 'https://example.com/timesfm-2.5.onnx',
          engine: webEngine,
          });
        • OptionalcacheDir?: string

          Custom cache directory for downloaded models.

        • Optionalproxy?: { url: string; username?: string; password?: string }

          Proxy configuration for model download in restricted network environments.

          IMPORTANT: This field is forwarded to downloadModel only when called explicitly. fromPretrained() itself does not download models — it requires an existing modelPath. If you use the separate downloadModel() function to obtain the model before calling fromPretrained(), pass your proxy config directly to downloadModel().

          import { downloadModel, TimesFMModel } from '@agentix-e/timesfm-core';

          const modelPath = await downloadModel({
          proxy: { url: 'http://proxy:8080', username: 'user', password: 'pass' },
          });
          const model = await TimesFMModel.fromPretrained({ modelPath });

          Priority: this option → TIMESFM_PROXY_URL env var → HTTPS_PROXY env var.

          For security, prefer passing the password via the TIMESFM_PROXY_PASSWORD environment variable instead of embedding it in this config object. The password field is accepted as a convenience for programmatic use but will NOT be logged or serialized.

        • OptionalskipWarmup?: boolean

          When true, the warmup inference (triggered during load()) is skipped.

          This is intended for benchmarking where the caller wants to measure the true cold-start (first-inference) latency separately. Production callers should leave this at the default (false) so that the first user-facing forecast() call benefits from JIT-compiled execution plans.

        • OptionalintraOpNumThreads?: number

          Number of threads for intra-op parallelism in ONNX Runtime.

          Controls intraOpNumThreads in the ONNX Runtime session options. Set to 0 to let ONNX Runtime auto-detect (default). Higher values improve throughput on multi-core CPUs but increase memory usage.

          Recommendations:

          • 0 (auto-detect): suitable for most workloads
          • number of physical cores: max throughput for batch inference
          • 1: minimum latency, deterministic execution
          const model = await TimesFMModel.fromPretrained({
          modelPath: './timesfm-2.5.onnx',
          intraOpNumThreads: 4, // use 4 threads
          });

      Returns Promise<TimesFMModel>

      if modelPath is not provided or the file doesn't exist.

    • Forecast a batch of univariate time series.

      Parameters

      • horizon: number

        Number of future time points to forecast.

      • inputs: Float32Array<ArrayBufferLike>[]

        List of 1-D time series. Each can have different length. May contain NaN values (leading NaNs are stripped, internal NaNs are linearly interpolated).

      • Optionaloptions: ForecastCallOptions

        Optional AbortSignal and progress callback.

      Returns Promise<ForecastOutput>

      Point forecasts + quantile forecasts.

      if the model has not been compiled.

      AbortError if the operation was cancelled.