# Regional Routing & Privacy

> OpenGen keeps endpoint region, inference scope, processing regions, and storage residency strictly distinct. Every catalog route attaches a PublicPrivacyDisclosure where unestablished residency, logs, retention, and Zero Data Retention facts stay null. All user prompts, inputs, and outputs remain workspace-private with no public gallery and on-demand output purging.

## Agent Prompt

```text
Apply regional routing and privacy checks before submitting OpenGen generations using https://opengen.dev/docs/regional-routing:
1. Inspect route privacy disclosures via GET https://opengen.dev/v1/models/{provider}/{model} or GET https://opengen.dev/v1/routes (or MCP get_model). Never infer processing residency, storage residency, or Zero Data Retention from endpointRegion or optional provider headers alone — check whether each fact's value is non-null with dated evidence.
2. Constrain execution explicitly with either routeId (exact pinned route) or routing ({ providerIds, deploymentIds, endpointRegions, processingRegions, processingScopes, authorOnly, preference, fallback }).
3. Run POST https://opengen.dev/v1/pricing/estimate (or MCP estimate_cost) with those routing constraints to confirm an eligible route and spend ceiling before asking the user to approve and submitting with an Idempotency-Key.
```

## Endpoint region is not data residency

Many media gateways conflate an API hostname with where inference runs or where assets are stored. OpenGen separates four distinct attributes on every deployment and route:

| Field                                 | Meaning                                                             | Observed Values in Catalog                                                                                     |
| ------------------------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `endpointRegion`                      | Geographic region where the provider's API HTTP endpoint terminates | `ap-southeast-1`, `ap-northeast-1`, `eu-central-1`, `us-east-1`, `cn-beijing`, `cn-hongkong`, or `undisclosed` |
| `inferenceScope` (`deployment.scope`) | Provider's documented routing scope for that endpoint               | `regional`, `mainland-china`, `international`, `global`, or `undisclosed`                                      |
| `processingRegions`                   | Verified regions where model inference actually executes            | Array of region codes, or **`null`** when not established                                                      |
| `storageRegions`                      | Verified regions where provider-side inputs/outputs are stored      | Array of region codes, or **`null`** when not established                                                      |

> [!WARNING]
> Selecting `endpointRegions: ["eu-central-1"]` or `endpointRegions: ["ap-southeast-1"]` routes requests to that documented regional API endpoint, but **does not** establish per-request processing or storage residency unless the provider documents and OpenGen qualifies non-null `processingRegions` / `storageRegions` evidence.

## Public supplier privacy disclosures (`privacyDisclosure`)

Every route returned by `GET /v1/routes`, `GET /v1/models/{provider}/{model}`, `GET /v1/collections/{slug}`, and MCP `get_model` includes a `privacyDisclosure` object. Each privacy fact is represented as `{ "value": <value | null>, "evidence": { "source": "https://...", "checkedAt": "YYYY-MM-DD", "status": "documented" | "live-verified" } | null }`.

Whenever a provider has not established a guarantee at the public catalog level, OpenGen sets **`value: null` and `evidence: null`** rather than guessing:

- `endpointRegion` and `inferenceScope` (populated when documented, `null` when `undisclosed`)
- `processingRegions` and `storageRegions` (`null` unless explicitly qualified)
- `payloadHistory` (`"disabled" | "enabled" | null`)
- `deploymentLogs` (`"disabled" | "enabled" | null`)
- `maxDataRetentionSeconds` (integer seconds or `null`)
- `zeroDataRetention` (boolean or `null`)
- `controls`: documented opt-in provider controls (`payloadHistoryOptOut`, `outputExpiryControl`, `privateOutputAcl`)
- `notes`: plain-language caveats summarizing what is and is not established

> [!IMPORTANT]
> On `fal` routes, OpenGen documents the provider's `controls` (`X-Fal-Store-IO: 0` for payload history opt-out and `X-Fal-Object-Lifecycle-Preference` for CDN expiry and output ACL), while keeping `deploymentLogs`, `maxDataRetentionSeconds`, and `zeroDataRetention` as `null`. Neither header disables deployment logs or establishes Zero Data Retention (ZDR) or regional residency.

## Request-level routing controls

You can control route selection on `POST /v1/pricing/estimate`, `POST /v1/generations`, and MCP `estimate_cost` / `generate` in two ways:

1. **Pin one exact route (`routeId`)**: Pass `"routeId": "alibaba/ap-southeast-1/wan-3.0"` (or another canonical ID from `GET /v1/routes`) to lock execution to that exact deployment and model.
2. **Declarative constraints (`routing`)**: Filter candidate routes and choose ranking and fallback behavior:
   - `providerIds`: restrict to specific serving providers (e.g., `["alibaba", "byteplus"]`).
   - `deploymentIds`: restrict to specific regional deployments (e.g., `["alibaba-model-studio-ap-southeast-1"]`).
   - `endpointRegions`: restrict by API endpoint region (e.g., `["ap-southeast-1", "ap-northeast-1"]`).
   - `processingRegions`: require qualified processing residency regions (fails with `422 no_executable_route` if no route establishes them).
   - `processingScopes`: restrict by `deployment.scope` (`"regional"`, `"mainland-china"`, `"international"`, `"global"`, `"undisclosed"`).
   - `authorOnly`: boolean — when `true`, restrict serving routes strictly to the model creator's own `authorProviderIds` (for example OpenAI for [GPT Image 2](/openai/gpt-image-2) or Alibaba for [Wan 3.0](/alibaba/wan-3.0)).
   - `fidelity`: `"any"` or `"native"`.
   - `preference`: `"cost"`, `"speed"`, or `"reliability"`.
   - `fallback`: boolean — set `false` to prevent automatic failover to another candidate route if the primary route fails before dispatch.

```bash tab="cURL"
# Pin Alibaba Model Studio Singapore with no cross-region fallback
curl --fail-with-body -X POST "$OPENGEN_API_URL/v1/pricing/estimate" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "modelId": "alibaba/wan-3.0",
    "operation": "text-to-video",
    "input": {
      "prompt": "Slow dolly shot over rain-slicked granite courtyard at dawn",
      "resolution": "480p",
      "duration": 5,
      "aspectRatio": "16:9"
    },
    "routing": {
      "authorOnly": true,
      "endpointRegions": ["ap-southeast-1"],
      "fallback": false,
      "preference": "cost"
    }
  }'
```

```ts tab="TypeScript"
const baseUrl = process.env.OPENGEN_API_URL ?? 'https://opengen.dev';

const estimate = await fetch(`${baseUrl}/v1/pricing/estimate`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.OPENGEN_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    modelId: 'alibaba/wan-3.0',
    operation: 'text-to-video',
    input: {
      prompt: 'Slow dolly shot over rain-slicked granite courtyard at dawn',
      resolution: '480p',
      duration: 5,
      aspectRatio: '16:9',
    },
    routing: {
      authorOnly: true,
      endpointRegions: ['ap-southeast-1'],
      fallback: false,
      preference: 'cost',
    },
  }),
}).then((r) => r.json());

console.log(estimate.selectedRouteId, estimate.candidates);
```

```python tab="Python"
import os
import httpx

base_url = os.environ.get("OPENGEN_API_URL", "https://opengen.dev")

response = httpx.post(
    f"{base_url}/v1/pricing/estimate",
    headers={"Authorization": f"Bearer {os.environ['OPENGEN_API_KEY']}"},
    json={
        "modelId": "alibaba/wan-3.0",
        "operation": "text-to-video",
        "input": {
            "prompt": "Slow dolly shot over rain-slicked granite courtyard at dawn",
            "resolution": "480p",
            "duration": 5,
            "aspectRatio": "16:9",
        },
        "routing": {
            "authorOnly": True,
            "endpointRegions": ["ap-southeast-1"],
            "fallback": False,
            "preference": "cost",
        },
    },
    timeout=30.0,
)
response.raise_for_status()
print(response.json()["selectedRouteId"])
```

```json tab="MCP"
{
  "tool": "estimate_cost",
  "arguments": {
    "modelId": "alibaba/wan-3.0",
    "operation": "text-to-video",
    "input": {
      "prompt": "Slow dolly shot over rain-slicked granite courtyard at dawn",
      "resolution": "480p",
      "duration": 5,
      "aspectRatio": "16:9"
    },
    "routing": {
      "authorOnly": true,
      "endpointRegions": ["ap-southeast-1"],
      "fallback": false,
      "preference": "cost"
    }
  }
}
```

```bash tab="CLI"
cat <<'EOF' > regional-request.json
{
  "modelId": "alibaba/wan-3.0",
  "operation": "text-to-video",
  "input": {
    "prompt": "Slow dolly shot over rain-slicked granite courtyard at dawn",
    "resolution": "480p",
    "duration": 5,
    "aspectRatio": "16:9"
  },
  "routing": {
    "authorOnly": true,
    "endpointRegions": ["ap-southeast-1"],
    "fallback": false,
    "preference": "cost"
  }
}
EOF

opengen pricing estimate --input regional-request.json
```

## Workspace governance policies

Workspace administrators can attach reusable routing policies (`modelIds`, `modelProviderExceptions`, `authorOnly`, `providerIds`, `deploymentIds`, `endpointRegions`, `processingRegions`, `processingScopes`, `fidelity`, `fallback`, plus `maxCostMicros`) to API keys in `/app/keys`. OAuth grants inherit the intersection of the authorizing credential's policy snapshot and current policy. Request-level routing can only narrow a governance policy — attempting to route outside it returns `403 policy_denied`.

## Workspace privacy and owned media delivery

All user generations, prompts, uploaded inputs, outputs, receipts, and metadata are strictly private to the owning workspace:

- **No public gallery**: OpenGen has no public generation feed, share/publish operation, visibility toggle, or private-content SEO.
- **No leaked provider URLs**: Raw upstream provider output URLs remain internal recovery data (`upstreamId` is always `null` and `storageKey` is stripped on customer responses).
- **First-party signed private capabilities**: Delivered outputs use query-free HMAC-signed URLs (`https://opengen.dev/media/v1.<payload>.<hmac>.<ext>`) served with `Cache-Control: private, no-store`, `Content-Security-Policy: default-src 'none'; sandbox`, `Cross-Origin-Resource-Policy: cross-origin`, `Referrer-Policy: no-referrer`, `X-Content-Type-Options: nosniff`, and `X-Robots-Tag: noindex, nofollow, noarchive`.
- **On-demand output purge**: Call `DELETE /v1/generations/{id}/outputs` (or MCP `purge_job_outputs` / `opengen job purge-outputs <id>`) on any terminal settled job to permanently delete retained output bytes and immediately invalidate all `/media` links (`410 Gone`).

See [Generations Lifecycle](/docs/generations), [Private Assets](/docs/assets), and [/privacy](/privacy) for full operational details.
