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

# Secrets

> Give a sandbox an API key without the key ever entering the sandbox. The platform attaches your real credential to outbound requests.

A **secret** is a credential — an API key, token, or password — that you store once and bind to sandboxes. Code running inside the sandbox never sees the real value. It sees a **stand-in token**, and Superserve swaps that token for your real credential as each request leaves the sandbox — only on requests to the hosts you allow.

This matters because sandboxes run untrusted code. A leaked env var, a prompt-injected agent, or a `printenv` in a log can all expose a raw key. With secrets, there's nothing in the sandbox to leak — the real credential never crosses the boundary.

## How it works

<Steps>
  <Step title="Store the credential">
    `Secret.create()` encrypts the value and stores it with Superserve. You give it a name and the hosts it may authenticate (a [provider shortcut](/secrets/create#provider-shortcuts) sets the hosts for you).
  </Step>

  <Step title="Bind it to a sandbox">
    On `Sandbox.create()`, add it to the `secrets` map — `{ ANTHROPIC_API_KEY: "anthropic-prod" }`. The sandbox gets an `ANTHROPIC_API_KEY` it can read like any other variable, but its value is a **stand-in token**, not your key.
  </Step>

  <Step title="The sandbox makes a request">
    The code calls, say, `api.anthropic.com` with that token, exactly as it would with a real key.
  </Step>

  <Step title="Superserve attaches the real key">
    On the way out, Superserve recognizes the token, swaps in your real credential for that host, and forwards the request. The service sees your real key; the sandbox never did.
  </Step>
</Steps>

<Note>
  Secrets are **host-scoped**. A secret for `api.anthropic.com` is only ever attached to requests to that host. Sent anywhere else, the stand-in token is useless.
</Note>

## When to use secrets

Use secrets for anything that **authenticates** — API keys, tokens, passwords. For non-sensitive configuration like log levels, feature flags, or public URLs, plain [`envVars`](/sandbox/environment-variables) is simpler and works fine.

## Provider shortcuts

For common services, a **provider shortcut** preconfigures the auth scheme and allowed hosts so you only supply a name and value:

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  import { Secret } from "@superserve/sdk"

  await Secret.create({
    name: "anthropic-prod",
    value: process.env.ANTHROPIC_API_KEY!,
    provider: "anthropic",
  })
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  import os

  from superserve import Secret

  Secret.create(
      name="anthropic-prod",
      value=os.environ["ANTHROPIC_API_KEY"],
      provider="anthropic",
  )
  ```
</CodeGroup>

Built-in shortcuts span LLM APIs (Anthropic, OpenAI, Gemini, OpenRouter, …), dev tools (GitHub, GitLab, Vercel, Cloudflare), and SaaS (Stripe, Notion, Resend, …). Call [`Provider.list()`](/secrets/create#provider-shortcuts) for the current list, or define your own auth with [custom secrets](/secrets/create#custom-secrets).

## Next steps

<CardGroup cols={2}>
  <Card title="Create a secret" icon="key" href="/secrets/create">
    Provider shortcuts, custom auth, and rotation.
  </Card>

  <Card title="Bind to a sandbox" icon="link" href="/secrets/binding">
    Attach secrets to environment variables at create time.
  </Card>

  <Card title="Audit usage" icon="list-checks" href="/secrets/audit">
    See every request made with a secret.
  </Card>

  <Card title="Network log" icon="globe" href="/sandbox/network-log">
    See everything a sandbox reached on the network.
  </Card>
</CardGroup>
