MCPcopy Create free account
hub / github.com/PriorLabs/tabpfn-client

github.com/PriorLabs/tabpfn-client @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
508 symbols 1,864 edges 36 files ⚖ Apache-2.0 125 documented · 25% ● updated 7d agov0.10.1 · 2026-11-20★ 2571 open issues

Browse by type

⨍ Functions 396◇ Types & classes 81↳ Endpoints 31
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TabPFN Client

PyPI version Discord colab Documentation Twitter Follow License Python Versions Last Commit

TabPFN is a foundation model for tabular data that outperforms traditional methods while being dramatically faster. This client library provides easy access to the TabPFN API, enabling state-of-the-art tabular machine learning in just a few lines of code.

Interactive Notebook Tutorial

[!TIP]

Dive right in with our interactive Colab notebook! It's the best way to get a hands-on feel for TabPFN, walking you through installation, classification, and regression examples.

Open In Colab

Stable Release

This API is now in a stable release. It has been extensively tested and is used across multiple use cases. While we continue to make improvements, the core service is reliable for day-to-day use. Please reach out to us if you encounter any stability issues.

This is a cloud-based service: your data will be sent to our servers for processing.

Please only upload data you have permission to share, and avoid sensitive, confidential, or personally identifiable information. Consider anonymizing or pseudonymizing your data in line with your organization’s policies.

TabPFN Ecosystem

Choose the right TabPFN implementation for your needs:

  • TabPFN Client (this repo): Easy-to-use API client for cloud-based inference
  • TabPFN Extensions: Community extensions and integrations
  • TabPFN: Core implementation for local deployment and research
  • TabPFN UX: No-code TabPFN usage

Quick Start

Installation

pip install --upgrade tabpfn-client

Basic Usage

Set a token first — fit() raises without one and never prompts. Generate it at platform.priorlabs.ai/account/api-keys:

export TABPFN_TOKEN="<your-token>"

See Authentication for the alternatives.

from tabpfn_client import init, TabPFNClassifier, TabPFNRegressor
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

# Load an example dataset

X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.5, random_state=42
)

# Use it like any sklearn model
model = TabPFNClassifier()
model.fit(X_train, y_train)
# Get predictions
predictions = model.predict(X_test)
# Get probability estimates
probabilities = model.predict_proba(X_test)

Model Versions

Leaving model_path unset lets the server pick the current default model. To pin a model version, use create_default_for_version(); list_available_models() lists the accepted model_path names.

from tabpfn_client import TabPFNClassifier
from tabpfn_client.constants import ModelVersion

model = TabPFNClassifier.create_default_for_version(ModelVersion.V3_5)

TabPFN v4 is available and selectable: use create_default_for_version(ModelVersion.V4) (or "v4"), or model_path="v4_default". Leaving model_path unset still selects the current default model. v4 does not support thinking mode yet.

Thinking Mode

Thinking mode trades extra fit-time compute for higher predictive quality. The server explores additional configurations during fit() and returns a tuned model; predict() then runs as usual.

from tabpfn_client import TabPFNClassifier

# Simplest form: enable with defaults (effort="medium").
model = TabPFNClassifier(thinking_mode=True)
model.fit(X_train, y_train)
model.predict(X_test)

Knobs:

  • thinking_mode: bool = False — enable thinking with default effort. Equivalent to thinking_effort="medium".
  • thinking_effort: {"micro", "mini", "low", "medium", "high", "xhigh", "max"} | None — effort level, from least to most compute. Setting this also enables thinking, so thinking_mode=True is optional when you've set the level explicitly. Levels other than "medium" and "high" are not available to every account; the server rejects a level your account cannot use.
  • thinking_timeout_s: float | None — time limit for the fit, in seconds. Only consulted when thinking is enabled. Each effort level has a maximum; the server rejects a longer value.
  • thinking_metric: str | None — optimization metric for the fit. Only consulted when thinking is enabled. See the constructor docstring of TabPFNClassifier / TabPFNRegressor for the full list of supported metrics per task (classification, multiclass, regression) and their aliases.
  • group_col: str | list[str] | None — column(s) of X identifying groups of related rows, e.g. a patient or session id. The model replaces them with one categorical feature for the group. In thinking mode, rows of one group are also never split between training and validation during the fit. Also works without thinking mode.
  • time_col: str | None — column of X holding time. Validation uses contiguous time blocks. Cannot be combined with group_col. Thinking mode only.
  • group_time_col: str | None — column of X ordering the rows within a group. Requires group_col. Thinking mode only.
model = TabPFNClassifier(
    thinking_effort="high",
    thinking_timeout_s=600,
    thinking_metric="roc_auc",
)

# Grouped data: X_train and X_test are DataFrames that keep the named columns.
model = TabPFNClassifier(thinking_mode=True, group_col="patient_id")
model.fit(X_train, y_train)
model.predict_proba(X_test)

Notes:

  • Thinking mode is only supported on v3 models. Leave model_path at its default ("auto", which lets the server pick the latest default — currently a v3 model) or set it explicitly to a v3 model. Combining thinking with a v2 or v2.5 model_path raises ValueError client-side.
  • thinking_timeout_s and thinking_metric are only consulted when thinking is enabled; passing them without thinking_mode=True or thinking_effort=... raises ValueError.
  • Thinking-mode fits take longer than regular fits (often several minutes).
  • Thinking-mode fits draw from a separate, smaller budget than regular fits — they do not count against your regular prediction allowance, and you cannot use your regular allowance for them. The number of thinking-mode fits you can run per day is limited. If you need more capacity, request an increase via platform.priorlabs.ai.

KV Cache

fit_mode="fit_with_cache" caches the fit so repeated predictions against it are faster. Use it when you fit once and predict many times.

from tabpfn_client import TabPFNRegressor

model = TabPFNRegressor(fit_mode="fit_with_cache")
model.fit(X_train, y_train)

model.predict(X_test)  # served from the cache built during fit()
model.predict(X_other)

fit() records the id of the fitted model as model_id_. To predict against the same fit from another process or machine, save the estimator and load it there — see Saving and Loading Fitted Models.

Notes:

  • fit_mode accepts "fit_preprocessors" (the default) or "fit_with_cache".
  • Predictions are the same either way — caching changes the speed, not the model.
  • Not compatible with thinking mode.

Saving and Loading Fitted Models

A fit lives on the TabPFN server, so a fitted estimator can be saved without its training data and loaded in a later run — or on another machine — to predict without fitting again. This pays off most when the fit was expensive (thinking mode) or when you predict many times against one fit (fit_mode="fit_with_cache").

from tabpfn_client import TabPFNClassifier

model = TabPFNClassifier(thinking_mode=True)
model.fit(X_train, y_train)
model.save_model("model.json")

# In a later run:
model = TabPFNClassifier.load_model("model.json")
model.predict(X_test)

save_model() writes a small JSON record: the id of the fitted model, the hyperparameters, the class labels and the training-set size, and whether the fit or a prediction is still pending. It leaves out api_mode and client_options, which describe how the client talks to the server: a loaded model uses those of the process that loads it. save_model() also returns that record as a dict, so it can be kept elsewhere (a database, an experiment tracker) and passed to load_model() directly.

Notes:

  • The loading process must authenticate with the account that ran the fit; fitted models are not visible to other accounts.
  • load_model() makes no request. A fitted model stays usable for as long as its training data remains on the server; if it was deleted (for instance with UserDataClient), the first predict() raises FittedModelNotFoundError.
  • Pickling with pickle or joblib works too and stays small, since the estimator holds no training data. The JSON record is the format that is readable and meant to stay loadable across tabpfn-client versions.

A script that reruns often can reuse the fit when it is available and fit otherwise:

from tabpfn_client import FittedModelNotFoundError

try:
    model = TabPFNClassifier.load_model("model.json")
    predictions = model.predict(X_test)
except (FileNotFoundError, FittedModelNotFoundError):
    model = TabPFNClassifier().fit(X_train, y_train)
    model.save_model("model.json")
    predictions = model.predict(X_test)

Submitting a fit and waiting for it later

A fit can run for a long time, in thinking mode especially, and the process waiting for it can stop: a closed notebook, a crash, a job timeout. submit_fit() starts the fit and returns as soon as the server has accepted it. Save the model then, and a later run can load it and wait for the same fit instead of fitting again:

from pathlib import Path

from tabpfn_client import TabPFNClassifier

path = Path("model.json")
if path.exists():
    model = TabPFNClassifier.load_model(path)
else:
    model = TabPFNClassifier(thinking_mode=True)
    model.submit_fit(X_train, y_train)  # returns without waiting for the fit
    model.save_model(path)
model.wait_for_fit()
predictions = model.predict(X_test)

Until wait_for_fit() has seen the fit complete, the model is pending, and predict() raises NotFittedError without asking the server. wait_for_fit() polls the server until the fit has completed, and returns at once if it already has.

Submitting a prediction and waiting for it later

A large prediction can take a while too. submit_predict() starts it and returns as soon as the server has accepted it, so the process can do other work in the meantime. wait_for_predict() then waits for the prediction and returns it. The model holds the pending prediction until then, and save_model() saves it, so a later run can load the model and wait for the same prediction:

from tabpfn_client import TabPFNClassifier

model = TabPFNClassifier.load_model("model.json")
# Returns without waiting for the prediction.
model.submit_predict(X_test, output_type="probas")
model.save_model("model.json")  # saves the pending prediction too
# ... other work, or a later run that loads "model.json" again ...
predictions = model.wait_for_predict()  # what model.predict_proba(X_test) returns

submit_predict() takes the arguments of predict() (a classifier's also takes output_type), and wait_for_predict() returns what predict() returns for them. A classifier's output_type is "preds" (the default: the class labels) or "probas" (what predict_proba() returns).

A model holds one pending prediction. A new submit_predict() or predict() replaces it once the server has accepted the new prediction, and a new fit drops it; the id of a dropped prediction is logged as a warning. The server keeps the result of a prediction for at least a day after it completes.

predict() holds its own prediction the way fit() holds its fit: while it waits for a prediction that the server runs as a background job, the model holds it. If that wait stops, for a timeout or an interrupt, call wait_for_predict() to wait for the same prediction instead of starting a new one, or save_model() to wait for it in a later run. A regressor's "full" output split over several requests is not held; its ids are logged instead.

Timings

After fit() and predict() (or wait_for_predict()), an estimator reports how many seconds the server spent on each stage:

model = TabPFNClassifier()
model.fit(X_train, y_train)
model.predict(X_test)

model.get_timings()
# {"fit": {"elapsed_s": ..., "queue_wait_s": ..., "train_set_transform_s": ..., "fit_s": ...},
#  "predict": {"test_set_transform_queue_wait_s": ..., "test_set_transform_s": ...,
#              "predict_queue_wait_s": ..., "predict_s": ...}}
  • A *queue_wait_s field is time spent waiting for the server to start the work; the oth

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 337
Class 81
Function 59
Route 31

Languages

Python100%

Modules by API surface

tests/unit/test_tabpfn_regressor.py46 symbols
src/tabpfn_client/client.py46 symbols
tests/unit/test_tabpfn_classifier.py43 symbols
tests/unit/test_client.py39 symbols
tests/quick_test_v2.py37 symbols
src/tabpfn_client/api_models.py32 symbols
src/tabpfn_client/estimator.py31 symbols
src/tabpfn_client/service_wrapper.py28 symbols
tests/unit/test_service_wrapper.py26 symbols
src/tabpfn_client/prompt_agent.py24 symbols
tests/unit/test_browser_auth.py23 symbols
src/tabpfn_client/sagemaker/estimator.py19 symbols

For agents

$ claude mcp add tabpfn-client \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page