> ## Documentation Index
> Fetch the complete documentation index at: https://humain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox

> Test your integration without consuming LLM credits or generating billing events — using a dedicated sandbox credential, not a different URL.

## What is the sandbox?

Sandbox is a property of the **credential**, not a different environment or base URL. Every
credential is issued as either `hk_live_…` (production) or `hk_test_…` (sandbox); both work
against the exact same `https://api.humain.ai` host and the exact same endpoints.

> [!WARNING]
>
> There is no separate sandbox base URL. If you've seen `sandbox.api.humain.ai` referenced
> elsewhere, that's stale — always call `https://api.humain.ai` and control sandbox behavior
> by which credential you use.

Authentication-level checks run identically for both credential types — an inactive kiosk or a
FraudGuard-blocked credential is rejected the same way whether the token is `hk_live_` or
`hk_test_`. What differs is what happens *inside* a session opened with a sandbox credential.

## Issuing a sandbox credential

In the admin panel, when you issue a new credential under **Kiosk → Credentials**, choose
**Sandbox** instead of **Live**. This mints an `hk_test_…` token rather than `hk_live_…` —
everything else about the issuance flow is identical.

## What happens in a sandbox session

> [!TIP]
>
> Sandbox sessions skip the turn pipeline entirely for the conversational content — there is no
> LLM call, and critically, **no per-turn guardrail or FraudGuard check runs either**, since
> those checks live inside the same pipeline step that's being skipped. Don't rely on the
> sandbox to validate your guardrail configuration.

### Text sessions

A sandbox text session **echoes your message back verbatim** over the WebSocket — no LLM call,
no guardrail pipeline, no usage event:

```json theme={null}
// You send:
{"type": "message", "content": "What are your opening hours?"}

// You receive:
{"type": "response", "content": "What are your opening hours?", "message_id": "..."}
```

### Voice sessions

A sandbox voice session still runs the full WebRTC pipeline — ICE negotiation, DTLS handshake,
and Opus audio transport all function normally, including the `control` data channel. Instead of
reaching Gemini Live, the server runs a **record → beep → echo** loop: it plays a short tone,
records your speech, and plays it back to you.

This lets you verify your WebRTC signalling, audio routing, and `VoiceStatus` state machine
without consuming any AI credits.

## What is and isn't simulated

| Behaviour | Sandbox (`hk_test_`) | Production (`hk_live_`) |
| - | - | - |
| Bearer token / credential validation | ✅ Real | ✅ Real |
| Kiosk active / FraudGuard credential block check | ✅ Real | ✅ Real |
| Session open / close | ✅ Real | ✅ Real |
| WebRTC signalling (voice) | ✅ Real | ✅ Real |
| Per-turn guardrail rules (blocked phrases, PII) | ❌ Skipped | ✅ Real |
| Per-turn FraudGuard checks | ❌ Skipped | ✅ Real |
| LLM inference | ❌ Skipped — echoes input | ✅ Real |
| Gemini Live (voice) | ❌ Skipped — record/beep/echo | ✅ Real |
| Knowledge base retrieval | ❌ Skipped | ✅ Real |
| Usage billing | ❌ Not billed | ✅ Billed |

> [!NOTE]
>
> Because guardrails don't run against the echoed content, you cannot use the sandbox to test
> whether a specific input would be blocked. To test guardrail behavior, use a live credential
> in a low-traffic testing kiosk instead.

## Switching credentials in code

Centralise the credential in one place so switching between sandbox and production is a
one-line change — the base URL never changes.

```javascript JavaScript theme={null}
const CREDENTIAL = process.env.NODE_ENV === 'production'
  ? process.env.HUMAIN_LIVE_CREDENTIAL   // hk_live_...
  : process.env.HUMAIN_SANDBOX_CREDENTIAL; // hk_test_...

const response = await fetch('https://api.humain.ai/v1/sessions', {
  method: 'POST',
  headers: { 'Authorization': `Bearer ${CREDENTIAL}` },
  body: JSON.stringify({ mode: 'text' }),
});
```

```python Python theme={null}
import os

credential = (
    os.environ["HUMAIN_LIVE_CREDENTIAL"]
    if os.environ.get("ENV") == "production"
    else os.environ["HUMAIN_SANDBOX_CREDENTIAL"]
)
```

```go Go theme={null}
credential := os.Getenv("HUMAIN_SANDBOX_CREDENTIAL")
if os.Getenv("ENV") == "production" {
    credential = os.Getenv("HUMAIN_LIVE_CREDENTIAL")
}
```

> [!WARNING]
>
> **Never expose live credentials in client-side code.** Your `hk_live_…` token is a long-lived
> secret. In browser environments, either proxy API calls through your own server or issue an
> `hk_test_…` (sandbox) credential instead for public-facing demos. Treat it like a password.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.