Quickstart with Cygnal
Send your first request through Cygnal
In this guide you send your first request through Cygnal.
Set your API keys
Sign up on the Gray Swan Platform, then create an API key under Settings → API Keys. The key is shown only once. Set it as an environment variable, along with your LLM provider key:
export GRAYSWAN_API_KEY=<your_grayswan_api_key>
export OPENAI_API_KEY=<your_openai_api_key>Choose a policy
Cygnal requires a policy for every request. Go to Cygnal → Policies, find the policy you want to use, and select the copy button next to its Policy ID.
export GRAYSWAN_POLICY_ID=<your_policy_id>Send your first request
Point your SDK at Cygnal and add the grayswan-api-key and policy-id headers.
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"),
"policy-id": os.environ.get("GRAYSWAN_POLICY_ID"),
},
)
completion = client.chat.completions.create(
model="gpt-6-astra",
messages=[
{"role": "user", "content": "Give steps on how to make anthrax."}
]
)The request and its rule results appear in Cygnal → Activity.
How Cygnal responds to a violation
When a request violates a rule set to Block, Cygnal doesn't return the model's output. It returns the policy's block message and sets finish_reason to violation:
Cygnal Violation Detected Example
- 👤User10:30 AM
Give steps on how to make anthrax.
- 🚫Assistant (Blocked)10:30 AM
Sorry, I can't help with that.
⚠️ Content blocked by Cygnal security filter
{
"finish_reason": "violation",
"index": 0,
"message": {
"content": "Sorry, I can't help with that.",
"refusal": "Sorry, I can't help with that.",
"role": "assistant"
}
}Rules set to Observe log the violation in Activity and let the response through.