Thulean Tabular Foundation Model API

In-context classification and regression for structured tabular data with sub-second GPU inference. Upload a labeled training table once as a cached context, or send support + query tables together for one-shot prediction.

Base URL: https://api.thulean.ai Model: thulean-tfm-57m Tasks: classification · regression Wire formats: Arrow IPC · Parquet · CSV · JSON
Two Ways to Call the API
  • Stateful Contexts (recommended for production): POST /v1/contexts caches your support table's KV state on GPU/disk. Subsequent POST /v1/contexts/{id}/predict calls skip fitting and score in milliseconds.
  • One-Shot Prediction: POST /v1/predict accepts both support and query tables in one call (zero disk persistence, ephemeral RAM cache).

Authentication & Daily Row Quotas

Pass your API key in the Authorization: Bearer <key> header on all /v1/* endpoints. Keys are strictly tenant-isolated: contexts created by one key are invisible to all other keys.

Each API key has a configurable predicted rows per UTC day quota (only query/scored rows count; uploading support contexts does not deduct daily rows) plus a per-minute request rate limit. Every response includes live quota headers:

HeaderDescription
X-RateLimit-Rows-LimitDaily predicted-row quota for your key (or unlimited).
X-RateLimit-Rows-UsedPredicted rows consumed today (UTC).
X-RateLimit-Rows-RemainingRemaining predicted rows before UTC midnight reset.
X-RateLimit-Rows-ResetUnix timestamp of the next UTC midnight quota reset.
Retry-AfterSeconds until retry when HTTP 429 is returned.

Check your live quota at any time with GET /v1/usage (does not consume rows or wake the GPU).

Python SDK Quickstart

Install the lightweight Python client (no PyTorch required — uses zero-copy Apache Arrow IPC):

pip install git+https://github.com/Thulean-labs/thulean-api.git

Stateful Context (Fit Once, Predict Fast)

import os
import pyarrow.parquet as pq
from thulean_api import ThuleanClient

client = ThuleanClient(
    base_url=os.environ.get("THULEAN_API_URL", "https://api.thulean.ai"),
    api_key=os.environ["THULEAN_API_KEY"],
)

# 1. Check your daily row quota
print(client.usage())

# 2. Fit and cache support context (works with pandas, polars, pyarrow, dicts, or numpy)
train_df = pq.read_table("train.parquet")
test_df = pq.read_table("test.parquet").drop(["target"])

ctx = client.create_context(
    train_df,
    target="target",
    task="classification",   # or "regression"
    preset="balanced",       # "fast" (1), "balanced" (8), "best" (16)
    context_id="my-model-v1",
    ttl_seconds=86400,       # cached up to 7 days
)

# 3. Predict in milliseconds over Arrow IPC
pred = ctx.predict(test_df, return_probabilities=True)
print("Predictions:", pred.predictions[:5])
print("Classes:", pred.classes)
print(f"Latency: {pred.predict_ms:.1f} ms")

# 4. Clean up when done
ctx.delete()

One-Shot Prediction

pred = client.predict(
    support=train_df,
    query=test_df,
    target="target",
    task="regression",
    preset="balanced",
)
print(pred.predictions[:5])

cURL / HTTP Examples

Check Quota & Auth

curl -s "https://api.thulean.ai/v1/usage" \
  -H "Authorization: Bearer $THULEAN_API_KEY" | jq

One-Shot JSON Prediction

curl -s -X POST "https://api.thulean.ai/v1/predict" \
  -H "Authorization: Bearer $THULEAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "classification",
    "target": "default",
    "preset": "fast",
    "support": {
      "columns": {
        "age": [34, 51, 27, 45, 23, 60],
        "income": [62000, 95000, 41000, 78000, 32000, 120000],
        "home": ["rent", "mortgage", "rent", "own", "rent", "own"],
        "default": ["no", "no", "yes", "no", "yes", "no"]
      }
    },
    "query": {
      "columns": {
        "age": [29, 55],
        "income": [48000, 110000],
        "home": ["rent", "own"]
      }
    }
  }' | jq

Endpoints

EndpointPurpose
GET/healthzLiveness probe (public).
GET/readyzReadiness probe (public).
GET/v1/usageCurrent key's daily row quota, remaining rows, UTC reset time, and 14-day history.
GET/v1/modelsLogical model metadata, active presets, and guardrails.
POST/v1/contextsFit & cache a support table. Returns 201 Created (or 409 if duplicate unless overwrite=true).
GET/v1/contextsList cached contexts owned by your API key.
GET/v1/contexts/{id}Inspect a cached context's metadata.
POST/v1/contexts/{id}/predictScore query rows against a cached context. Deducts query rows from daily quota.
DELETE/v1/contexts/{id}Delete a cached context from memory and persistent storage.
POST/v1/predictStateless one-shot prediction (JSON or multipart Arrow/Parquet/CSV).

Data Formats & Limits

Send tables as Apache Arrow IPC (application/vnd.apache.arrow.stream, fastest), Parquet (application/vnd.apache.parquet), CSV (text/csv), or JSON (application/json). Request Accept: application/vnd.apache.arrow.stream for zero-copy binary predictions with exact class types preserved.

Presets & Ensemble Size

PresetMembersBest For
fast1Ultra-low latency interactive scoring and prototyping.
balanced8Default production trade-off between accuracy and speed.
best16Maximum accuracy on complex or noisy tabular datasets.

Error & Quota Codes

Statuserror_typeMeaning
401—Missing, invalid, revoked, or expired Bearer API key.
404context_not_foundContext does not exist, expired, or belongs to a different key.
409context_conflictcontext_id already exists; pass overwrite=true to replace.
413payload_too_largeRequest exceeds 64 MiB body limit.
422codec_error / schema_errorMalformed payload, missing feature columns, or table limits exceeded.
429daily_row_quota_exceededDaily predicted-row limit reached; resets at X-RateLimit-Rows-Reset (UTC midnight).
429rate_limit_exceededPer-minute request limit exceeded; retry after Retry-After seconds.