# Hosted API quickstart

Source: https://orbitals.principled.app/docs/hosted-api/quickstart/

Run your first guardrail: add ScopeGuard-2 to a simple parcel-tracking assistant, so that it blocks every query the assistant must not handle.

## Before you begin

The hosted API is in preview and access is on request: write to us at <orbitals@principled-intelligence.com> and we enable your email domain. Then create your account on the dashboard.

[Orbitals dashboard: Create your account](https://orbitals.principled.app/sign-up)

## Send your first query

### 1. Create an API key

In the [dashboard](https://orbitals.principled.app/), create a key and copy it: the dashboard shows it only once.

![The empty API keys page of the Default project with API keys highlighted in the sidebar](https://orbitals.principled.app/docs/img/dashboard/api-keys-nav.png)

Open API keys in the sidebar

### 2. Query ScopeGuard-2

**Python**

Setup

```bash
pip install orbitals  # Python 3.10 or later
export PRINCIPLED_API_KEY="principled_..."
```

quickstart.py

```python
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

```shell-session
$ python quickstart.py
Restricted
```

**cURL**

Setup

```bash
export PRINCIPLED_API_KEY="principled_..."
```

```bash
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 '{
  "conversation": [
    {
      "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."
}'
```

`Restricted` means your AI service must never process the message, so you do not pass it on to your LLM.

### 3. See it in the dashboard

Back in the dashboard, **Overview** lists your calls under **Recent queries**: click one to open the conversation it checked and the class it got.

![A ScopeGuard-2 query opened from Recent queries on Overview: its three-turn conversation, classified Restricted](https://orbitals.principled.app/docs/img/dashboard/conversation.png)

* [ScopeGuard-2: What it judges and what each scope class means.](https://orbitals.principled.app/docs/guide/orbitals/scope-guard-v2/)
* [ScopeGuard-2 on the hosted API: The same call with a full conversation, in Python and cURL.](https://orbitals.principled.app/docs/hosted-api/scope-guard-v2/overview/)
