Getting started
Developer samples for integrating the Guard Dog library into applications, agent workflows and provider traffic.
Run your first sample.
- Install the Guard Dog wheel in a Python 3.11+ virtual environment.
- Download and extract the samples ZIP, then open a terminal in the extracted folder.
- Use that environment’s Python to run a local example:
python samples/integrations/custom_scan.py
python samples/integrations/batch_scan.pyThe first sample prints the results for the configured presets. The batch example prints one result per input, in the original order. These two examples use local fixture text and require no provider account.
The library is installed separately. Keep its release version with your sample results and inspect the findings produced by your selected policy.
Library and application samples
Use these examples to add checks to your own application, work with multiple inputs, apply PII masking or inspect tool and response boundaries. Select a sample name to download its Python file.
| Sample | What it shows | Dependencies |
|---|---|---|
Presets and application integrationcustom_scan.py | Compare presets, use conversation context, scan tool/output content and compose field-policy middleware. | Guard Dog; Starlette, HTTPX and Uvicorn for middleware modes. |
Stateful application checksguarddog_class.py | Compare block, report and learn behavior with GuardDog and RunMode. | Guard Dog. |
Batch scanningbatch_scan.py | Scan independent inputs concurrently and keep results in input order. | Guard Dog. |
PII maskingpii_pipeline.py | Compare default scanning with PII masking and demonstrate an in-memory detokenization round trip. | Guard Dog. |
Agent and tool boundariesagent_tool_boundaries.py | Inspect tool arguments, tool results and an agent write boundary. | Guard Dog. |
Completed streaming responsesstreaming_egress.py | Accumulate response chunks and inspect the complete message at its boundary. | Guard Dog. |
ASGI input and output controlsasgi_egress_enforcement.py | Use an offline backend to compare report, redact and block responses. | Guard Dog, Starlette and HTTPX. |
MCP client sample
The stdio client starts the installed server, discovers its tools and invokes scan_text with conversation and role context.
Install the MCP dependencies and configure the client, then run:
python samples/integrations/mcp_client.pyProvider and framework integrations
These examples make requests to the configured provider when you run them. Each file lists its credential and model environment variables. Use a model available to your account and install the SDK dependencies for the example you choose.
| Sample | What it shows | Dependencies |
|---|---|---|
OpenAI SDKopenai_chat.py | Route an OpenAI-compatible client through the local sample gateway. | OpenAI SDK; configured upstream provider. |
Anthropic Messagesanthropic_messages.py | Send the Anthropic Messages API through the sample gateway’s /v1/messages route. | Anthropic SDK; configured upstream provider. |
OpenRouteropenrouter_chat.py | Use HTTPX with an OpenRouter-compatible gateway route. | HTTPX; configured OpenRouter upstream. |
Hugging Face Inferencehuggingface_inference.py | Scan input locally before submitting it to the configured inference model. | Guard Dog and HTTPX; Hugging Face inference access. |
LangChainlangchain_chat.py | Compose an application-side scan with a ChatOpenAI client pointed at the gateway. | Guard Dog, langchain-openai and langchain-core. |
LiteLLMlitellm_example.py | Scan text locally before a LiteLLM completion request. | Guard Dog and LiteLLM; configured provider. |
Local multi-provider gateway sample
The FastAPI teaching gateway scans inbound OpenAI-compatible and Anthropic requests before forwarding them. It runs on loopback by default, rejects streaming and does not inspect output or authenticate callers.
python -m pip install fastapi uvicorn httpx
python samples/proxy/gateway_multi_provider.pyBefore launching, load the template’s values into the process environment and set the upstream provider credential. The program does not automatically load a .env file. Point the provider SDK examples at GUARD_DOG_PROXY=http://127.0.0.1:8090.
For authenticated input/output inspection and buffered streaming, use the packaged gateway setup guide.
Capability status and deployment evidence
Capability scope · 17 October 2026
SupportedPresent in the accepted artifact or the stated verified LAB deployment. This does not imply general production acceptance or live activation on every host.
BetaImplemented source or pilot with incomplete release, host or operational acceptance.
PlannedIntended capability without accepted implementation or rollout.
Record the version, environment and evidence for each capability. Installation alone does not enable every capability.
Guard Dog Code operation coverage gives the 17 October Supported, Beta and Planned boundaries, exact host operations and evidence limits. Editable Word masters remain the authoritative documentation deliverables; private packages and held CISO materials are not released by this website alignment.