Skip to main content

respan-instrumentation-guardrails

Respan instrumentation plugin for Guardrails AI. It wraps Guardrails Guard execution methods and emits guardrail spans into the Respan tracing pipeline.

Configuration

1. Install

pip install respan-ai respan-instrumentation-guardrails guardrails-ai

guardrails-ai is the Guardrails runtime package. It must be available in your package index for runnable Guardrails applications.

2. Set Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Your Respan API key. Authenticates both proxy and tracing.
RESPAN_BASE_URL No Defaults to https://api.respan.ai/api.

Quickstart

3. Run Script

import os

from dotenv import load_dotenv

load_dotenv()

respan_api_key = os.environ["RESPAN_API_KEY"]
respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
os.environ["OPENAI_API_KEY"] = respan_api_key
os.environ["OPENAI_BASE_URL"] = respan_base_url

from guardrails import Guard
from pydantic import BaseModel
from respan import Respan
from respan_instrumentation_guardrails import GuardrailsInstrumentor


class SupportReply(BaseModel):
    answer: str
    priority: str


respan = Respan(
    api_key=respan_api_key,
    base_url=respan_base_url,
    instrumentations=[GuardrailsInstrumentor()],
)

guard = Guard.for_pydantic(output_class=SupportReply)
result = guard(
    model="gpt-4o-mini",
    messages=[
        {
            "role": "user",
            "content": "Return JSON with answer and priority for a late shipment.",
        }
    ],
)

print(result.validated_output)
respan.flush()

4. View Dashboard

After running the script, traces appear on your Respan dashboard.

Further Reading

See the Respan example projects for runnable scripts.

Metadata

Release files for respan-instrumentation-guardrails 0.1.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 respan-instrumentation-guardrails 0.1.0
File Size Uploaded
respan_instrumentation_guardrails-0.1.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for respan-instrumentation-guardrails 0.1.0
File Interpreter ABI Platform
respan_instrumentation_guardrails-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / respan_instrumentation_guardrails-0.1.0.tar.gz

Download URL respan_instrumentation_guardrails-0.1.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
59a2844a676eee4f62a862301dbd5d67212fdaacaefbe2e37093886bc5df419a
BLAKE2b-256 checksum
How to use checksums
6c4c745ab656b0290bc02768f9d9ae96578f770b8e278e59408a3ea154d96c9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0

Release files / respan_instrumentation_guardrails-0.1.0-py3-none-any.whl

Download URL respan_instrumentation_guardrails-0.1.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88398e78883f0921a6a45e2c45e3443c294be2e1a94cb3daa6a3958066ca157a
BLAKE2b-256 checksum
How to use checksums
9c052096cb8d13e160ad800313e06df7325c7aa0656c2217ed06982147f9cf7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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