Skip to main content

Quickstart

Train a model from the command line and score with it offline. You need curl and jq.

1. Get an API key​

Sign in at quantum.fidelityai.org and copy your key (fai_…) from the account menu. Keep it on a server or developer machine — never ship it inside an app: anyone holding it can spend your credits. Rotate it from the same menu if it leaks.

KEY=fai_...
API=https://api.fidelityai.org/api/v1
curl -s $API/me -H "Authorization: Bearer $KEY" # your account, usage and credits

2. Create a model and upload examples​

MODEL=$(curl -s -X POST $API/models -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' -d '{"name":"my-model"}' | jq -r .id)

# source.jsonl: one {"sequence":[...]} per line, at least 2 lines
printf '%s\n' '{"sequence":[3,1,4,1,5]}' '{"sequence":[2,7,1,8,2]}' '{"sequence":[3,1,4,1,6]}' > source.jsonl

curl -s -X PUT $API/models/$MODEL/content -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' \
-d "$(jq -n --arg s "$(cat source.jsonl)" '{source: $s}')"

See Data formats and limits for the other accepted formats and for how vocabulary size sets the capacity a run needs.

3. Quote​

curl -s -X POST $API/models/$MODEL/train-quote -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' -d '{}'

The quote is free. It returns the price (amount_cents), what's left to pay after credits (amount_due_cents), and the capacity (max_qubits). If the run can't be done — the source is identical to what this model was last trained on, or a run is already in progress — it returns {"blocked": true, "reason": "..."} and nothing can be charged.

4. Pay and train​

curl -s -X POST $API/billing/checkout-dynamic -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' -d "{\"model_id\":\"$MODEL\"}" | jq -r .url

Open the returned Stripe URL and pay amount_due_cents. Training starts as soon as Stripe confirms payment — closing the browser afterwards is fine. If your credits cover the whole price there is no URL: the response already has "status": "training".

5. Wait for the result​

until [ "$(curl -s $API/models/$MODEL/result -H "Authorization: Bearer $KEY" | jq -r .status)" != training ]; do sleep 60; done
curl -s $API/models/$MODEL/result -H "Authorization: Bearer $KEY" | jq .result.client_handoff_artifact > artifact.json

status ends as ready or failed (with an error). A run that fails on our side can be retried free: POST $API/models/$MODEL/train-retry.

After a successful run your uploaded source and candidates are deleted; only the model is kept. To keep them for editing and retraining, set {"keep_data": true} on the model (PUT $API/models/$MODEL) before training.

6. Score offline​

curl -sO https://fidelityai.org/sdk/scorer.v1.js
node -e '
const FidelityAIScorer = require("./scorer.v1.js")
const artifact = require("./artifact.json")
const seqs = [[3,1,4,1,5],[2,7,1,8,2]].map(s => FidelityAIScorer.encodeTokens(s, artifact))
console.log(FidelityAIScorer.scoreEncodedSequences(seqs, artifact))
'

Lower score is more typical of your examples. See Scoring offline for iOS and Android, and for what the other fields mean.