Skip to content

Commit fcaabfe

Browse files
authored
Update links and package name / PR 2
updated links, moved examples into basic folder
2 parents 6d16a8b + 3060449 commit fcaabfe

27 files changed

+133
-140
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 OpenAI
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
install:
33
npm install
44

5+
.PHONY: install-docs
6+
install-docs:
7+
pip install -r requirements.txt
8+
59
.PHONY: format
610
format:
711
npm run format
@@ -20,8 +24,8 @@ build:
2024

2125
.PHONY: build-docs
2226
build-docs:
23-
npm run docs:build
27+
mkdocs build
2428

2529
.PHONY: serve-docs
2630
serve-docs:
27-
npm run docs:serve
31+
mkdocs serve

README.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Clone the repository and install locally:
99

1010
```bash
1111
# Clone the repository
12-
git clone https://github.com/openai/guardrails-js.git
12+
git clone https://github.com/openai/openai-guardrails-js.git
1313
cd guardrails-js
1414

1515
# Install dependencies
@@ -25,7 +25,7 @@ npm run build
2525
The easiest way to use Guardrails TypeScript is as a drop-in replacement for the OpenAI client:
2626

2727
```typescript
28-
import { GuardrailsOpenAI } from '@guardrails/guardrails-ts';
28+
import { GuardrailsOpenAI } from '@openai/guardrails';
2929

3030
async function main() {
3131
// Use GuardrailsOpenAI instead of OpenAI
@@ -60,7 +60,7 @@ main();
6060

6161
### Agents SDK Integration
6262
```typescript
63-
import { GuardrailAgent } from '@guardrails/guardrails-ts';
63+
import { GuardrailAgent } from '@openai/guardrails';
6464
import { Runner } from '@openai/agents';
6565

6666
// Create agent with guardrails automatically configured
@@ -113,7 +113,7 @@ Datasets must be in JSONL format, with each line containing a JSON object:
113113
### Programmatic Usage
114114

115115
```typescript
116-
import { GuardrailEval } from '@guardrails/guardrails-ts';
116+
import { GuardrailEval } from '@openai/guardrails';
117117

118118
const eval = new GuardrailEval(
119119
'configs/my_guardrails.json',
@@ -134,7 +134,7 @@ await eval.run('Evaluating my dataset');
134134

135135
## Examples
136136

137-
The package includes comprehensive examples in the `examples/` directory:
137+
The package includes comprehensive examples in the [`examples/` directory](https://github.com/openai/openai-guardrails-js/tree/main/examples):
138138

139139
- **`agents_sdk.ts`**: Agents SDK integration with GuardrailAgent
140140
- **`hello_world.ts`**: Basic chatbot with guardrails using GuardrailsOpenAI
@@ -160,37 +160,28 @@ npm run build
160160

161161
**Using tsx (Recommended)**
162162
```bash
163-
cd examples
164-
npx tsx agents_sdk.ts # Agents SDK integration
163+
cd examples/basic
165164
npx tsx hello_world.ts # Basic chatbot with guardrails
166-
npx tsx azure_example.ts # Azure OpenAI integration
167-
npx tsx local_model.ts # Local model usage
168-
npx tsx streaming.ts # Streaming responses
169-
npx tsx suppress_tripwire.ts # Handling violations
170165
```
171166

172167
## Available Guardrails
173168

174169
The TypeScript implementation includes the following built-in guardrails:
175170

176-
- **Keywords**: Filters content based on keyword matching
177171
- **Moderation**: Content moderation using OpenAI's moderation API
178-
- **URLs**: URL filtering and domain allowlist/blocklist
179-
- **PII**: Personally Identifiable Information detection
180-
- **NSFW**: Not Safe For Work content detection
172+
- **URL Filter**: URL filtering and domain allowlist/blocklist
173+
- **Contains PII**: Personally Identifiable Information detection
181174
- **Hallucination Detection**: Detects hallucinated content using vector stores
182175
- **Jailbreak**: Detects jailbreak attempts
183-
- **Competitors**: Detects mentions of competitor products
184-
- **Secret Keys**: Detects exposed API keys and secrets
185-
- **Topical Alignment**: Ensures responses stay within business scope
186-
- **User-Defined LLM**: Custom LLM-based guardrails
176+
- **Off Topic Prompts**: Ensures responses stay within business scope
177+
- **Custom Prompt Check**: Custom LLM-based guardrails
187178

188179
## License
189180

190181
MIT License - see LICENSE file for details.
191182

192183
## Disclaimers
193184

194-
Please note that Guardrails may use Third-Party Services such as the [Presidio open-source framework](https://github.com/microsoft/presidio), which are subject to their own terms and conditions and are not developed or verified by OpenAI.
185+
Please note that Guardrails may use Third-Party Services such as the [Presidio open-source framework](https://github.com/microsoft/presidio), which are subject to their own terms and conditions and are not developed or verified by OpenAI. For more information on configuring guardrails, please visit: [platform.openai.com/guardrails](https://platform.openai.com/guardrails)
195186

196187
Developers are responsible for implementing appropriate safeguards to prevent storage or misuse of sensitive or prohibited content (including but not limited to personal data, child sexual abuse material, or other illegal content). OpenAI disclaims liability for any logging or retention of such content by developers. Developers must ensure their systems comply with all applicable data protection and content safety laws, and should avoid persisting any blocked content generated or intercepted by Guardrails.

docs/agents_sdk_integration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Our Guardrails can easily be integrated with OpenAI's Agents SDK using the **Gua
1919
The easiest way to integrate guardrails is using `GuardrailAgent` as a drop-in replacement:
2020

2121
```typescript
22-
import { GuardrailAgent } from '@guardrails/guardrails-ts';
22+
import { GuardrailAgent } from '@openai/guardrails';
2323
import { Runner } from '@openai/agents';
2424

2525
// Create agent with guardrails automatically configured
@@ -99,7 +99,7 @@ const agent = new GuardrailAgent({ config: configDict, ... });
9999

100100
## Next Steps
101101

102-
- Use the [Guardrails Wizard](https://guardrails-vercel-git-main-openai.vercel.app/guardrails) to generate your configuration
102+
- Use the [Guardrails Wizard](https://platform.openai.com/guardrails) to generate your configuration
103103
- Explore available guardrails for your use case
104-
- Learn about pipeline configuration in our [quickstart](./typescript-quickstart.md)
104+
- Learn about pipeline configuration in our [quickstart](./quickstart.md)
105105
- For more details on the OpenAI Agents SDK, refer to the [Agent SDK documentation](https://openai.github.io/openai-agents-js/).

docs/evals.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ npm run eval -- --config-path guardrails_config.json --dataset-path data.jsonl
1414
npm run eval -- --config-path guardrails_config.json --dataset-path data.jsonl --mode benchmark --models gpt-5 gpt-5-mini gpt-5-nano
1515
```
1616

17-
Test with included demo files in our [github repository](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails/src/guardrails/evals/eval_demo)
18-
1917
## Dependencies
2018

2119
The evals tool is included with the TypeScript package. No additional dependencies are required.
@@ -41,7 +39,7 @@ The evals tool is included with the TypeScript package. No additional dependenci
4139

4240
Export a configuration from the Guardrails Wizard UI and pass its path via `--config-path`.
4341

44-
- Open the [Wizard UI](https://oaig-whisper-yonder-xnjpy2.vercel.app/guardrails)
42+
- Open the [Wizard UI](https://platform.openai.com/guardrails)
4543
- Configure the guardrails you want to evaluate
4644
- Use Export to download the config file (JSON)
4745
- Run the evaluator with `--config-path /path/to/exported_config.json`
@@ -162,4 +160,4 @@ npm run eval -- --config-path config.json --dataset-path data.jsonl --base-url h
162160
## Next Steps
163161

164162
- See the [API Reference](./ref/eval/guardrail_evals.md) for detailed documentation
165-
- Use [Wizard UI](https://oaig-whisper-yonder-xnjpy2.vercel.app/guardrails) for configuring guardrails without code
163+
- Use [Wizard UI](https://platform.openai.com/guardrails) for configuring guardrails without code

docs/examples.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Examples
22

3-
Ready-to-run examples demonstrating Guardrails in various scenarios. See the [`examples/`](https://github.com/OpenAI-Early-Access/guardrails-js/tree/main/examples/) folder for complete implementations.
3+
Ready-to-run examples demonstrating Guardrails in various scenarios. See the [`examples/`](https://github.com/openai/openai-guardrails-js/tree/main/examples/) folder for complete implementations.
44

55
## Example Implementations
66

7-
- [hello_world.ts](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples/hello_world.ts) — Basic Guardrails usage
8-
- [agents_sdk.ts](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples/agents_sdk.ts) — OpenAI Agents SDK integration
9-
- [streaming.ts](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples/streaming.ts) — Streaming vs blocking usage
10-
- [suppress_tripwire.ts](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples/suppress_tripwire.ts) — Handle violations without raising
11-
- [multiturn_with_prompt injection detection.ts](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples/multiturn_with_prompt injection detection.ts) — Multi-turn with prompt injection detection
12-
- [azure_example.ts](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples/azure_example.ts) — Azure OpenAI client
13-
- [local_model.ts](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples/local_model.ts) — OpenAI-compatible local endpoint
7+
- [hello_world.ts](https://github.com/openai/openai-guardrails-js/tree/main/examples/basic/hello_world.ts) — Basic Guardrails usage
8+
- [agents_sdk.ts](https://github.com/openai/openai-guardrails-js/tree/main/examples/basic/agents_sdk.ts) — OpenAI Agents SDK integration
9+
- [streaming.ts](https://github.com/openai/openai-guardrails-js/tree/main/examples/basic/streaming.ts) — Streaming vs blocking usage
10+
- [suppress_tripwire.ts](https://github.com/openai/openai-guardrails-js/tree/main/examples/basic/suppress_tripwire.ts) — Handle violations without raising
11+
- [multiturn_with_prompt_injection_detection.ts](https://github.com/openai/openai-guardrails-js/tree/main/examples/basic/multiturn_with_prompt_injection_detection.ts) — Multi-turn with prompt injection detection
12+
- [azure_example.ts](https://github.com/openai/openai-guardrails-js/tree/main/examples/basic/azure_example.ts) — Azure OpenAI client
13+
- [local_model.ts](https://github.com/openai/openai-guardrails-js/tree/main/examples/basic/local_model.ts) — OpenAI-compatible local endpoint
1414

1515
## Getting Started
1616

17-
1. Follow the Quickstart guide: [TypeScript](./typescript-quickstart.md)
18-
2. Explore examples: [TypeScript examples](https://github.com/OpenAI-Early-Access/guardrails-js/tree/main/examples/)
17+
1. Follow the Quickstart guide: [TypeScript](./quickstart.md)
18+
2. Explore examples: [TypeScript examples](https://github.com/openai/openai-guardrails-js/tree/main/examples/)
1919
3. Run scripts to see Guardrails in action
2020

2121
Each example is self-contained with clear configuration and usage patterns.

docs/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Guardrails
22

3-
**Guardrails** is a safety framework for LLM applications that automatically validates inputs and outputs using configurable checks. Use the [Guardrails Wizard](https://guardrails-vercel-git-main-openai.vercel.app/guardrails) to create configurations, then drop in our client classes for automatic validation.
3+
**Guardrails** is a safety framework for LLM applications that automatically validates inputs and outputs using configurable checks. Use the [Guardrails Wizard](https://platform.openai.com/guardrails) to create configurations, then drop in our client classes for automatic validation.
44

55
![Guardrails Wizard](assets/images/guardrails_wizard_screenshot.png)
66

@@ -27,7 +27,7 @@
2727
## Quickstart
2828

2929
```typescript
30-
import { GuardrailsOpenAI } from '@guardrails/guardrails-ts';
30+
import { GuardrailsOpenAI } from '@openai/guardrails';
3131

3232
async function main() {
3333
const client = await GuardrailsOpenAI.create({
@@ -53,9 +53,9 @@ main();
5353

5454
## Next Steps
5555

56-
- [Quickstart: TypeScript](./typescript-quickstart.md)
56+
- [Quickstart](./quickstart.md)
5757
- [Examples](./examples.md) - See real implementations
58-
- [Guardrails Wizard](https://guardrails-vercel-git-main-openai.vercel.app/guardrails) - Create configurations visually
58+
- [Guardrails Wizard](https://platform.openai.com/guardrails) - Create configurations visually
5959

6060
## Disclaimers
6161

docs/typescript-quickstart.md renamed to docs/quickstart.md

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Get started with Guardrails TypeScript in minutes. Guardrails provides drop-in r
55
## Install
66

77
```bash
8-
npm install @guardrails/guardrails-ts
8+
npm install @openai/guardrails
99
```
1010

1111
## Set API Key
@@ -16,7 +16,7 @@ export OPENAI_API_KEY=sk-...
1616

1717
## Create Pipeline Configuration
1818

19-
The fastest way is using the [Guardrails Wizard](https://guardrails-vercel-git-main-openai.vercel.app/guardrails) - a no-code tool for creating configurations.
19+
The fastest way is using the [Guardrails Wizard](https://platform.openai.com/guardrails) - a no-code tool for creating configurations.
2020

2121
Or define manually:
2222

@@ -56,19 +56,11 @@ Replace your OpenAI client with the Guardrails version (`GuardrailsOpenAI`):
5656
We support `chat.completions.create` and `responses.create`.
5757

5858
```typescript
59-
import { GuardrailsOpenAI } from '@guardrails/guardrails-ts';
59+
import { GuardrailsOpenAI } from '@openai/guardrails';
6060

6161
async function main() {
6262
// Use GuardrailsOpenAI instead of OpenAI
63-
const client = await GuardrailsOpenAI.create({
64-
version: 1,
65-
output: {
66-
version: 1,
67-
guardrails: [
68-
{"name": "Moderation", "config": {"categories": ["hate", "violence"]}}
69-
]
70-
}
71-
});
63+
const client = await GuardrailsOpenAI.create('./guardrails_config.json');
7264

7365
try {
7466
const response = await client.responses.create({
@@ -124,19 +116,15 @@ const client = await GuardrailsOpenAI.create(
124116
For OpenAI Agents SDK users, we provide `GuardrailAgent` as a drop-in replacement:
125117

126118
```typescript
127-
import { GuardrailAgent } from '@guardrails/guardrails-ts';
119+
import { GuardrailAgent } from '@openai/guardrails';
128120
import { Runner } from '@openai/agents';
129121

130122
// Create agent with guardrails automatically configured
131-
const agent = await GuardrailAgent.create({
132-
version: 1,
133-
output: {
134-
version: 1,
135-
guardrails: [
136-
{"name": "Moderation", "config": {"categories": ["hate", "violence"]}}
137-
]
138-
}
139-
}, "Customer support agent", "You are a customer support agent. You help customers with their questions.");
123+
const agent = await GuardrailAgent.create(
124+
'./guardrails_config.json',
125+
"Customer support agent",
126+
"You are a customer support agent. You help customers with their questions."
127+
);
140128

141129
// Use exactly like a regular Agent
142130
const result = await Runner.run(agent, "Hello, can you help me?");
@@ -149,38 +137,36 @@ const result = await Runner.run(agent, "Hello, can you help me?");
149137
Use the Azure-specific client:
150138

151139
```typescript
152-
import { GuardrailsAzureOpenAI } from '@guardrails/guardrails-ts';
153-
154-
const client = await GuardrailsAzureOpenAI.create({
155-
version: 1,
156-
output: {
157-
version: 1,
158-
guardrails: [
159-
{"name": "Moderation", "config": {"categories": ["hate", "violence"]}}
160-
]
140+
import { GuardrailsAzureOpenAI } from '@openai/guardrails';
141+
142+
const client = await GuardrailsAzureOpenAI.create(
143+
'./guardrails_config.json',
144+
{
145+
azure_endpoint: "https://your-resource.openai.azure.com/",
146+
api_key: "your-azure-key",
147+
api_version: "2025-01-01-preview"
161148
}
162-
}, {
163-
azure_endpoint: "https://your-resource.openai.azure.com/",
164-
api_key: "your-azure-key",
165-
api_version: "2025-01-01-preview"
166-
});
149+
);
167150
```
168151

169152
## Third-Party Models
170153

171154
Works with any OpenAI-compatible API:
172155

173156
```typescript
174-
import { GuardrailsOpenAI } from '@guardrails/guardrails-ts';
157+
import { GuardrailsOpenAI } from '@openai/guardrails';
175158

176159
// Local Ollama model
177-
const client = await GuardrailsOpenAI.create(config, {
178-
baseURL: "http://127.0.0.1:11434/v1/",
179-
apiKey: "ollama"
180-
});
160+
const client = await GuardrailsOpenAI.create(
161+
'./guardrails_config.json',
162+
{
163+
baseURL: "http://127.0.0.1:11434/v1/",
164+
apiKey: "ollama"
165+
}
166+
);
181167
```
182168

183169
## Next Steps
184170

185-
- Explore TypeScript [examples](https://github.com/OpenAI-Early-Access/guardrails/tree/main/guardrails-ts/examples) for advanced patterns
171+
- Explore TypeScript [examples](https://github.com/openai/openai-guardrails-js/tree/main/examples) for advanced patterns
186172
- Learn about [streaming considerations](./streaming_output.md)

docs/ref/checks/hallucination_detection.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const config = {
5959
### Use with Guardrails Client
6060

6161
```typescript
62-
import { GuardrailsOpenAI } from '@guardrails/guardrails-ts';
62+
import { GuardrailsOpenAI } from '@openai/guardrails';
6363

6464
const client = await GuardrailsOpenAI.create(config);
6565
const response = await client.responses.create({
@@ -80,7 +80,7 @@ console.log(response.llm_response.output_text);
8080

8181
### Complete Example
8282

83-
See [`examples/`](https://github.com/openai/guardrails-js/tree/main/examples) for the full implementation.
83+
See [`examples/`](https://github.com/openai/openai-guardrails-js/tree/main/examples) for the full implementation.
8484

8585
### Notes
8686

docs/ref/exceptions-typescript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Exceptions: TypeScript
22

3-
Exception classes raised by `@guardrails/guardrails-ts`.
3+
Exception classes raised by `@openai/guardrails`.
44

55
```typescript
66
export class GuardrailError extends Error {}
@@ -23,6 +23,6 @@ export class GuardrailExecutionError extends GuardrailError {
2323
- `GuardrailNotFoundError`: referenced guardrail name not registered.
2424
- `GuardrailExecutionError`: runtime failure within a guardrail (optional `cause`).
2525

26-
For the full source, see [guardrails-ts/src/exceptions.ts](https://github.com/OpenAI-Early-Access/guardrails/blob/main/guardrails-ts/src/exceptions.ts) in the repository.
26+
For the full source, see [src/exceptions.ts](https://github.com/openai/openai-guardrails-js/blob/main/src/exceptions.ts) in the repository.
2727

2828

0 commit comments

Comments
 (0)