AI Chat

AI Chat

Send a prompt to an LLM with automatic PII encoding/decoding. The prompt is encoded before reaching the LLM, and the LLM's response is decoded back to original values.

The full pipeline is:

  1. Your prompt is scanned for PII
  2. PII is replaced with Privacy Twins
  3. The encoded prompt is sent to the LLM
  4. The LLM response (containing Privacy Twins) is decoded
  5. You receive both the raw LLM response and the decoded version

SDK Usage:

const result = await client.chatWithAI({
  prompt: 'Analyze credit history for John Doe at john@company.com',
  model: 'gemini-2.0-flash-exp',
  provider: 'vertex'
});
post/api/ai/chat

Request body

promptstring required

User prompt (will be automatically encoded to remove PII before reaching the LLM)

sessionIdstring

Session tracking ID for multi-turn conversations

sessionContinuationIdsstring[]

Continuation IDs from prior conversation turns (enables cross-turn decoding)

modelstring

LLM model name

provider'vertex' | 'aws' | 'mock'

LLM provider

temperaturenumber double

Generation temperature (higher = more creative)

maxTokensinteger

Maximum tokens in the LLM response

Example request

{
  "prompt": "Analyze credit history for John Doe at john@company.com",
  "model": "gemini-2.0-flash-exp",
  "provider": "vertex"
}

Response

AI chat response with decoded PII

successboolean
originalPromptstring

The original user prompt (with real PII)

encodedPromptstring

The prompt sent to the LLM (PII replaced with Privacy Twins)

llmResponsestring

Raw LLM response (contains Privacy Twins)

decodedResponsestring

Final response with Privacy Twins decoded back to original values

continuationIdstring
processingTimeMsnumber

Example response

{
  "encoding": {
    "transformations": [
      {
        "components": [
          {
            "original": "John",
            "twin": "Maria",
            "type": "FIRST_NAME"
          }
        ]
      }
    ]
  }
}

Changes