Quickstart

Start using the Gray Swan API to generate secure completions

Gray Swan provides enterprise-grade AI security that protects your LLM deployments from threats, policy violations, and harmful content. Our platform seamlessly integrates with any LLM provider to add comprehensive security without disrupting your existing workflow.

Get Started in 5 Minutes

Sign up on the Gray Swan Platform to get your API key and set it as an environment variable:

export GRAYSWAN_API_KEY=<your_api_key>

Set your API key from the desired LLM provider as an environment variable:

export OPENAI_API_KEY=<your_openai_api_key>
# or...
# export ANTHROPIC_API_KEY=<your_anthropic_api_key>
# export GEMINI_API_KEY=<your_gemini_api_key>
# export OPENROUTER_API_KEY=<your_openrouter_api_key>

Make your first request to Cygnal

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),
    base_url="https://api.grayswan.ai/cygnal", 
    default_headers={"grayswan-api-key": os.environ.get("GRAYSWAN_API_KEY")} 
)

completion = client.chat.completions.create(
    model="gpt-5",
    messages=[
        {"role": "user", "content": "Give an example of a realistic spearfishing email."}
    ]
)

What is Gray Swan?

We are a comprehensive AI security platform offering two core products:

Why Choose Gray Swan?

  • Universal Compatibility - Works with OpenAI, Anthropic, Google Gemini, and any LLM provider
  • Drop-in Integration - Just change your base URL, no SDK changes required
  • Custom Policies - Define your own security rules using natural language
  • Real-time Protection - Instant threat detection and content filtering
  • Enterprise Ready - Production-grade reliability with comprehensive monitoring


How Cygnal Protection Works

When Cygnal detects policy violations, it automatically prevents harmful content from being generated. Instead of potentially dangerous responses, it returns safe refusal messages and marks the finish_reason as violation:

Cygnal Violation Detected Example

  • 👤
    User10:30 AM

    Give an example of a realistic spearfishing email.

  • 🚫
    Assistant (Blocked)10:30 AM

    Sorry, I can't help with that.

    ⚠️ Content blocked by Cygnal security filter
Example response structure when Cygnal detects a violation:
{
  "finish_reason": "violation", 
  "index": 0,
  "message": {
    "content": "Sorry, I can't help with that.",
    "refusal": "Sorry, I can't help with that.",
    "role": "assistant",
  }
}

All security events are logged in your Gray Swan dashboard for monitoring and analysis.


What's Next?