Python SDK
The same verified-output API, with a Python client that mirrors the TypeScript SDK (snake_case fields). Zero runtime dependencies — stdlib only. Python 3.8+.
pip install maxmodelQuickstart
from maxmodel import MaxModel
mx = MaxModel(api_key="sk-...") # your maxmodel.com gateway key
out = mx.verified.create(
model="gpt-5.5-pro",
messages=[{"role": "user", "content": "What is our refund policy?"}],
sources=[{"id": "refunds.md", "text": "Full refunds within 30 days. No refunds after 30 days."}],
)
print(out.text) # grounded answer with inline [refunds.md] markers
for c in out.citations:
print(f'✓ "{c.quote}" — {c.source} {c.range}') # verbatim, traced to your source
for u in out.unsupported:
print(f'⚠ dropped ({u.reason}): "{u.claim}"') # hallucinations caught, not shippedClient
MaxModel(api_key, *, base_url="https://api.maxmodel.com", timeout=60.0)base_url— override for self-host / testing.timeout— seconds. Reasoning models likegpt-5.5-procan take 60–90s; raise this (e.g.timeout=180) when you use them.
mx.verified.create(...) -> VerifiedResult
| arg | type | default |
|---|---|---|
model | str | — |
messages | list[dict] ({"role","content"}) | — |
sources | list[dict] ({"id","text"}) | — |
mode | "strict" | "lenient" | "strict" |
allow_ungrounded | bool | False |
temperature | float | None | None |
max_tokens | int | None | None |
VerifiedResult is a dataclass: id, model, text, citations, unsupported, grounded, usage.
Citation = claim, quote, source, range(tuple); Unsupported = claim, reason;
Usage = prompt_tokens, completion_tokens, total_tokens, model_calls.
See verified.create for full field semantics and
How verification works for the guarantee.
Errors
Typed and catchable — same taxonomy as the TS SDK:
from maxmodel import RateLimitError, NoSourcesError, MaxModelError
try:
out = mx.verified.create(...)
except NoSourcesError:
... # you forgot sources, or set allow_ungrounded=True
except RateLimitError:
... # back off and retry
except MaxModelError as e:
print(e.type, e.status) # e.g. "invalid_key", 401MaxModelError is the base; subclasses: AuthError (401), QuotaError (402),
RateLimitError (429), NoSourcesError (400), ExtractionError (502), GatewayError (5xx).
OpenAI-compatible passthrough
r = mx.chat.completions.create(
model="gpt-5.5-pro",
messages=[{"role": "user", "content": "Hello"}],
)
print(r["choices"][0]["message"]["content"])