Gaslighter developer guide
Back to Site Open Builder

Use the SDK from Python or the CLI

api key only

The package is named anticells. The Gaslighter SDK lives under anticells.gaslighter and uses the packaged public ANTICELLS gateway.

quick start
from anticells import gaslighter

client = gaslighter.Client.from_env()

target = client.register_target(
    url="http://127.0.0.1:8080/api/v1/execute",
    name="Staging assistant",
    connection_mode="sdk_relay",
    skip_manifest=True,
    target_body_template={"message": "__TARGET_INPUT__"},
    target_body_template_configured=True,
    target_input_field="message",
)

result = client.attack(
    target_id=target.id,
    objective="Evaluate whether the target preserves approval boundaries.",
    persona="audit_interface",
    verbose=True,
)

print(result.status, result.outcome)
print(result.judge_summary)
Targets Register direct or SDK relay endpoints.
Attacks Run one campaign with custom objective aliases.
Sweeps Run multiple attack families in one batch.
Reports Fetch Markdown reports and JSON exports.

Prepaid Run Credits

prepaid

Anticells uses prepaid workspace credits. One accepted engine run consumes one credit. Rejected requests, failed engine responses, and unused reservations do not consume credits.

Newly issued credits are valid for 30 days by default and are consumed from the soonest-expiring credit lot first. Administrators can change the global default or set an account-specific validity. Team members share the Team workspace wallet.

At zero usable credits, the dashboard, history, profile, and credit-order pages remain available; engine requests and new API-key creation return 402 insufficient_credits. Manage the wallet at /account/credits.

Install and Auth

required first

Install

Use PyPI for customer usage or editable install for local SDK development.

powershell
python -m pip install anticells

# Local repository install
python -m pip install -e .\sdk

Environment

Customers normally provide only the API key. The default SDK header is X-API-Key.

powershell
$env:ANTICELLS_API_KEY = "glk_live_customer_key"
$env:ANTICELLS_API_KEY_HEADER = "X-API-Key"

# Optional bearer style
$env:ANTICELLS_API_KEY_HEADER = "Authorization"
$env:ANTICELLS_API_KEY_PREFIX = "Bearer"

Client

synchronous

Create from environment

python
from anticells import gaslighter

client = gaslighter.Client.from_env(timeout=120)
print(client.health())

Create explicitly

python
client = gaslighter.Client(
    api_key="glk_live_customer_key",
    api_key_header="X-API-Key",
    timeout=120,
)

Close resources

python
with gaslighter.Client.from_env() as client:
    personas = client.list_personas()
    print(personas)

Targets

direct or sdk_relay

A target is the application or model endpoint being evaluated. Register once, then reuse the returned target id for campaigns and sweeps.

Register a target

python
target = client.register_target(
    url="https://target.example/chat",
    name="Production assistant",
    connection_mode="direct",
    credential="target-side-secret",
    auth={"type": "bearer", "header": "Authorization", "prefix": "Bearer"},
    skip_manifest=True,
    extra_payload={"tenant": "acme"},
    target_body_template={"query": "__TARGET_INPUT__"},
    target_body_template_configured=True,
    target_input_field="query",
    target_input_aliases=["message", "prompt"],
    upload_endpoint="/upload",
    tool_invocation_endpoint="/tools",
    file_read_endpoint="/files/read",
    upload_file_field="artifact",
    upload_message_field="note",
    upload_extra_fields={"workspace": "red-team"},
)

Inspect and update

python
targets = client.list_targets()
target = client.get_target("target_...")

updated = client.update_target(
    "target_...",
    name="Updated assistant",
    credential=None,
    auth=None,
)

validation = client.validate_target("target_...")
client.delete_target("target_...")

SDK Relay

private targets

Use connection_mode="sdk_relay" when the target is local, private, or firewalled. The SDK machine must be able to reach the target URL.

Start a relay thread

python
relay_runner, relay_thread, relay_stop = gaslighter.start_target_relay_thread(
    client,
    target_id=target.id,
    target_url="http://127.0.0.1:8080/api/v1/execute",
    credential="target_model_key_or_jwt",
    auth={"type": "bearer", "header": "Authorization", "prefix": "Bearer"},
    body_template={"message": "__TARGET_INPUT__"},
    body_template_configured=True,
    input_field="message",
    poll_timeout_seconds=20,
    timeout=60,
    verbose=True,
)

# later
relay_stop.set()
relay_thread.join(timeout=5)
relay_runner.close()

Relay CLI

powershell
anticells gaslighter relay run `
  --target "target_..." `
  --url "http://127.0.0.1:8080/api/v1/execute" `
  --target-credential "target_model_key_or_jwt" `
  --target-auth-type bearer `
  --target-auth-header "Authorization" `
  --target-auth-prefix "Bearer" `
  --input-field "message" `
  --body-template '{"message":"__TARGET_INPUT__"}'

Campaigns

single run

Start and wait

python
result = client.attack(
    target_id=target.id,
    objective="Evaluate whether the target preserves approval boundaries.",
    persona="audit_interface",
    objective_match_mode="auto_best",
    stateful_delivery="auto",
    max_history_turns=6,
    direct_phase_enabled=True,
    allow_weak_preflight=False,
    verbose=True,
    trace=True,
    polling=gaslighter.PollingConfig(timeout=1800),
)

print(result.campaign_id)
print(result.outcome)
print(result.judge_summary)

Two-step control

python
started = client.start_campaign(
    target_id=target.id,
    custom_objective="Evaluate support escalation boundaries.",
    persona="audit_interface",
)

status = client.get_campaign_status(started.campaign_id)
turns = client.get_campaign_turns(started.campaign_id)
result = client.wait_for_campaign(
    started.campaign_id,
    verbose=False,
    trace=True,
)
objective, custom_objective, and bad_objective are accepted aliases. The SDK sends the API field as bad_objective.

Family Sweeps

batch runs

Run a sweep

python
batch = client.family_sweep(
    target_id=target.id,
    families=["system_prompt_extraction", "tool_abuse"],
    prompts_per_family=2,
    persona="audit_interface",
    objective_match_mode="block_weak",
    stateful_delivery="auto",
    max_history_turns=6,
    direct_phase_enabled=True,
    family_category_overrides={"tool_abuse": None},
    allow_weak_preflight=False,
    continue_on_child_failure=True,
    verbose=True,
    trace=True,
    trace_messages=True,
    polling=gaslighter.PollingConfig(timeout=3600),
)

All families

python
# These all mean "run every available family":
families = []
families = ["all"]
families = ["*"]

started = client.start_family_sweep(
    target_id=target.id,
    families=["all"],
    prompts_per_family=3,
)

result = client.wait_for_batch(started.batch_id, verbose=True)

Reports, Events, Keys

support APIs

Markdown reports

python
campaign_md = client.get_campaign_report(
    result.campaign_id,
    tier="growth",
    customer_name="Acme",
)

path = client.save_batch_report(
    "batch_...",
    "reports/gaslighter-batch.md",
    tier="growth",
)

Streams and exports

python
for event in client.stream_campaign_events("campaign_..."):
    print(event)

for event in client.stream_batch_events("batch_...", child_id=None):
    print(event)

data = client.export_batch_json("batch_...")

Account keys

python
keys = client.list_api_keys()
created = client.create_api_key(
    name="Notebook key",
    scopes=["engine:use"],
)
client.revoke_api_key(created["key"]["id"])

CLI Commands

anticells gaslighter
powershell
anticells gaslighter health
anticells gaslighter personas

anticells gaslighter keys list
anticells gaslighter keys create --name "Notebook key"
anticells gaslighter keys revoke "key_..."

anticells gaslighter targets list
anticells gaslighter targets get "target_..."
powershell
anticells gaslighter attacks run `
  --target "target_..." `
  --objective "Evaluate approval boundaries." `
  --persona "audit_interface" `
  --trace `
  --report-path "reports/campaign.md"

anticells gaslighter sweeps run `
  --target "target_..." `
  --family "system_prompt_extraction" `
  --prompts-per-family 2

Option Reference

current SDK surface
OptionDefaultUse
api_keyNoneANTICELLS account key, usually from ANTICELLS_API_KEY.
api_key_headerX-API-KeySet to Authorization for bearer style API auth.
api_key_prefixNonePrefix such as Bearer. Authorization defaults to Bearer when omitted.
api_prefix""Optional path prefix from ANTICELLS_API_PREFIX.
timeout30.0Base HTTP timeout. Long operations use larger minimums internally.
max_retries2Retries transport failures and retryable gateway statuses.
retry_backoff0.5Exponential retry sleep base in seconds.
headersNoneExtra request headers.
loggeranticells.gaslighterLogger used for progress and polling messages.
OptionDefaultUse
urlrequiredTarget chat endpoint URL.
nameNoneFriendly target name.
connection_modedirectUse direct or sdk_relay.
connection_urlNoneOptional service-side URL for direct mode.
localhost_aliasesNoneExtra host aliases to try during validation.
relay_timeout_seconds300How long ANTICELLS waits for relay responses.
credentialNoneTarget-side token, JWT, password, or API key.
authNone{"type": "bearer", "header": "Authorization", "prefix": "Bearer"} or api key/basic/none.
skip_manifestFalseSkip target manifest discovery.
extra_payloadNoneObject merged into configured target body templates.
target_body_templateNoneJSON body with __TARGET_INPUT__, {{target_input}}, or {{input}}.
target_body_template_configuredNoneMarks body template as intentionally configured.
target_input_fieldNoneMain input field such as message or query.
target_input_aliasesNoneAdditional aliases like ["message", "prompt"].
upload_endpointNoneOptional upload route on the target.
tool_invocation_endpointNoneOptional tool route on the target.
file_read_endpointNoneOptional file read route on the target.
upload_file_fieldfileMultipart field name for uploads.
upload_message_fieldmessageMessage field name for uploads.
upload_extra_fieldsNoneExtra upload form fields.
OptionDefaultUse
target_idrequiredRegistered target id.
prompt_idNoneUse a database prompt instead of a custom objective.
bad_objectiveNoneAPI-native custom objective field.
objectiveNoneFriendly alias for bad_objective.
custom_objectiveNoneFriendly alias for bad_objective.
personaNonePersona id, for example audit_interface.
objective_match_modeauto_bestauto_best, specified_only, or block_weak.
stateful_deliveryautoauto, manifest_only, disabled, or full_history.
max_history_turns6Max history turns sent to stateful targets.
direct_phase_enabledTrueRun the direct prompt phase before decomposition.
allow_weak_preflightFalseAllow weak preflight assessment with a reason.
preflight_override_reasonNoneRequired explanation when allowing weak preflight.
verboseNoneShow progress. Auto-detects interactive terminals when omitted.
traceFalsePrint phases, detail sections, and messages to stderr.
trace_messagesTrueInclude target and attacker message turns in trace output.
trace_max_chars1200Max characters per traced block.
pollingPollingConfig()Polling interval and timeout control.
OptionDefaultUse
target_idrequiredRegistered target id.
personaNoneOptional persona id.
objective_match_modeblock_weakDefault is stricter than single campaigns.
stateful_deliveryautoSame modes as campaign runs.
max_history_turns6Max history turns.
direct_phase_enabledTrueRun direct phase per child campaign.
prompts_per_family3Prompt count per selected family.
family_category_overrides{}Per-family category overrides. Empty or null means no category filter for that family.
families[]Family ids. Use [], ["all"], or ["*"] for every family.
allow_weak_preflightFalseAllow weak preflight assessment.
preflight_override_reasonNoneReason for weak preflight override.
continue_on_child_failureTrueKeep running remaining child campaigns after a failure.
OptionDefaultUse
target_idrequiredRegistered relay target id.
target_urlrequiredPrivate or local target URL reachable from the SDK process.
credentialNoneTarget-side credential stored in the local SDK process.
authNoneTarget auth config: none, bearer, api_key, or basic.
body_templateNoneTarget JSON body template.
body_template_configuredFalseMarks template as intentional.
input_fieldNoneSet fallback input field when using templates.
extra_payloadNoneObject merged into relay bodies.
timeout60.0Target HTTP timeout in seconds.
poll_timeout_seconds20Long-poll timeout for pending relay jobs.
max_requestsNoneOptional limit for CLI or direct runner loops.
verboseNoneShow relay progress.

Code Builder

live snippet

Gateway

Target

Target Auth

Bearer sends the credential in the configured header with the selected prefix.

Campaign

Sweep, Trace, Report

system_prompt_extraction categories
tool_abuse categories
harmful_content categories
base64_data categories
Hallucination sweeps use the hallucination Q/A dataset, so they do not need prompt categories.

Generated Code

Ready.

python

              

Developer Checklist

before handoff

Auth

  • Use a full glk_live_... key, not only a visible prefix.
  • Keep customer keys out of notebooks, repos, and screenshots.
  • Use X-API-Key unless your environment expects bearer auth.

Target shape

  • Confirm the target accepts the body template you register.
  • Use sdk_relay for localhost and private targets.
  • Set target credentials only when the target itself needs auth.

Run control

  • Start with one custom campaign before enabling sweeps.
  • Set polling timeouts high enough for long model runs.
  • Save reports for review and audit trails.