Quickstart

Send your first masked prompt through the Privian Chat Completions endpoint using the OpenAI SDK.

1. Get an API key

Sign in and create a gateway key from the dashboard. Keys are prefixedsk-gw_live_ (production) or sk-gw_test_ (non-production) and shown only once at creation time. Privian stores only the SHA-256 hash.

2. The recommended endpoint

New integrations use Privian's OpenAI-compatible Chat Completions endpoint:

text
POST https://api.privian.io/v1/chat/completions

Use it as a drop-in with the OpenAI SDK by setting the base URL tohttps://api.privian.io/v1.

3. cURL

bash
curl -sS -X POST "https://api.privian.io/v1/chat/completions" \
  -H "Authorization: Bearer $GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Hello, my name is Michael" }
    ]
  }'

4. Python (OpenAI SDK)

python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_PRIVIAN_GATEWAY_API_KEY",
    base_url="https://api.privian.io/v1",
)

response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[
        {"role": "user", "content": "Hello, my name is Michael"},
    ],
)

print(response.choices[0].message.content)

5. Node / TypeScript (OpenAI SDK)

ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.PRIVIAN_GATEWAY_API_KEY,
  baseURL: "https://api.privian.io/v1",
});

const response = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  messages: [
    { role: "user", content: "Hello, my name is Michael" },
  ],
});

console.log(response.choices[0].message.content);

What happened

  • Privian deterministically detected sensitive entities in every message before any provider call.
  • The provider (e.g. OpenAI) received only the masked content.
  • Privian rehydrated PII placeholders back to the original values in the returned text. Secrets stay as placeholders by policy.

Legacy endpoint

The original Privian endpoint POST https://api.privian.io/v1/gateway with the { prompt, model } shape remains supported for existing integrations, but new customers should use the OpenAI-compatible Chat Completions endpoint above.

bash
# Legacy API example
curl -sS -X POST "https://api.privian.io/v1/gateway" \
  -H "Authorization: Bearer $GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "prompt": "Hello, my name is Michael"
  }'

Next