Skip to main content
Everything on this page is importable from the top-level package:

Clients

Auditor measures, Fixer fixes, Refinery runs the whole pipeline. Each has an async twin with the same run method, and each takes its stage config as an object: an AuditorConfig per audit stage, a FixerConfig for the fix.

Auditor

class · sdvm.auditor Synchronous client for the SDVM audit stage.
Parameters
str
required
AuditorConfig | None
default:"None"
The AuditorConfig for every call — votes (odd) audits each sample N times and returns the majority verdict per dimension. None is AuditorConfig(votes=1).
str
default:"'https://api.sdvm.ai'"
float
default:"120.0"

Auditor.aggregate()

static Cross-sample (dataset-level) audit over the output of run, computed locally. Returns per-field distributions and a per-check pass/fail rollup.
Parameters
list[DataSample]
required

Auditor.run()

Audit a list of samples (max 100 per request).
Parameters
list[DataSample]
required
Samples to audit.
str | None
default:"None"
Optional free-text description of dataset conventions the quality audit must not mistake for defects — e.g. a dataset that is uniformly lowercased, uses markup tokens, or truncates the context by design. Without it, such formatting is flagged as a grammatical defect.
AuditorConfig | None
default:"None"
Override the instance-level AuditorConfig for this request.
Returns The samples with their verdict attached on .audit.

AsyncAuditor

class · sdvm.auditor Async client for the SDVM audit stage.
Parameters
str
required
AuditorConfig | None
default:"None"
str
default:"'https://api.sdvm.ai'"
float
default:"120.0"

AsyncAuditor.aggregate()

static Cross-sample (dataset-level) audit over already-audited samples — local, deterministic. See Auditor.aggregate.

AsyncAuditor.run()

async Audit a list of samples asynchronously; see Auditor.run.
Parameters
list[DataSample]
required
str | None
default:"None"
AuditorConfig | None
default:"None"

Fixer

class · sdvm.fixer High-level synchronous client for the SDVM fix stage.
Fix routes each sample’s repair from an audit verdict — the .audit a sample already carries, or one routing audit run for it — and applies it with a never-worse guard. It does NOT reaudit to judge whether the fix helped; that is Refinery’s job (audit → fix → reaudit). Use Auditor for the verdict and Refinery when you want the whole pipeline. Parameters
str
required
FixerConfig | None
default:"None"
The FixerConfig for every call — max_attempts, how many tries the fixer gets at an accepted fix from one verdict. Left None, the server default of one attempt applies.
str
default:"'https://api.sdvm.ai'"
float
default:"120.0"

Fixer.run()

Fix a list of samples (max 100 per request).
Parameters
list[DataSample]
required
Samples to fix.
FixerConfig | None
default:"None"
Override the instance-level FixerConfig for this request; fields left None keep the instance’s values.
str | None
default:"None"
Optional dataset conventions for the routing audit (see Auditor.run) — declare formatting like uniform lowercasing or markup so it is not mistaken for a defect that triggers a needless fix.
Returns Fixed samples, reconstructed to their task’s type. A fixed sample carries a .fix block {"changes": [...], "flagged": bool, "attempts": int}: changes is what the fix did, flagged is true only for what it could not resolve (never made worse), attempts how many tries it got.

AsyncFixer

class · sdvm.fixer High-level async client for the SDVM fix stage; see Fixer.
Parameters
str
required
FixerConfig | None
default:"None"
str
default:"'https://api.sdvm.ai'"
float
default:"120.0"

AsyncFixer.run()

async Fix a list of samples asynchronously; see Fixer.run.
Parameters
list[DataSample]
required
FixerConfig | None
default:"None"
str | None
default:"None"

Refinery

class · sdvm.refinery Run the full pipeline (audit → fix → reaudit) end to end.
A Refinery runs audit -> fix -> reaudit, server-side (POST /refine), one pass: audit(votes) -> fix(max_attempts) -> reaudit(votes). Each returned sample carries one block per stage: .audit (the verdict BEFORE the fix — the one the fix was routed from, and the same block an Auditor returns), .fix (what the fix did: changes, flagged, attempts) and .reaudit (the verdict AFTER the fix, which is how you tell whether it helped; None for a sample the fix left alone, whose .audit still holds). Parameters
str
required
AuditorConfig | None
default:"None"
The audit before the fix — votes (odd) audits each sample N times and takes the majority verdict per dimension. None is one vote.
FixerConfig | None
default:"None"
The fix stage — max_attempts, tries at an accepted fix from the one verdict.
AuditorConfig | None
default:"None"
The audit after the fix, run on the samples the fix changed. None is one vote.
str | None
default:"None"
dataset conventions passed to every stage (see Auditor.run).
str
default:"'https://api.sdvm.ai'"
float
default:"120.0"

Refinery.run()

Execute the pipeline; returns the samples carrying .audit, .fix and .reaudit. Stage configs given here override the instance’s for this call.
Parameters
list[DataSample]
required
AuditorConfig | None
default:"None"
FixerConfig | None
default:"None"
AuditorConfig | None
default:"None"
str | None
default:"None"

AsyncRefinery

class · sdvm.refinery Async Refinery; see it for details.
Parameters
str
required
AuditorConfig | None
default:"None"
FixerConfig | None
default:"None"
AuditorConfig | None
default:"None"
str | None
default:"None"
str
default:"'https://api.sdvm.ai'"
float
default:"120.0"

AsyncRefinery.run()

async Execute the pipeline asynchronously; see Refinery.run.
Parameters
list[DataSample]
required
AuditorConfig | None
default:"None"
FixerConfig | None
default:"None"
AuditorConfig | None
default:"None"
str | None
default:"None"

Samples

The data types you pass in and get back. After a run, a sample carries .audit (Auditor, Refinery), .fix (Fixer, Refinery) and .reaudit (Refinery).

DataSample

class · sdvm.types · extends ABC Abstract base for a sample.
Every concrete sample declares a non-empty task_type (enforced at definition time) and serializes via to_dict, which emits task_type plus the sample’s fields (a field named extra is flattened in as passthrough metadata). Concrete classes are registered by task_type so from_dict can rebuild a sample from a server response.

DataSample.from_dict()

classmethod Rebuild a sample from a serialized dict, dispatching on its task_type.
Any audit / fix / reaudit block on the dict is carried onto the rebuilt sample. Parameters
dict
required

DataSample.to_dict()

Serialize the sample for the API: task_type plus its fields, with extra flattened in and audit / fix / reaudit included only when present.

TextSample

class · sdvm.types · extends DataSample A single text sample, e.g. a pre-training document.
Fields
str
required

TextSample.from_dict()

classmethod Rebuild a sample from a serialized dict, dispatching on its task_type.
Any audit / fix / reaudit block on the dict is carried onto the rebuilt sample. Parameters
dict
required

TextSample.to_dict()

Serialize the sample for the API: task_type plus its fields, with extra flattened in and audit / fix / reaudit included only when present.

MultipleChoiceSample

class · sdvm.types · extends DataSample A single-answer multiple-choice item: a context, choices, and the answer_index of the one correct choice. Extra columns pass through via extra.
style tells the audit how to read the context (see MC_STYLES): the same data shape covers sentence-completion ("continuation") and question-answering ("qa"). Fields
str
required
list[str]
required
int
required
str
default:"'continuation'"
dict
default:"dict()"

MultipleChoiceSample.from_dict()

classmethod Rebuild a sample from a serialized dict, dispatching on its task_type.
Any audit / fix / reaudit block on the dict is carried onto the rebuilt sample. Parameters
dict
required

MultipleChoiceSample.to_dict()

Serialize the sample for the API: task_type plus its fields, with extra flattened in and audit / fix / reaudit included only when present.

MultipleChoiceCompletionSample

class · sdvm.types · extends MultipleChoiceSample A multiple-choice item whose context is a sentence STEM the correct choice continues.
The stem is truncated by design — it ends mid-sentence on a dangling word — so “is the context complete?” is not a question that applies here, and the auditor does not ask it. That is the point of having a distinct type: the guarantee is visible in the name rather than buried in a style flag, and you cannot accidentally get a completeness verdict on a stem. Fields
str
required
list[str]
required
int
required
str
default:"'continuation'"
dict
default:"dict()"

MultipleChoiceCompletionSample.from_dict()

classmethod Rebuild a sample from a serialized dict, dispatching on its task_type.
Any audit / fix / reaudit block on the dict is carried onto the rebuilt sample. Parameters
dict
required

MultipleChoiceCompletionSample.to_dict()

Serialize the sample for the API: task_type plus its fields, with extra flattened in and audit / fix / reaudit included only when present.

MultipleChoiceQuestionAnswerSample

class · sdvm.types · extends MultipleChoiceSample A multiple-choice item whose context is a complete QUESTION the correct choice answers.
Unlike a completion stem, the question is meant to stand on its own, so a truncated or malformed one IS a defect — the auditor checks completeness for this type. Fields
str
required
list[str]
required
int
required
str
default:"'qa'"
dict
default:"dict()"

MultipleChoiceQuestionAnswerSample.from_dict()

classmethod Rebuild a sample from a serialized dict, dispatching on its task_type.
Any audit / fix / reaudit block on the dict is carried onto the rebuilt sample. Parameters
dict
required

MultipleChoiceQuestionAnswerSample.to_dict()

Serialize the sample for the API: task_type plus its fields, with extra flattened in and audit / fix / reaudit included only when present.

QuestionAnswerSample

class · sdvm.types · extends DataSample A question and its written answer — two fields, no choices to pick from.
answer is whatever the dataset publishes as the answer: a bare value, a sentence, or a worked solution. Nothing here is specific to one corpus — a dataset that separates a reasoning trace from the value it arrives at puts the value in answer and the trace in extra, where every other column already passes through untouched. Fields
str
required
str
required
dict
default:"dict()"
What sdvm-audit-1 returns for this type and what sdvm-fix-1 changes are on the model pages: sdvm-audit-1, sdvm-fix-1.

QuestionAnswerSample.from_dict()

classmethod Rebuild a sample from a serialized dict, dispatching on its task_type.
Any audit / fix / reaudit block on the dict is carried onto the rebuilt sample. Parameters
dict
required

QuestionAnswerSample.to_dict()

Serialize the sample for the API: task_type plus its fields, with extra flattened in and audit / fix / reaudit included only when present.

ConversationSample

class · sdvm.types · extends DataSample A chat transcript: a list of messages in the OpenAI shape, as in an SFT corpus.
At most one system message, and only first; at least one user and one assistant turn. The type does not require the transcript to alternate or to end on an assistant turn, and it accepts an empty turn: those are defects the audit reports and the fix repairs, so the type lets them through to be repaired. A tool or function turn is refused. Plain {"role", "content"} dicts are accepted anywhere a Message is and normalised. Fields
list[Message]
required
str
default:"last"
How much of the transcript the models read: "last", the final exchange, or "all", every assistant turn, reported per turn under audit["turns"]. Anything else is a ValueError.
dict
default:"dict()"
What sdvm-audit-1 returns for this type and what sdvm-fix-1 changes are on the model pages: sdvm-audit-1, sdvm-fix-1.

ConversationSample.from_dict()

classmethod Rebuild a sample from a serialized dict, dispatching on its task_type.

ConversationSample.to_dict()

Serialize for the API request: task_type, messages as plain dicts, turns, and the extra keys flattened in.

Message

class · sdvm.types One turn of a conversation.
Fields
str
required
"system", "user" or "assistant"; anything else is a ValueError.
str
required
The turn’s text. Must be a string; it may be empty (the audit reports it as an empty turn).

Message.to_dict()

Configuration

One object per pipeline stage. On the HTTP API the same objects are the config of each endpoint: {"votes"} on /audit, {"max_attempts"} on /fix, and {"audit": {...}, "fix": {...}, "reaudit": {...}} on /refine.

AuditorConfig

class · sdvm.types Configuration of one audit stage — the Auditor, or the audit / reaudit stage of a Refinery.
Parameters
int
default:"1"
How many times to audit each sample; each field is the majority across them. 1 (default) is a single audit. Use an odd number: a tie has no majority. See Denoising with votes.

AuditorConfig.to_dict()

Serialize for the API request: {"votes": N}.

FixerConfig

class · sdvm.types Configuration of the fix stage — the Fixer, or the fix stage of a Refinery. Fields left None mean “the server default” (or, on a per-call override, “the instance’s value”).
Parameters
int | None
default:"None"
How many tries the fixer gets at an ACCEPTED fix from the one audit verdict it was given. A sample that comes back flagged — a generation that failed its own verification, or an edit the never-worse guard reverted — is tried again on the original sample with what went wrong as feedback, stopping at the first accepted fix. A sample no verdict routed to a fix gets no attempt. 1 to 5; the server default is 1. See Attempts.

FixerConfig.merge()

Return a new config with overrides taking priority over self.
Parameters
FixerConfig | None
required

FixerConfig.to_dict()

Serialize non-None fields to a dict for the API request.

Exceptions

All inherit from SDVMError.

SDVMError

exception · sdvm.exceptions · extends Exception Base exception for all SDVM SDK errors.

AuthenticationError

exception · sdvm.exceptions · extends SDVMError Raised when authentication fails (invalid or revoked API key).

InsufficientCreditsError

exception · sdvm.exceptions · extends SDVMError Raised when the account has insufficient credits (HTTP 402).

RateLimitError

exception · sdvm.exceptions · extends SDVMError Raised when the rate limit is exceeded (HTTP 429).

APIError

exception · sdvm.exceptions · extends SDVMError Raised for unexpected API errors.
Parameters
int
required
str
required
Last modified on September 18, 2026