{"id":9799,"library":"guardrails-api-client","title":"Guardrails API Client","description":"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.","status":"active","version":"0.4.0","language":"python","source_language":"en","source_url":"https://github.com/guardrails-ai/guardrails-api-client","tags":["AI","LLM","API Client","guardrails","security","moderation"],"install":[{"cmd":"pip install guardrails-api-client","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"HTTP client for making API requests.","package":"httpx"},{"reason":"Used for data validation and parsing API responses.","package":"pydantic"}],"imports":[{"wrong":"from guardrails_api_client import Client","symbol":"ApiClient","correct":"from guardrails_api_client import ApiClient"}],"quickstart":{"code":"import guardrails_api_client\nimport os\n\n# Ensure GUARDRAILS_API_KEY is set in your environment\n# Example: export GUARDRAILS_API_KEY=\"your_api_key_here\"\napi_key = os.environ.get(\"GUARDRAILS_API_KEY\", \"\")\n\nif not api_key:\n    print(\"Error: GUARDRAILS_API_KEY environment variable is not set.\")\n    print(\"Please set it before running the quickstart.\")\nelse:\n    client = guardrails_api_client.Client(\n        base_url=\"https://api.guardrails.ai\", # Or your custom base URL\n        api_key=api_key,\n    )\n\n    try:\n        # Replace 'your-guard-id' with an actual guard ID from your Guardrails account\n        response = client.v1.create_run(\n            llm_output=\"Hello, I am an AI model.\",\n            guard_id=\"your-guard-id\",\n            # ... other parameters like metadata, stream etc.\n        ).result\n\n        print(f\"Is valid: {response.is_valid}\")\n        if not response.is_valid:\n            print(f\"Reasons: {response.reasons}\")\n            print(f\"Fixed output: {response.fixed_output}\")\n\n    except guardrails_api_client.errors.V1CreateRunError as e:\n        print(f\"API Error: {e.response.json() if e.response else e}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"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."},"warnings":[{"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.","message":"As 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).","severity":"breaking","affected_versions":"<1.0.0"},{"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.","message":"Authentication failures (e.g., HTTP 401 Unauthorized) commonly occur if the `GUARDRAILS_API_KEY` is missing, invalid, or expired.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Specific 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.","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"search_vec":"'-1.0':42 '0.4.0':32 'activ':45 'ai':24,52 'api':2,7,22,50,54 'applic':25 'cadenc':38 'chang':51 'client':3,8,55 'common':39 'current':29 'develop':26,46 'follow':34 'guardrail':1,6,21,56 'guardrails-api-cli':5 'indic':44 'interact':18 'interfac':16 'librari':12,43 'llm':53 'moder':58 'potenti':48 'pre':41 'provid':13 'python':11 'rapid':36 'releas':37 'secur':57 'simpl':15 'version':31","created_at":"2026-04-17T01:20:47.208119+00:00","updated_at":"2026-04-17T01:20:47.208119+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/guardrails-api-client/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":null}}