A simple example demonstrating OpenAI's gpt-oss-safeguard-20b model via OpenRouter provider with PIIBlockPolicy for detecting and blocking personally identifiable information.
Set your OpenRouter API key:
export OPENROUTER_API_KEY="your-api-key"
export OPENAI_API_KEY="your-api-key"Install dependencies from upsonic_configs.json:
upsonic installAdd a new package:
upsonic add <package> <section>
# Examples:
upsonic add requests api
upsonic add pandas==2.0.0 apiRemove a package:
upsonic remove <package> <section>
# Examples:
upsonic remove requests apiSections: api, streamlit, development
uv run main.pyRuns built-in test cases (safe query + PII query).
upsonic runStarts server at http://localhost:8000 with Swagger docs at /docs.
Example API call:
curl -X POST http://localhost:8000/call \
-H "Content-Type: application/json" \
-d '{"user_query": "My email is john@example.com, can you help me with my account?"}'- Safe queries → Normal AI response
- Queries with PII (emails, phone numbers, etc.) → Blocked with helpful feedback suggesting how to rephrase
| File | Purpose |
|---|---|
main.py |
Agent with safety policy |
upsonic_configs.json |
Dependencies & API schema |