Skip to main content

API reference

Base URL: https://api.fidelityai.org/api/v1

Every request carries your key: Authorization: Bearer fai_…. Bodies are JSON (Content-Type: application/json). Errors are {"error": "..."} with a 4xx/5xx status; the quote reports a run it won't sell as {"blocked": true, "reason": "..."} with status 200.

Endpoints​

MethodPathDoes
GET/meYour account: email, API key, usage, credits
POST/keys/rotateReplace your API key
GET/modelsList your models
POST/modelsCreate a model
PUT/models/{id}Rename a model, or set whether its data is kept
DELETE/models/{id}Delete a model and its data
GET/models/{id}/contentFetch the saved source and candidates
PUT/models/{id}/contentSave the source and candidates
POST/models/{id}/train-quotePrice a training run (free)
POST/billing/checkout-dynamicPay for and start a training run
POST/models/{id}/train-retryRetry a run that failed on our side (free)
GET/models/{id}/resultTraining status, and the artifact when ready
POST/billing/portalOpen the Stripe billing portal (invoices, card)
POST/build-previewSandbox preview on a built-in demo dataset (100/month)

Account​

GET /me​

{
"email": "you@example.com",
"tier": "free",
"api_key": "fai_…",
"usage": { "month": "2026-10", "calls": 3, "limit": 100 },
"credits": { "month": "2026-10", "grant_cents": 3000, "remaining_cents": 2586, "expires_at": 1793491200 }
}

usage counts sandbox previews against the monthly limit.

POST /keys/rotate​

Deactivates the current key immediately and returns a new one: {"api_key": "fai_…"}.

Models​

POST /models​

Body {"name": "my-model"} (optional, up to 120 characters). Returns the model: {"id": "…", "name": "…", "created_at": …, "updated_at": …, "last_trained_at": null, "last_trained_hash": null}.

GET /models​

{"models": [{ "id", "name", "created_at", "updated_at", "last_trained_at", "last_status", "last_error", … }]}

PUT /models/{id}​

Body: any of {"name": "new name"}, {"keep_data": true}, {"encoding": {...}} (role-embedding settings; see Encodings; null restores the default settings). Returns {"id": "…", "name": "…", "keep_data": false, "encoding": null}.

keep_data (default false): after a successful run we delete the saved source, the candidates and their scores, and keep only the model. Set it to true before training to keep them (e.g. to edit and retrain in the console).

DELETE /models/{id}​

Body {"confirm_model_id": "<id>"} — must repeat the id, so a stray request can't delete a model. Returns {"ok": true, "id": "…"}. Deletion is permanent.

PUT /models/{id}/content​

Body {"source": "…", "candidates": "…"} — strings, up to 8 MB each; see Data formats and limits. Returns what was saved, with updated_at.

GET /models/{id}/content​

{"source": "…", "candidates": "…", "updated_at": …} (empty strings if nothing is saved yet).

Training​

POST /models/{id}/train-quote​

Body {} or {"max_qubits": N} (default 26). Free; charges nothing.

{
"blocked": false,
"kind": "new",
"source_mb": 0.2,
"max_qubits": 26,
"amount_cents": 500,
"amount_due_cents": 86,
"credits": { "applied_cents": 414, "remaining_cents": 2586, "due_cents": 86 },
"pricing": { … }
}

kind is new or retrain. When the run can't be sold, blocked is true with a reason: the source is unchanged since the last training at this capacity, or a run is already in progress.

POST /billing/checkout-dynamic​

Body {"model_id": "<id>"}, optionally "max_qubits" and "name". Applies credits, then:

  • if a card payment is due: {"url": "https://checkout.stripe.com/…", "id": "cs_…", "amount_due_cents": 86, …} — open url; training starts when Stripe confirms payment;
  • if credits cover everything: training starts at once and the response has "status": "training".

Refused (4xx, nothing charged) for the same reasons the quote is blocked.

POST /models/{id}/train-retry​

Body {}. Starts a free retry when the last run failed on our side with the same source and capacity. Returns {"status": "training", …}, or an error if the model isn't eligible.

GET /models/{id}/result​

While training: {"status": "training", "max_qubits": 26, …}. On failure: {"status": "failed", "error": "…", "failure_kind": "…"}. When done:

{ "status": "ready", "max_qubits": 26, "result": { "client_handoff_artifact": { "grammar": { … }, "clientHandoff": { … } }, "k": 2, "v": 4046, … } }

result.client_handoff_artifact is the artifact — pass it to the portable scorer. The rest of result describes the run. Poll about once a minute.

Billing​

POST /billing/portal​

Returns {"url": "https://billing.stripe.com/…"} for your Stripe customer portal, once you have started a checkout at least once.