Skip to main content

How to Use TabPFN

TabPFN can be used in two ways, depending on your workflow and compute setup. Use the API for our hosted service and for production use. For testing and if you have GPUs, install the open-source package from Hugging Face.
OSS PackageAPI Access
Full control, local inferenceManaged infrastructure, no setup
Requires GPU, Python and PyTorchOnly Internet Access Needed, Python not required
Best for research & experimentationBest for production & teams

OSS Package

Recommended for researchers, ML practitioners, and engineers with GPU availability. TabPFN is available as an open-source Python package on GitHub with the checkpoint for non-commercial use hosted on HuggingFace. It provides the model locally, giving you full control over your data and experimentation.
pip install tabpfn
To get access to the latest features and our TabPFN-2.5 model, please upgrade the package to the latest version:
pip install --upgrade tabpfn

GitHub

Check out our TabPFN open-source GitHub repository.
Use the TabPFNClassifier just like any scikit-learn estimator:
from tabpfn import TabPFNClassifier
model = TabPFNClassifier()
model.fit(X_train, y_train)
preds = model.predict(X_test)
The first time you use the model, you will be asked to accept the model license and configure the access token, see the detailed instructions.
GPU recommended (e.g., NVIDIA T4 at minimum) or A100/H100 for optimal inference speed.

TabPFN API

Recommended 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 and manages GPU compute, scaling, and model versioning. You can use it either through a REST API or the Python SDK.

Using the Python SDK (API Client)

pip install tabpfn-client

GitHub

Check out our tabpfn-client open-source GitHub repository for a detailed getting-started guide and examples.
Instantiate the hosted TabPFNClassifier for API-backed predictions:
from tabpfn_client import TabPFNClassifier

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

# Get predictions
preds = model.predict(X_test)
Authentication
To authenticate you can run a prediction, which will prompt you to sign in if needed. To log in programmatically, follow these steps:
import tabpfn_client
token = tabpfn_client.get_access_token()
To log in on another machine using your access token and skip the interactive flow, use:
tabpfn_client.set_access_token(token)

Using the REST API

You must sign up and generate an API key before making any requests. Requests without valid authentication headers will be rejected. For more information, visit the API Reference.
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, you can 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,
    "params": {
      "output_type": "preds"  # choose 'probas' for returning probabilities
    }
}
files = {
    "data": (None, json.dumps(payload), "application/json"),
    "dataset_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.

Selecting the model version

By default you’ll get the latest TabPFN model. However, you can also specify a particular version. See the details of the available models.

OSS Package

  1. Ensure your installation is up to date: pip install -U tabpfn
  2. Instantiate the classifier or regressor:
from tapfn import TabPFNClassifier, TabPFNRegressor
from tabpfn.constants import ModelVersion

# Set the version of the TabPFNClassifier to 2.5
classifier = TabPFNClassifier.get_default_for_version(ModelVersion.V2_5)

# Set the version of the TabPFNRegressor to 2.5
regressor = TabPFNRegressor.get_default_for_version(ModelVersion.V2_5)

API via Python SDK

  1. Ensure your installation is up to date: pip install -U tabpfn-client
  2. Instantiate the classifier or regressor:
from tabpfn_client.estimator import TabPFNClassifier
from tabpfn_client.constants import ModelVersion

# Set the version of the TabPFNClassifier to 2.5
classifier = TabPFNClassifier.get_default_for_version(ModelVersion.V2_5)
Alternatively, a variety of models can be selected using the model_path option:
from tabpfn_client import TabPFNClassifier

# View the models available
print(TabPFNClassifier().list_available_models())

# Create a classifier or regressor using a particular model
classifier = TabPFNClassifier(model_path="v2.5_real")

API via REST

The model is selected using the model_path argument in the payload. The default model paths are as follows:
TabPFN-2.5TabPFN-2
Classificationtabpfn-v2.5-classifier-v2.5_default.ckpttabpfn-v2-classifier-finetuned-zk73skhh.ckpt
Regressiontabpfn-v2.5-regressor-v2.5_default.ckpttabpfn-v2-regressor.ckpt
For example, the payload to specify the TabPFN-2.5 regression model is
{
	"task": "classification",
	"config": {
    "model_path": "tabpfn-v2.5-regressor-v2.5_default.ckpt"
  }
}
The TabPFN (v1) model is only available through the OSS package, via the tag on GitHub.

FAQ

Have questions? Check out the FAQ for answers to common topics about GPUs, limits, API usage, and more.