# Quickstart

Get Started in 5 Minutes

This guide walks you through creating an account, making your first API call, and verifying that PII is being redacted.

Step 1: Get Your API Key

Contact us to create your account and receive your Aptly API key:

Expected Response
{
  "customer": {
    "id": "cus_abc123",
    "email": "you@company.com",
    "plan": "pro"
  },
  "api_key": {
    "key": "apt_live_xyz789...",
    "rate_limit_per_hour": 10000
  }
}

Note: Save your API key securely. It won't be shown again.

Step 2: Make Your First Request

If you're already using the OpenAI SDK, the change is trivial—just update the base_url:

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api-aptly.nsquaredlabs.com/v1",
    api_key="apt_live_your_key_here"
)

response = client.chat.completions.create(
    model="gpt-4",
    messages=[{
        "role": "user",
        "content": "My email is john.doe@example.com and my SSN is 123-45-6789"
    }],
    # Pass your OpenAI key in the request
    extra_body={
        "api_keys": {
            "openai": "sk-your-openai-key"
        }
    }
)

print(response.choices[0].message.content)
print(response.aptly.pii_detected)  # True
print(response.aptly.pii_entities)  # ['EMAIL_ADDRESS', 'US_SSN']
JavaScript/TypeScript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api-aptly.nsquaredlabs.com/v1',
  apiKey: 'apt_live_your_key_here',
});

const response = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{
    role: 'user',
    content: 'My email is john.doe@example.com and my SSN is 123-45-6789'
  }],
  // Pass your OpenAI key in the request
  api_keys: {
    openai: 'sk-your-openai-key'
  }
});

console.log(response.choices[0].message.content);
console.log(response.aptly.pii_detected);  // true
console.log(response.aptly.pii_entities);  // ['EMAIL_ADDRESS', 'US_SSN']

Step 3: Verify PII Redaction

The response includes metadata about what PII was detected and redacted:

Response Metadata
{
  "aptly": {
    "audit_log_id": "log_abc123",
    "pii_detected": true,
    "pii_entities": ["EMAIL_ADDRESS", "US_SSN"],
    "response_pii_detected": false,
    "response_pii_entities": [],
    "compliance_framework": "gdpr",
    "latency_ms": 245
  }
}

What actually got sent to OpenAI (with default mask mode):

"My email is EMAIL_ADDRESS_A and my SSN is US_SSN_A"

Step 4: Check Your Audit Logs

Every request creates an immutable audit log entry. Query your logs via the API:

curl
curl https://api-aptly.nsquaredlabs.com/v1/logs \
  -H "Authorization: Bearer apt_live_your_key_here"

The response includes all your logged requests with PII detection details, timestamps, and costs.

What's Next