Skip to main content

guardrails-client

A thin REST client for the guardrails-api.

Quickstart

pip install guardrails-ai-sdk
from guardrails_ai.sdk import GuardrailsAI, Guard, ValidationOutcome

# Init the GuardrailsAI client
client = GuardrailsAI(api_key="xxx")

# Fetch a Guard from the server
guard: Guard = await client.guards.retrieve(name="my-guard")

print(guard)

# Run a Guard to validate content
validation_outcome: ValidationOutcome = await client.guards.validate(name="my-guard", llm_output="Hello, world.")

if not validation_outcome.validation_passed:
    print(validation_outcome.validation_summaries)

# Create Guarded Chat Completions
chat_completion = await client.guards.chat.completions.create(guard_name="my-guard", model="gpt-5-nano", messages=[{ "role": "user", "content": "Hello, world." }])

print(chat_completion.choices[0].message.content)
print(chat_completion.guardrails)

# Stream Guarded Chat Completions
completion_stream = await client.guards.chat.completions.create(
    guard_name="my-first-guard",
    model="gpt-5-nano",
    messages=[
        {"role": "user", "content": "Give yourself a realistic name and introduce yourself."}
    ],
    stream=True
)

full_text = ""
validation_summaries = []
async for chunk in completion_stream:
    full_text += chunk.choices[0].delta.content
    validation_summaries.extend(chunk.guardrails.get("validation_summaries", []))


print("\n ==> Validation Summaries: ", validation_summaries)
print("\n ==> Final Content: ", full_text)

Metadata

Release files for guardrails-ai-sdk 0.5.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 guardrails-ai-sdk 0.5.0
File Size Uploaded Provenance
guardrails_ai_sdk-0.5.0.tar.gz 14.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for guardrails-ai-sdk 0.5.0
File Interpreter ABI Platform
guardrails_ai_sdk-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.3 kB

Release files / guardrails_ai_sdk-0.5.0.tar.gz

Download URL guardrails_ai_sdk-0.5.0.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
366f9aa4136a588505083561451761d44ab8ae4a94a3d2b019f22215d06c8e2f
BLAKE2b-256 checksum
How to use checksums
3d00289ced2d93e61f86db14824e8b533cc425ea6c3ff0f168204d91950dce43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 10, 2026.

Transparency log

Release files / guardrails_ai_sdk-0.5.0-py3-none-any.whl

Download URL guardrails_ai_sdk-0.5.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87fb9fb83d7eda91e3256b7916cac1e144471ea83517652a4545d5a16ffcccc3
BLAKE2b-256 checksum
How to use checksums
9639b3106b57d81639179d6d0711587275fd99a648fec4c131d7fe81ae0467b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 10, 2026.

Transparency log

Security for guardrails-ai-sdk 0.5.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for guardrails_ai_sdk-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 10, 2026.

Transparency log

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.

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