# Use of Model Adapters in Pipeline Builder

**URL:** <https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748>\
**Category:** Ask the Community\
**Tags:** modeling, pipeline-builder\
**Created:** [July 17, 2024, 9:18am UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748 "2024-07-17T09:18:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![9eab477d6eb76c06c4f6](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/9eab477d6eb76c06c4f6/32/7919_2.png) [@9eab477d6eb76c06c4f6](https://community.palantir.com/u/9eab477d6eb76c06c4f6)\
**Post date:** [July 17, 2024, 9:18am UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/1 "2024-07-17T09:18:27Z")

</div>

Hello,

Following a question I previously raised in SO:  
[palantir foundry - How to use a Model Adapter in a User Defined Functions (UDF) for Pipeline Builder - Stack Overflow](https://stackoverflow.com/questions/78325988/how-to-use-a-model-adapter-in-a-user-defined-functions-udf-for-pipeline-builde).

With the new Python UDF functions, we would like to know if it would be possible to use a [Model Adapter API](https://www.palantir.com/docs/foundry/integrate-models/model-adapter-api/) within a UDF in order to infer all the rows of input data ?

Best regards,

---

<div class="post-metadata">

**Author:** ![tucker](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@tucker](https://community.palantir.com/u/tucker)\
**Post date:** [July 17, 2024, 3:38pm UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/2 "2024-07-17T15:38:38Z")

</div>

Hi! Welcome to the Palantir Developer Community!

As of now, model assets are not supported in Pipeline Builder. We definitely want to build an integration, however we do not have any concrete timelines at this time.

As the stack overflow answer suggests, you can use a [python transform](https://www.palantir.com/docs/foundry/integrate-models/model-asset-code-repositories/#run-inference-in-python-transforms) or [batch deployment](https://www.palantir.com/docs/foundry/manage-models/set-up-batch/) to create a dataset of model predictions and then use those in your pipeline.

---

<div class="post-metadata">

**Author:** ![9eab477d6eb76c06c4f6](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/9eab477d6eb76c06c4f6/32/7919_2.png) [@9eab477d6eb76c06c4f6](https://community.palantir.com/u/9eab477d6eb76c06c4f6)\
**Post date:** [August 2, 2024, 7:10am UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/3 "2024-08-02T07:10:53Z")

</div>

Hello Tucker,

Thank you for your reply and will look forward for this implementation.

Slightly related to this topic but from Workshop module, what would be the way to infer a Live deployed model from Workshop ?  
Does using Typescript or Python function with an API call to the model endpoint would work ? (It does work in Slate.)

Best regards,

---

<div class="post-metadata">

**Author:** ![nicornk](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/nicornk/32/192_2.png) [@nicornk](https://community.palantir.com/u/nicornk)\
**Post date:** [August 2, 2024, 7:08pm UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/4 "2024-08-02T19:08:16Z")

</div>

This should work out of the box

https://palantir.com/docs/foundry/functions/functions-on-models/

---

<div class="post-metadata">

**Author:** ![9eab477d6eb76c06c4f6](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/9eab477d6eb76c06c4f6/32/7919_2.png) [@9eab477d6eb76c06c4f6](https://community.palantir.com/u/9eab477d6eb76c06c4f6)\
**Post date:** [May 5, 2025, 1:39pm UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/5 "2025-05-05T13:39:38Z")

</div>

Hello,

I would like to follow-up on this feature. Is there any update on:

- Using a Model Asset in Pipeline builder via a UDF?
- Using a registered model (not Palantir provided - externally hosted) via a UDF?

Cheers,

---

<div class="post-metadata">

**Author:** ![tucker](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@tucker](https://community.palantir.com/u/tucker)\
**Post date:** [May 5, 2025, 2:07pm UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/6 "2025-05-05T14:07:01Z")

</div>

It depends on what type of model you want to use.

If you want to use an LLM you can register the LLM in Foundry, which makes it available in the same manner that Palantir provided models are (easy use in Pipeline Builder, AIP Logic, etc). See docs about that here [https://www.palantir.com/docs/foundry/administration/bring-your-own-model](https://www.palantir.com/docs/foundry/administration/bring-your-own-model).

If your model is not an LLM and you want to call from Pipeline Builder you can use a [Python function as a UDF](https://www.palantir.com/docs/foundry/functions/python-functions-builder) in Pipeline Builder, and inside the function you can call the model.

Calling the model from a python function isnt the easiest thing, you need to [register the model as function](https://www.palantir.com/docs/foundry/manage-models/direct-function-publishing/), and then use the platform SDK to call the model.

In the below example, I have a model that is registered with the api name `com.foundryfrontend.models.TitanicModel2`:

```python
import foundry
from functions.api import function
from foundry.v2 import FoundryClient
from foundry_sdk_runtime import FOUNDRY_HOSTNAME, FOUNDRY_TOKEN

TITANIC_MODEL = "com.foundryfrontend.models.TitanicModel2"

@function
def execute_titanic_model(age: int, gender: str) -> str:
    client = FoundryClient(
        auth=foundry.UserTokenAuth(hostname=FOUNDRY_HOSTNAME.get(), token=FOUNDRY_TOKEN.get()),
        hostname=FOUNDRY_HOSTNAME.get(),
    )
    result = client.functions.Query.execute(
        TITANIC_MODEL,
        parameters={"age": age, "gender": gender},
        preview=True,
    )

    if result.value:
        return "The person is predicted to survive"
    else:
        return "The person is predicted to NOT survive"

```

You’ll have to change the code to make it work for your use case

---

<div class="post-metadata">

**Author:** ![9eab477d6eb76c06c4f6](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/9eab477d6eb76c06c4f6/32/7919_2.png) [@9eab477d6eb76c06c4f6](https://community.palantir.com/u/9eab477d6eb76c06c4f6)\
**Post date:** [July 7, 2025, 8:50am UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/7 "2025-07-07T08:50:39Z")

</div>

Hello Tucker,

The provided code snippet is working well in preview from Code Repository, I manage to get my results back from the model.  
However, when calling the UDF from Pipeline Builder, I am having an APIUsageDenied in Preview and another error in build.

```auto
 Failed to call udf for recoverable error: {transformId=ri.function-registry.main.function.08b46bac-78f7-4ce7-a2b6-91d91ac67af7, transformVersion=Version{major: 0, minor: OptionalInt[0], patch: OptionalInt[2], preReleaseIdentifier: Optional.empty, semanticVersionRange: Optional.empty}, transformName=ModelAsset_model, batchFailedResult={result={type=runtimeError, runtimeError={message=PermissionDeniedError: {
    "errorCode": "PERMISSION_DENIED",
    "errorInstanceId": "edc07d65-5ff4-4a74-9ee2-2c0212213715",
    "errorName": "ApiUsageDenied",
    "parameters": {
        "missingScope": "api:usage:functions-read"
    }

```

In build:

```auto
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.util.concurrent.ExecutionException: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 7) (localhost executor driver): org.apache.spark.SparkException: [TASK_WRITE_FAILED] Task failed while writing rows to foundry://my_hostname.com/datasets/ri.foundry.main.dataset.772dxxxx/views/ri.foundry.main.transaction.0000xxxxx/startTransactionRid/ri.foundry.main.transaction.0000xxxxxf/files/spark."

[...]

  File "/app/var/cache/yorw9IXjpm2/lib/python3.9/site-packages/foundry_sdk/v2/functions/query.py", line 46, in __init__
    self._api_client = core.ApiClient(auth=auth, hostname=hostname, config=config)
  File "/app/var/cache/yorw9IXjpm2/lib/python3.9/site-packages/foundry_sdk/_core/api_client.py", line 344, in __init__
    assert_non_empty_string(hostname, "hostname")
  File "/app/var/cache/yorw9IXjpm2/lib/python3.9/site-packages/foundry_sdk/_core/utils.py", line 120, in assert_non_empty_string
    raise TypeError(f"The {name} must be a string, not {type(value)}.")
TypeError: The hostname must be a string, not <class 'NoneType'>.
, parameters={}}}, index=0}}

```

So it looks like the hostname could be malformated when using hostname=FOUNDRY\_HOSTNAME.get() ?

---

<div class="post-metadata">

**Author:** ![sasraf](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@sasraf](https://community.palantir.com/u/sasraf)\
**Post date:** [April 2, 2026, 3:41pm UTC](https://community.palantir.com/t/use-of-model-adapters-in-pipeline-builder/748/8 "2026-04-02T15:41:57Z")

</div>

Hey there!

Just wanted to update this thread with some new information. Model adapters are now officially supported in Pipeline Builder through a first-class and easy-to-use Trained Model node.

For more details, refer to the docs here: [https://www.palantir.com/docs/foundry/pipeline-builder/transforms-trained-model](https://www.palantir.com/docs/foundry/pipeline-builder/transforms-trained-model)
