SDK Integration • Step 1

Integrate in 5 Minutes

Use the NotionAlpha Clarity SDK for automatic cost tracking, security detection, and outcome tracking. Drop-in replacement for OpenAI, Anthropic, and Azure OpenAI SDKs with built-in transaction ID capture.

Automatic Transaction ID Capture

SDK automatically captures transaction IDs for outcome tracking - no manual header extraction needed.

Real-Time Cost Tracking

Every request is automatically tracked with team-level cost attribution and budget enforcement.

Built-in Outcome Tracking

One-line outcome tracking with automatic ROI calculation. Link business value to LLM costs instantly.

SDK Examples

Choose Your SDK

Select an SDK below to see integration examples. All examples use the same pattern: change the endpoint and add attribution headers.

openai-integration.ts
// Install: npm install @notionalpha/clarity-sdk openai
import { NotionAlphaClient } from '@notionalpha/clarity-sdk';

// Initialize client
const clarity = new NotionAlphaClient({
  orgId: process.env.NOTIONALPHA_ORG_ID!,
  teamId: process.env.NOTIONALPHA_TEAM_ID!,
  environment: 'production',
  provider: {
    type: 'openai',
    providerId: process.env.NOTIONALPHA_PROVIDER_ID!
  }
});

// Make LLM call (FinOps + Security automatic)
const { response, transactionId } = await clarity.chat.completions.create({
  model: 'gpt-4o-mini',
  messages: [{ role: 'user', content: 'Hello!' }]
});

console.log(response.choices[0].message.content);
// ✅ Cost automatically tracked
// ✅ Security threats automatically detected
// ✅ Transaction ID captured for outcome tracking

Environment Variables

# NotionAlpha Configuration
NOTIONALPHA_PROVIDER_ID=ca2399ae-2dd4-4543-a078-1f009cd09f78
NOTIONALPHA_ORG_ID=e96ff6c3-fcac-40b9-b905-6d49f39bd0e2  # Internal UUID (NOT Clerk org ID)
NOTIONALPHA_TEAM_ID=b3ddb8d1-b2af-414f-bf16-a87beba0042d
NOTIONALPHA_ENVIRONMENT=Production  # Production, Staging, or Development

# Note: Your OpenAI API key is stored securely in Cloudflare KV
# No need to include it in your environment variables

Important: Get your internal Organization ID (UUID format) from the Providers page in the NotionAlpha dashboard.

This is NOT your Clerk organization ID (org_xxxxx format). The internal UUID is required for proper usage tracking.

✓ Security: API keys are stored securely in Cloudflare KV and never exposed in your application code.

Required Headers

HeaderRequiredDescriptionExample
X-Org-IDYesInternal organization UUID from dashboarde96ff6c3-fcac-40b9...
X-Team-IDYesTeam UUID for cost attributionb3ddb8d1-b2af-414f...
X-EnvironmentYesDeployment environment (case-sensitive)Production, Staging, Development
X-Feature-IDNoOptional feature identifier for trackingchat-assistant

⚠️ Important: Environment values are case-sensitive. Use Production, Staging, or Development (capitalized).

Ready for Step 2?

You've integrated the NotionAlpha proxy to track LLM costs. Now track the business value your AI creates.

Link business outcomes (tickets resolved, code generated, time saved) to LLM transactions for automatic ROI calculation. CFOs and CIOs see real-time value dashboards.

Track Business Outcomes