Registry / llm-agents / guardrails-api-client

guardrails-api-client

JSON →
library0.4.0pypypi✓ verified 84d ago

The `guardrails-api-client` is a Python library providing a simple interface to interact with the Guardrails API for AI application development. It is currently at version 0.4.0 and follows a rapid release cadence common for pre-1.0 libraries, indicating active development with potential for API changes.

pip install guardrails-api-client
INSTALL
IMPORT
SIG · GUARDRAILS-API-CLI
G
guardrails-api-client
llm-agentspythonv0.4.0
Install
3.7s avg
Import
Disk
29MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 30.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.7s · import 0.000s · 30MB
29MB installed
● package 29MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ApiClient
from guardrails_api_client import ApiClient
from guardrails_api_client import Client

Initializes the Guardrails API client, authenticates using an environment variable, and demonstrates a basic call to the `create_run` endpoint. This example checks an LLM output against a specified guard.

import guardrails_api_client import os # Ensure GUARDRAILS_API_KEY is set in your environment # Example: export GUARDRAILS_API_KEY="your_api_key_here" api_key = os.environ.get("GUARDRAILS_API_KEY", "") if not api_key: print("Error: GUARDRAILS_API_KEY environment variable is not set.") print("Please set it before running the quickstart.") else: client = guardrails_api_client.Client( base_url="https://api.guardrails.ai", # Or your custom base URL api_key=api_key, ) try: # Replace 'your-guard-id' with an actual guard ID from your Guardrails account response = client.v1.create_run( llm_output="Hello, I am an AI model.", guard_id="your-guard-id", # ... other parameters like metadata, stream etc. ).result print(f"Is valid: {response.is_valid}") if not response.is_valid: print(f"Reasons: {response.reasons}") print(f"Fixed output: {response.fixed_output}") except guardrails_api_client.errors.V1CreateRunError as e: print(f"API Error: {e.response.json() if e.response else e}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingAs a 0.x.x library, the API surface (e.g., client methods, parameters, response types, error handling) is subject to breaking changes in minor versions (e.g., 0.3.x to 0.4.x).
fix
Always consult the official documentation and release notes when upgrading between minor versions. Pin your dependency to `guardrails-api-client~=0.4` to avoid unexpected upgrades.
affects: <1.0.0
gotchaAuthentication failures (e.g., HTTP 401 Unauthorized) commonly occur if the `GUARDRAILS_API_KEY` is missing, invalid, or expired.
fix
Ensure the `GUARDRAILS_API_KEY` environment variable is correctly set and contains a valid API key. Verify the key's validity in your Guardrails account settings.
affects: All
gotchaSpecific API endpoint methods and their parameters (e.g., `client.v1.create_run`) can change or be renamed across versions, especially in pre-1.0 releases.
fix
Refer to the latest official documentation or the `guardrails-api-client` GitHub repository for the correct and most up-to-date API endpoint usage for your installed version.
affects: <1.0.0
Upgrade
Version history
0.4.0latest on PyPI · released Sep 19, 2025
Audit
Dependencies
httpxrequiredHTTP client for making API requests.
pydanticrequiredUsed for data validation and parsing API responses.
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
2
Resources
guardrails-api-client — pip install guardrails-api-client · libregistry