Skip to main content

Ruthless middleware that stops broken AI outputs from reaching your database

Project description

iron-thread

Ruthless middleware that stops broken AI outputs from reaching your database.

Install

pip install iron-thread

Quick Start

from ironthread import IronThread

it = IronThread()

# Create a schema
schema = it.create_schema(
    name="User Profile",
    schema_definition={
        "required": ["name", "email", "age"],
        "properties": {
            "name": {"type": "string"},
            "email": {"type": "string"},
            "age": {"type": "integer"}
        }
    }
)

# Validate any AI output
result = it.validate(
    ai_output='{"name": "John", "email": "john@example.com", "age": 28}',
    schema_id=schema["id"]
)

if result.passed:
    print("Clean — safe to send to database")
    print(result.data)
else:
    print(f"Blocked — {result.reason}")

Real World Usage

import openai
from ironthread import IronThread

it = IronThread()
client = openai.OpenAI()

# Your AI call
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Generate a user profile as JSON"}]
)

ai_output = response.choices[0].message.content

# Validate before touching your database
result = it.validate(
    ai_output=ai_output,
    schema_id="your-schema-id",
    model_used="gpt-4"
)

if result.passed:
    db.save(result.data)  # safe
else:
    print(f"AI output rejected: {result.reason}")

API

IronThread(host=...)

Initialize the client. Defaults to the hosted API.

.create_schema(name, schema_definition, description="")

Create a validation schema. Returns the schema with its id.

.validate(ai_output, schema_id, model_used="unknown")

Validate AI output against a schema. Returns a ValidationResult.

.stats()

Get dashboard stats — total runs, pass rate, avg latency.

.runs()

Get the last 50 validation runs.

ValidationResult

result.passed      # True or False
result.status      # "passed" / "failed" / "corrected"
result.reason      # why it failed (if it did)
result.data        # the clean validated output
result.latency_ms  # how long validation took
result.run_id      # ID of this run in the database

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iron_thread-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iron_thread-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file iron_thread-0.1.0.tar.gz.

File metadata

  • Download URL: iron_thread-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for iron_thread-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4fdd8e4d3146da6b0ee7d00e510cbd7f4c6bc695028ce3ebf98a1d924184d677
MD5 790b56ef7ed6e90984a0558645fd2e08
BLAKE2b-256 16379ef0691775b931bd97c463c7dee279aa9d2aa3fb331eb2d231519b2ca29a

See more details on using hashes here.

File details

Details for the file iron_thread-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iron_thread-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for iron_thread-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78bebf2a74f84a436ff35060c4360bfec100bb671e8eae7f49f5c60033900842
MD5 695d078d997cb4543f0a9cde16883685
BLAKE2b-256 e3b1b3eaebdf06210397c2b26b9381b820563f30cd2ae81f23c2d226ea93c155

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page