Skip to main content

How to Use TabPFN

TabPFN can be used in two ways - depending on your workflow and compute setup. Whether you’re experimenting locally, integrating into a pipeline, or deploying at scale, there’s a path that fits.

1. Open Source Package

Best for: researchers, ML practitioners, and engineers with local GPU or cluster access. TabPFN is available as an open-source Python package on GitHub. It provides the full model locally, giving you complete control over inference and experimentation.
pip install tabpfn
from tabpfn import TabPFNClassifier

model = TabPFNClassifier()
model.fit(X_train, y_train)
preds = model.predict(X_test)
GPU recommended (e.g., NVIDIA T4 at minimum) or A100/H100 for optimal inference speed.

2. TabPFN API

Best for: data teams and developers who want TabPFN’s performance without managing infrastructure. The Prior Labs API provides cloud-hosted access to TabPFN-2.5 - we handle all GPU compute, scaling, and model versioning. You can use it either through a REST API or our Python SDK.
You must sign up and generate an API key before making any requests. Requests without valid authentication headers will be rejected.

Using the REST API

First, define your dataset paths and authentication details. This allows you to reuse them across fit and predict calls.
import os, json, requests

# Define your file paths
train_path = "train.csv"   # path to your training dataset
test_path = "test.csv"     # path to your test dataset

# Get your API key from the environment
api_key = os.getenv("PRIORLABS_API_KEY")

headers = {"Authorization": f"Bearer {api_key}"}
Next, upload your training dataset to the /v1/fit endpoint. The API automatically preprocesses the data.
payload = {"task": "classification"}

files = {
    "data": (None, json.dumps(payload), "application/json"),
    "dataset_file": (train_path, open(train_path, "rb")),
}

fit_response = requests.post(
    "https://api.priorlabs.ai/v1/fit",
    headers=headers,
    files=files,
)

model_id = fit_response.json().get("model_id")
print(f"✅ Model trained: {model_id}")
Once fitted your model using in-context learning, send your test dataset to the /v1/predict endpoint using the returned model_id. You’ll receive predictions and/or probabilities in JSON format.
payload = {
    "task": "classification",
    "model_id": model_id,
}

files = {
    "data": (None, json.dumps(payload), "application/json"),
    "file": (test_path, open(test_path, "rb")),
}

predict_response = requests.post(
    "https://api.priorlabs.ai/v1/predict",
    headers=headers,
    files=files,
)

print("✅ Predictions:")
print(json.dumps(predict_response.json(), indent=2))

API Reference

You can follow the step-by-step onboarding instructions in the API Reference, which also includes detailed endpoint descriptions and authentication examples.

Using the Python SDK

import tabpfn_client
from tabpfn_client import TabPFNClassifier, TabPFNRegressor

# Authenticate using your Prior Labs token
tabpfn_client.set_access_token("YOUR_API_KEY")

# Use TabPFN like any scikit-learn model
model = TabPFNClassifier()
model.fit(X_train, y_train)

# Get predictions
preds = model.predict(X_test)
I