Generated from promptguard-sdk 2.4.2 as published on PyPI (sha256
0fae2f792594…). Signatures, parameters and descriptions are read from the package itself, so this page changes only when the pinned SDK version does. For a walkthrough, start with the guide.promptguard
PromptGuard Python SDK
Config
Class · from promptguard import Config
PromptGuard client.
api_key: str = field(repr=False)base_url: str = 'https://api.promptguard.co/api/v1/proxy'max_retries: int = 3retry_delay: float = 1.0timeout: float = 30.0
GuardApiError
Class · from promptguard import GuardApiError
GuardApiError(...)
GuardClient
Class · from promptguard import GuardClient
GuardClient(...)
GuardClient.scan
GuardClient.scan_async
GuardClient.close
GuardClient.aclose
GuardDecision
Class · from promptguard import GuardDecision
blocked: boolredacted: boolallowed: bool
GuardDecision(...)
PromptGuard
Class · from promptguard import PromptGuard
PromptGuard(...)
PromptGuard.close
PromptGuard.chat
Reached as PromptGuard.chat on an instance (a Chat; not constructed directly).
PromptGuard.chat.completions
Reached as PromptGuard.chat.completions on an instance (a ChatCompletions; not constructed directly).
PromptGuard.chat.completions.create
PromptGuard.security
Reached as PromptGuard.security on an instance (a Security; not constructed directly).
PromptGuard.security.scan
PromptGuard.security.redact
PromptGuard.agent
Reached as PromptGuard.agent on an instance (a Agent; not constructed directly).
PromptGuard.agent.validate_tool
PromptGuard.agent.stats
PromptGuard.redteam
Reached as PromptGuard.redteam on an instance (a RedTeam; not constructed directly).
PromptGuard.redteam.list_tests
PromptGuard.redteam.run_test
PromptGuard.redteam.run_all
PromptGuard.redteam.run_custom
PromptGuardAsync
Class · from promptguard import PromptGuardAsync
PromptGuardAsync(...)
PromptGuardAsync.close
PromptGuardAsync.chat
Reached as PromptGuardAsync.chat on an instance (a AsyncChat; not constructed directly).
PromptGuardAsync.chat.completions
Reached as PromptGuardAsync.chat.completions on an instance (a AsyncChatCompletions; not constructed directly).
PromptGuardAsync.chat.completions.create
PromptGuardAsync.security
Reached as PromptGuardAsync.security on an instance (a AsyncSecurity; not constructed directly).
PromptGuardAsync.security.scan
PromptGuardAsync.security.redact
PromptGuardAsync.agent
Reached as PromptGuardAsync.agent on an instance (a AsyncAgent; not constructed directly).
PromptGuardAsync.agent.validate_tool
PromptGuardAsync.agent.stats
PromptGuardAsync.redteam
Reached as PromptGuardAsync.redteam on an instance (a AsyncRedTeam; not constructed directly).
RedTeam; see it for why the paths moved and why run_autonomous / intelligence_stats are gone.
PromptGuardAsync.redteam.list_tests
PromptGuardAsync.redteam.run_test
PromptGuardAsync.redteam.run_all
PromptGuardAsync.redteam.run_custom
PromptGuardBlockedError
Class · from promptguard import PromptGuardBlockedError
PromptGuardBlockedError(...)
PromptGuardError
Class · from promptguard import PromptGuardError
PromptGuardError(...)
SecurityScanResult
Class · from promptguard import SecurityScanResult
security.scan call.
blocked: booldecision: strreason: strthreat_type: strconfidence: float
__version__
Constant · from promptguard import __version__
init
Function · from promptguard import init
instrumentation_report
Function · from promptguard import instrumentation_report
is_active
Function · from promptguard import is_active
True when auto-instrumentation is initialised (a guard client is installed). Note this is independent of whether any SDK was patchable — use :func:patched_sdks to confirm specific SDKs are instrumented.
patched_sdks
Function · from promptguard import patched_sdks
init().
shutdown
Function · from promptguard import shutdown
verify
Function · from promptguard import verify
promptguard.integrations.langchain
LangChain integration - PromptGuardCallbackHandler.
LangChainCallbackHandler
Alias · from promptguard.integrations.langchain import LangChainCallbackHandler
PromptGuardCallbackHandler.
PromptGuardCallbackHandler
Class · from promptguard.integrations.langchain import PromptGuardCallbackHandler
PromptGuardCallbackHandler(...)
PromptGuardCallbackHandler.on_llm_start
PromptGuardCallbackHandler.on_chat_model_start
PromptGuardCallbackHandler.on_llm_end
PromptGuardCallbackHandler.on_llm_error
PromptGuardCallbackHandler.on_chain_start
PromptGuardCallbackHandler.on_chain_end
PromptGuardCallbackHandler.on_chain_error
PromptGuardCallbackHandler.on_tool_start
PromptGuardCallbackHandler.on_tool_end
PromptGuardCallbackHandler.on_tool_error
PromptGuardRunnable
Class · from promptguard.integrations.langchain import PromptGuardRunnable
PromptGuardRunnable(...)
PromptGuardRunnable.guard_value
value; return it (possibly redacted) or raise on a block.
PromptGuardRunnable.as_runnable
guard_value in a langchain_core RunnableLambda.
promptguard.integrations.llamaindex
LlamaIndex integration - PromptGuardCallbackHandler for LlamaIndex.
LlamaIndexCallbackHandler
Alias · from promptguard.integrations.llamaindex import LlamaIndexCallbackHandler
PromptGuardCallbackHandler.
PromptGuardCallbackHandler
Class · from promptguard.integrations.llamaindex import PromptGuardCallbackHandler
PromptGuardCallbackHandler(...)
PromptGuardCallbackHandler.on_event_start
PromptGuardCallbackHandler.on_event_end
PromptGuardCallbackHandler.start_trace
PromptGuardCallbackHandler.end_trace
PromptGuardQueryGuard
Class · from promptguard.integrations.llamaindex import PromptGuardQueryGuard
PromptGuardQueryGuard(...)
PromptGuardQueryGuard.guard_query
query_str; return it (possibly redacted) or raise on a block.
PromptGuardQueryGuard.as_query_component
guard_query in a LlamaIndex FnComponent.
promptguard.integrations.crewai
CrewAI integration - guardrail function and tool wrapper.
PromptGuardGuardrail
Class · from promptguard.integrations.crewai import PromptGuardGuardrail
PromptGuardGuardrail(...)
session_id names the Conversation the crew’s scans belong to. CrewAI has no conversation id of its own, so without one none is sent.
PromptGuardGuardrail.before_kickoff
PromptGuardGuardrail.after_kickoff
PromptGuardGuardrail.scan_task_output
secure_tool
Function · from promptguard.integrations.crewai import secure_tool
_run method with PromptGuard.
promptguard.integrations.fastapi
ASGI middleware - scans prompt-shaped request bodies at the app’s edge.
extract_scan
Function · from promptguard.integrations.fastapi import extract_scan
PromptGuardMiddleware
Class · from promptguard.integrations.fastapi import PromptGuardMiddleware