Overview
ScopeGuard-2 checks whether a user message is in scope for your AI service before your LLM answers it. On the hosted API it runs on our servers: you send the conversation and your AI service description, and get back one of seven scope classes, with nothing to download or serve.
The hosted API serves one model, scope-guard-v2-pro-2609, the Pro version of ScopeGuard-2, not published on Hugging Face. It is the default when you leave out model.
Quickstart
With your API key, send the conversation so far, ending with the user's message:
- Python
- cURL
Setup
pip install orbitals # Python 3.10 or later
export PRINCIPLED_API_KEY="principled_..."
first_call.py
from orbitals.scope_guard_v2 import ScopeGuardV2
sg = ScopeGuardV2(
backend="api",
api_url="https://api.orbitals.principled.app",
)
result = sg.validate(
[
{
"role": "user",
"content": "I ordered a package, tracking number 1234567890",
},
{
"role": "assistant",
"content": (
"Great, the package is in transit. "
"What would you like to know?"
),
},
{
"role": "user",
"content": "If it does not arrive tomorrow, can I get a refund?",
},
],
ai_service_description=(
"A virtual assistant for a parcel delivery service. "
"It tracks packages by tracking number "
"and gives expected delivery dates. "
"It never handles refund requests."
),
)
print(result.scope_class.value)
Run it
$ python first_call.py
Restricted
Setup
export PRINCIPLED_API_KEY="principled_..."
curl -sS -X POST \
"https://api.orbitals.principled.app/orbitals/scope-guard-v2/validate" \
-H "X-API-Key: $PRINCIPLED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
conversationstring | object | object[]requiredA bare string is one user message, a single object must have role "user" and a list must end with a user message.: [
{
"role": "user",
"content": "I ordered a package, tracking number 1234567890"
},
{
"role": "assistant",
"content": "Great, the package is in transit. What would you like to know?"
},
{
"role": "user",
"content": "If it does not arrive tomorrow, can I get a refund?"
}
],
ai_service_descriptionstring | objectrequiredPlain text or a Structured V2 object; unknown keys are a 422. Which field drives which class: Scope classes.: "A virtual assistant for a parcel delivery service. It tracks packages by tracking number and gives expected delivery dates. It never handles refund requests."
}'
Your code branches on scope_class. Every other field and endpoint is in the Reference.