Skip to main content

quick start TLDR; just fill in API key and run this:

$env:STABILIZER_API_KEY = "YOUR_STABILIZER_API_KEY"
py -m stabilizer_python_sdk.run_me --new

end quick start

stabilizer-python-sdk

Standalone Python SDK and CLI for the Stabilizer API at https://stabilizerapi.documentinsight.ai/api.

The SDK supports the public API and the end-to-end workflow used by the bundled run_me helper.

Install

py -m pip install -e .

Set The API Key

You can provide the API key in either of these ways.

Option 1: .env.local

Create a .env.local file in the project root:

STABILIZER_API_KEY=YOUR_STABILIZER_API_KEY
STABILIZER_PROVIDER_API_KEY=YOUR_PROVIDER_API_KEY # when using BYOK

Option 2: Terminal Session Variable

PowerShell:

This is required for authenticated commands:

$env:STABILIZER_API_KEY = "YOUR_STABILIZER_API_KEY"

If you want the workflow config to use BYOK (in addition to the above):

$env:STABILIZER_PROVIDER_API_KEY = "YOUR_PROVIDER_API_KEY"

STABILIZER_PROVIDER_API_KEY is optional. Set it only when you want the workflow config to use BYOK for the provider (currently only openrouter is supported)

Run The Workflow

Use the run_me module when you want the full config -> optimize -> compile -> extract flow.

Once STABILIZER_API_KEY is set via .env.local or your terminal session (for example, $env:STABILIZER_API_KEY = "YOUR_STABILIZER_API_KEY" in PowerShell), you can omit --api-key from the command examples below. The fragment --api-key YOUR_STABILIZER_API_KEY is optional and only needed when you want to pass the key directly on a specific command.

py -m stabilizer_python_sdk.run_me `
  --state-file .\temp_db\run_me\2026-04-14-08-30-45.json `
  --temp-db-dir .\temp_db `
  --compile-payload-file .\compile-input.json `
  --extract-payload-file .\extract-input.json `
  --new `
  --poll-interval 2 `
  --poll-timeout 600

The same workflow can be controlled from code:

from pathlib import Path

from stabilizer_python_sdk.run_me import RunMeSettings, run_all

state = run_all(
    settings=RunMeSettings(
        api_key="YOUR_STABILIZER_API_KEY",
        base_url="https://stabilizerapi.documentinsight.ai/api",
        temp_db_dir=Path("temp_db"),
        state_file=None,
        new_run=True,
        compile_payload_file=Path("compile-input.json"),
        extract_payload_file=Path("extract-input.json"),
        poll_interval=2.0,
        poll_timeout=600.0,
    )
)
print(state)

Workflow Payload Files

Use *-input.json for request bodies and *-output.json for saved standalone responses.

config-input.json contains the LLM config request. Only name is required; provider, default_model, compile_strength, base_url, is_default, byok, and api_key are optional. compile_strength picks one of four base-model tiers (low, medium, high, max) that the server resolves to a concrete model; it defaults to low server-side and acts as the default for both compile and grounding when not overridden per-request. default_model is used only by the baseline-extraction path.

You can also pick a strength tier per request: pass compile_options.compile_strength on a compile and options.grounding_strength on an extract. Example compile fragment:

"compile_options": {
  "compile_strength": "high"
}

Example extract fragment:

"options": {
  "num_results": 3,
  "grounding_strength": "max"
}

Two extract options control the grounding work per request. grounding_methods is a list of public aliases (e.g. hard_grounding, coverage_check, stress_test) that overrides the method list saved at compile time for this run only; the mandatory runtime guards are always applied on top. minimal_run is a boolean that forces the cheapest possible run — no grounding methods, a single extraction with no variations, and no baseline extraction — and overrides grounding_methods, num_results, and run_baseline_extraction.

"options": {
  "minimal_run": true
}

Field Comparison

field_comparison decides how two outputs of the same function are compared — at compile time, an extraction against its training example. It is a sibling of json_structure, mapping field paths to comparison modes:

Mode Meaning
identical Deterministic equality after collapsing whitespace and lowercasing. Never sent to the LLM judge, never given partial credit.
aliases identical, with your own synonym table applied first.
semantic The LLM-judged comparison. This is the default for any field you do not mention.
ignore Excluded from scoring entirely, denominator included — for free-form prose.
"field_comparison": {
  "invoice_number": "identical",
  "notes": "ignore",
  "status": {
    "mode": "aliases",
    "closed": true,
    "groups": {
      "paid": ["money_in", "payment_confirmed"],
      "due": ["unpaid", "outstanding"]
    }
  }
}

Each groups key is the canonical value and a member of its own group, so money_in and payment_confirmed both compare equal to paid. Adding "closed": true also makes the table a closed vocabulary: a value outside it is reported as a conformance violation, independently of the score — two outputs that both return the same off-table value still agree, they are merely both illegal. A closed table your training_data contradicts is rejected when you submit the compile.

Paths address nested structure: address.city for a field inside an object, line_items[].sku for a field inside array-of-object items, and a bare name (tags) for an array of scalars — the alias table then applies element-wise, and the elements are deduplicated and sorted, so two outputs listing the same values in a different order compare equal.

Every path must resolve against json_structure; one that does not is rejected rather than quietly ignored. Omitting field_comparison entirely compares every field semantically, exactly as before the option existed.

Pass it on a compile to save it with the function, or on an extract to override the saved policy for that run only. Retune it later without recompiling — the policy does not affect the compiled extraction prompt:

py -m stabilizer_python_sdk function-update --function fn_123 --payload-file .\function-update.json

with {"field_comparison": {...}} in that file, or {"field_comparison": null} to drop the policy. py -m stabilizer_python_sdk function --function fn_123 reads back the current one.

optimize-input.json contains the prompt optimization request, including prompt, json_structure, training_data, and optional optimization_options. compile-input.json contains the function creation request. Only prompt and json_structure are required; name, description, tags, training_data, grounding_methods, field_comparison, and compile_options are optional. extract-input.json contains the extraction request, including function_id, source_text, and optional options, metadata, ground_truth, and field_comparison.

Standalone CLI runs keep their latest saved responses under .\temp_db\general\. For async standalone commands, optimize, compile, and extract update those saved responses only when you poll a job, either with py -m stabilizer_python_sdk poll or by passing --poll. The workflow state used by run_me is stored separately under .\temp_db\run_me\.

The files included in this repository are ready to use as examples:

py -m stabilizer_python_sdk config --payload-file .\config-input.json # example config
py -m stabilizer_python_sdk.run_me --compile-payload-file .\compile-input.json --extract-payload-file .\extract-input.json # example workflow

Standalone Sequence

The standalone flow is easiest to follow when you treat each module output as the source of the next module's IDs.

  1. Create the config and save the latest response to .\temp_db\general\config-output.json.
py -m stabilizer_python_sdk config --payload-file .\config-input.json
  1. [Optional] Optimize the prompt, using the config_id from config-output.json. Polling writes the latest response to .\temp_db\general\optimize-output.json.
py -m stabilizer_python_sdk optimize --payload-file .\optimize-input.json --config cfg_123 --poll

If you want that optimize step to update a compile payload automatically, pass --alter-compile with the compile payload path while using --poll. When the target compile payload does not include compile_options.num_prompt_variations, the CLI writes the optimize results into compile_options.optimized_prompts. If num_prompt_variations is present, the CLI keeps the count-based shape and replaces the top-level prompt with the first optimized prompt.

py -m stabilizer_python_sdk optimize --payload-file .\optimize-input.json --config cfg_123 --poll --alter-compile .\compile-input.json
  1. Compile the function, again using the config_id from config-output.json. Polling writes the latest response to .\temp_db\general\compile-output.json.
py -m stabilizer_python_sdk compile --payload-file .\compile-input.json --config cfg_123 --poll
  1. Extract with the function_id from compile-output.json. You can either copy that value into extract-input.json or pass it with --function. Polling writes the latest response to .\temp_db\general\extract-output.json.
py -m stabilizer_python_sdk extract --payload-file .\extract-input.json --function fn_123 --poll

Terminal Commands

Run only the commands you need, in any order.

Commands needed for regular flow:

py -m stabilizer_python_sdk config --payload-file .\config-input.json # create config
py -m stabilizer_python_sdk optimize --payload-file .\optimize-input.json --config cfg_123 --poll --alter-compile .\compile-input.json # optimize prompt
py -m stabilizer_python_sdk compile --payload-file .\compile-input.json --config cfg_123 --poll # compile function
py -m stabilizer_python_sdk extract --payload-file .\extract-input.json --function fn_123 --poll # extract data
py -m stabilizer_python_sdk poll --job job_123 --timeout 600 # poll job (not needed when using --poll in commands above)

Other commands:

py -m stabilizer_python_sdk health # check if the service is alive
py -m stabilizer_python_sdk models # list available models
py -m stabilizer_python_sdk org # get organization info
py -m stabilizer_python_sdk org-update --payload-file .\org-update.json # update organization info
py -m stabilizer_python_sdk api-keys # list api keys
py -m stabilizer_python_sdk api-key-create --payload-file .\api-key-create.json # create api key (optional budget / metadata / max_compile_strength)
py -m stabilizer_python_sdk api-key --key me # get api key summary with live budget usage and compile ceiling ('me' = calling key)
py -m stabilizer_python_sdk api-key-update --key key_123 --payload-file .\api-key-update.json # update budget / metadata / max_compile_strength / revoked
py -m stabilizer_python_sdk api-key-usage --key key_123 --from 2026-04-01 --to 2026-04-15 # get per-key usage
py -m stabilizer_python_sdk api-key-revoke --key key_123 # revoke api key
py -m stabilizer_python_sdk configs # list configs
py -m stabilizer_python_sdk config-update --config cfg_123 --payload-file .\config-update.json # update config
py -m stabilizer_python_sdk config-delete --config cfg_123 # delete config
py -m stabilizer_python_sdk config-test --payload-file .\config-test.json # verify a provider (BYOK) api key before saving it
py -m stabilizer_python_sdk functions --name Invoice --tag billing # list compiled functions
py -m stabilizer_python_sdk function --function fn_123 # get compiled function info
py -m stabilizer_python_sdk function-update --function fn_123 --payload-file .\function-update.json # update compiled function metadata
py -m stabilizer_python_sdk function-delete --function fn_123 # delete compiled function
py -m stabilizer_python_sdk extractions # list previous extractions
py -m stabilizer_python_sdk job --job job_123 # get job info
py -m stabilizer_python_sdk usage --from 2026-04-01 --to 2026-04-15 # get org usage info
py -m stabilizer_python_sdk usage --from 2026-04-01 --to 2026-04-15 --group-by key --limit 200 --cursor key_123 # per-key bulk usage (requires a 'full' key)
py -m stabilizer_python_sdk state latest # get current state summary

Notes:

All authenticated schema-backed commands require an API key from --api-key, STABILIZER_API_KEY, or .env.local.

Commands that create or update resources with request bodies require an explicit --payload-file. The only environment-backed defaults for standalone runs are STABILIZER_API_KEY and STABILIZER_PROVIDER_API_KEY.

state latest reads the current standalone state summary from .\temp_db\general\, using config-output.json, optimize-output.json, compile-output.json, and extract-output.json.

Capping What A Key Can Spend On Compiles

A key may carry max_compile_strength (low, medium, high, or max), bounding which base-model tier it is allowed to buy. It applies silently: a compile from a medium-capped key that asks for max — whether via compile_options.compile_strength or the LLM config default — is served at medium rather than rejected, so the caller never has to know its own tier. The cap also bounds the strength the compiler internally boosts its planner to.

Set it at creation in api-key-create.json, or re-tier an existing key with api-key-update — a key can follow a tenant's plan change without being reissued:

{ "max_compile_strength": "medium" }

Send {"max_compile_strength": null} to remove the ceiling; omit the field to leave it unchanged. api-key and api-keys return the current ceiling, null when uncapped.

SDK Surface

from stabilizer_python_sdk import StabilizerClient

StabilizerClient covers the public, org, runtime, management, and workflow routes.

The SDK is synchronous and dependency-free. It uses the Python standard library HTTP stack.

The typed request helpers take field_comparison directly:

from stabilizer_python_sdk import StabilizerClient, compile_function, extract

client = StabilizerClient(api_key="YOUR_STABILIZER_API_KEY")

compile_function(
    client,
    prompt="Extract the invoice",
    json_structure={"invoice_number": "<string>", "notes": "<string>", "status": "<string>"},
    training_data=[...],
    field_comparison={
        "invoice_number": "identical",
        "notes": "ignore",
        "status": {"mode": "aliases", "groups": {"paid": ["money_in"]}},
    },
)

# Override the saved policy for one run only.
extract(client, function_id="fn_123", source_text="...", field_comparison={"notes": "ignore"})

Admin API

StabilizerAdminClient covers the /v1/admin/* routes used by billing and ops callers. These routes are gated purely on the X-Admin-API-Key header, so this client sends only that header and never an Authorization: Bearer org token — the admin key alone is sufficient for the whole surface.

from stabilizer_python_sdk import StabilizerAdminClient

admin = StabilizerAdminClient(admin_api_key="YOUR_V1_ADMIN_API_KEY")

summary = admin.get_api_key("key_123")          # budget is None when unlimited
admin.update_api_key("key_123", {"budget": {"extract_limit": 20000, "period": "month"}})
admin.update_api_key("key_123", {"budget": {"extract_limit": 0}})   # suspend
admin.update_api_key("key_123", {"budget": None})                   # unlimited
admin.update_api_key("key_123", {"revoked": True})                  # reversible offboard
usage = admin.get_api_key_usage("key_123", from_="2026-07-01", to="2026-08-01")
admin.revoke_api_key("key_123")                 # one-way offboard
minted = admin.create_org_api_key("org_abc", {"name": "tenant-name"})

created = admin.create_org({"name": "Acme", "external_id": "aad-tenant-1"})
orgs = admin.list_orgs()                        # {"orgs": [...]}
org = admin.get_org("org_abc")                  # {"org": {...}}
admin.update_org("org_abc", {"name": "Acme Inc."})
admin.delete_org("org_abc")                     # one-way; does not revoke the org's keys

create_org_api_key and create_org are the only places key_value (the raw sk-stab-... secret) is ever returned — store it at creation.

create_org's external_id makes org provisioning idempotent: pass the caller's own tenant identifier (e.g. an Azure AD tenant id from a marketplace webhook), and a repeat call with the same external_id returns the org already provisioned for it — api_key is None in that response, since a key value can't be recovered after its original creation — instead of creating a duplicate org.

get_api_key_usage takes a half-open window [from, to). It defaults to the key's current budget period, or all-time when the key has no budget. The returned counts are window-scoped, but budget.used always reflects the current billing period.

There are no admin CLI commands; the admin key stays out of the CLI surface and these operations are library-only.

Examples

from stabilizer_python_sdk import StabilizerClient

client = StabilizerClient(api_key="YOUR_STABILIZER_API_KEY")
print(client.health())
print(client.supported_models())

Metadata

Release files for stabilizer-python-sdk 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stabilizer-python-sdk 0.7.0
File Size Uploaded Provenance Actions
stabilizer_python_sdk-0.7.0.tar.gz 55.3 kB Without provenance Details for stabilizer_python_sdk-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stabilizer-python-sdk 0.7.0
File Interpreter ABI Platform Actions
stabilizer_python_sdk-0.7.0-py3-none-any.whl Python 3 none any Details for stabilizer_python_sdk-0.7.0-py3-none-any.whl

Total release size: 87.3 kB

Release files / stabilizer_python_sdk-0.7.0.tar.gz

Download URL stabilizer_python_sdk-0.7.0.tar.gz
Size 55.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fa342e82a31b55e9b24706aa945f9976630a5c6b7076cf1787ef2c78818a0417
BLAKE2b-256 checksum
How to use checksums
e24968fd4bf384dc32791423f2f7a51661074d15fb9c66096c4d5074a421f96f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / stabilizer_python_sdk-0.7.0-py3-none-any.whl

Download URL stabilizer_python_sdk-0.7.0-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e2b40cbd531dd30470eca44eb61deb016abf6a01f7983607cf07b735d9773e9
BLAKE2b-256 checksum
How to use checksums
5245b7ef44dcc5eb514924ab053a7b54a80a105ed44266408942d460fe253bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for stabilizer-python-sdk 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page