Author models in TypeScript

Sunsetted functionality

The below documentation describes the foundry_ml library which is no longer recommended for use in the platform. Instead, use the palantir_models library. You can also learn how to migrate a model from the foundry_ml to the palantir_models framework through an example.

The foundry_ml library will be removed on October 31, 2025, corresponding with the planned deprecation of Python 3.9.

Warning

Models that are backed by Functions can only be deployed to Live deployments, which may not be enabled in your environment by default. Contact your Palantir representative to have this functionality enabled.

Functions can be submitted to modeling objectives and can be fully managed and deployed as models. This allows you to:

  • Power your operational applications with TypeScript-function-backed models in conjunction with Scenarios.
  • Use objectives to govern and manage CI/CD of functions to critical applications.
  • Set up the rails to facilitate an eventual transition of Live endpoints and applications from TypeScript business logic to feedback-driven machine learning.

Writing an objective-compatible Function

There are a few requirements for a Function to be compatible with modeling objectives:

  1. Your Function must be annotated with the @ModelFunction decorator. Ensure that enableModelFunction is set to true in the functions.json file in your Function repository.

Enable model function decorator

  1. Your Function's inputs must only include scalar types or collection types.
  2. Your Function's output spec must be a custom type that only contains fields with scalar or collection types.
  3. Your Function must be successfully published.

See below for an example Function signature that would be compatible with modeling objectives.

Copied!
1 2 3 4 5 6 import { Integer, ModelFunction, String } from "@foundry/functions-api"; @ModelFunction() public myFunction(input1: Integer, input2: String): { output1: String } { ... }

After authoring your model, you can submit it to an objective.

If you plan on submitting a Function to an objective that has an objective API, the parameter names must match exactly. In the example snippet above, that would mean input1 and input2 are defined as your objective inputs and output1 is defined as your objective output.