Skip to main content
This guide walks you through integrating White Circle into an AI-powered code generation app. You’ll learn how to moderate user prompts, validate generated code for security issues, track sessions, and identify high-risk users.

Overview

AI code generation apps face unique moderation challenges:
  • Users may request malicious code such as malware, exploits, or scripts designed to harm systems
  • Generated code might contain vulnerabilities like SQL injection, XSS, or hardcoded credentials
  • Prompt injection attacks can manipulate the AI into bypassing safety guidelines
  • Users may attempt to extract proprietary code or system prompts from the AI
White Circle addresses all of these by providing real-time content moderation for both prompts and generated code.
Only the last message is evaluated for violations. When you send a conversation with multiple messages, White Circle evaluates only the final message against your policies. Previous messages provide context but are not flagged. This means you should send user prompts and AI-generated code separately for individual moderation.

Prerequisites

Before you begin, make sure you have:
  • A White Circle account with access to the dashboard
  • A working AI code generation app (this guide uses examples with OpenAI’s API, but works with any provider)

Architecture

Here’s how White Circle fits into your vibe coding app architecture:

Step 1: Create an API Key

Create an API key to authenticate your requests to White Circle.
  1. Go to the API Keys page
  2. Click Create API Key
  3. Name it something descriptive like vibe-coding-production
  4. Copy the key and store it securely — you won’t be able to see it again

Step 2: Create Policies

Create policies that define what content should be flagged. For a vibe coding app, you’ll need policies to catch malicious requests and inappropriate content generation. Go to the Policies page and create the following:
Detects attempts to create deceptive interfaces designed to steal credentials.
Prevents generation of explicit sexual content and adult platforms.
Catches requests for malicious hacking tools and destructive software.
Use Shadow mode when first creating policies to test them without affecting your production traffic. You can monitor flagged content in the dashboard before enabling enforcement.

Step 3: Create a Deployment

Create a deployment that groups your policies together.
  1. Go to the Deployments page
  2. Click Add Deployment
  3. Name it vibe-coding-production
  4. Select all the policies you created above
  5. Save the deployment and copy the Deployment ID
Consider creating separate deployments for different environments:
  • vibe-coding-development — for dev and QA testing
  • vibe-coding-production — for live traffic

Step 4: Integrate the API

Now integrate White Circle into your code generation app. Below is a complete implementation example.
Context merging reduces payload size. Use this recommended flow:
  1. First request in a session: Send the full conversation history to establish context
  2. Subsequent requests: Set include_context: true and send only the new message — White Circle automatically prepends previous messages from the session
This approach minimizes data transfer while maintaining full conversation context for accurate moderation.

Configuration

First, set up your configuration and White Circle client:

Main Code Generation Logic

Here’s the core implementation with White Circle integration:

API Endpoint

Expose the code generator as an API endpoint in your web framework:

Step 5: Add User Risk Scoring

Use White Circle’s Radar feature to identify users with a history of violations. This helps you proactively protect your platform from abuse.

Step 6: Set Up Slack Alerts

Get instant Slack notifications for critical policy violations. You can configure alerts for specific policies only — for example, receive notifications for malicious code requests while skipping less urgent violations.
  1. Go to Integrations → Slack
  2. Click Connect to Slack and authorize the app
  3. Select a channel (e.g., #security-alerts)
  4. Select only critical policies — choose high-priority policies like “Malware” or “Phishing” to avoid alert fatigue
  5. Save the integration
Keep your alert channel focused by enabling notifications only for policies that require immediate attention. You can always review all violations in the dashboard.
For private channels, first invite the bot with /invite @White Circle Notifications

Step 7: Track Metrics

Beyond moderation, use White Circle’s metrics to gain insights into your code generation sessions. Create metrics on the Metrics page:
Detect requests related to gambling platforms and betting systems.
Track when users request refunds or compensation.
Capture genuine expressions of gratitude and positive feedback.
Metrics are computed in the background and don’t affect your API response times. View aggregated data in your dashboard to identify trends and improve your code generation experience.

Best Practices

Check user prompts and AI-generated code. Users can craft prompts that seem innocent but lead to harmful code generation.
For multi-turn conversations, use include_context: true with an external_session_id. This reduces payload size and ensures White Circle has full conversation context.
When code is flagged for vulnerabilities, retry with a more capable model and explicit security instructions rather than just rejecting the request.
When White Circle flags generated code as harmful, have a fallback strategy ready:
  • Retry with a more capable model (e.g., upgrade from gpt-5-mini to gpt-5.2)
  • Add security-focused system prompt additions
  • Log the incident for later review and model fine-tuning
Use risk scoring and metrics to identify users who repeatedly attempt to generate malicious code. Consider rate limiting or account restrictions for severe cases.
Enable shadow mode on new policies to test them without blocking content. Review flagged sessions in the dashboard before enabling enforcement.

Example Generation Flow

Here’s how a typical moderated code generation session looks:

Next Steps

View Sessions Dashboard

Monitor flagged sessions and review moderation decisions

Context Merging

Learn more about efficient multi-turn conversation handling

Risk Scoring

Deep dive into user risk assessment with Radar

Policy Configuration

Fine-tune your policies for better accuracy