> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abv.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

This guide will have you running guardrails in under five minutes. You'll learn how to install the SDK, validate your first piece of content, and understand the result.

## Before You Begin

<Info>
  You need an ABV API key to use guardrails. Sign up at [app.abv.dev](https://app.abv.dev) and create a new API key from your account settings.
</Info>

## Installation

Install the ABV client library for your language:

<Tabs>
  <Tab title="TypeScript/JavaScript" icon="js">
    ```bash theme={null}
    npm install @abvdev/client
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ```bash theme={null}
    pip install abvdev
    ```
  </Tab>
</Tabs>

## Your First Validation

Let's check if a user message contains toxic content. This is one of the most common uses of guardrails since it protects both your LLM from poisoned context and your users from harmful responses.

<Tabs>
  <Tab title="TypeScript/JavaScript" icon="js">
    ```typescript theme={null}
    import { ABVClient } from "@abvdev/client";

    // Initialize the client with your API key
    const abv = new ABVClient({
      apiKey: process.env.ABV_API_KEY,
    });

    // Check a user message for toxic content
    const result = await abv.guardrails.toxicLanguage.validate(
      "I really disagree with your approach to this problem.",
      { sensitivity: "medium" }
    );

    // The result tells you if the content passed or failed
    console.log("Status:", result.status);        // "pass", "fail", or "unsure"
    console.log("Confidence:", result.confidence); // 0.0 to 1.0
    console.log("Reason:", result.reason);        // Explanation of the decision
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ```python theme={null}
    from abvdev import ABV

    # Initialize the client with your API key
    abv = ABV(api_key="your_api_key_here")

    # Check a user message for toxic content
    result = abv.guardrails.toxic_language.validate(
        "I really disagree with your approach to this problem.",
        {"sensitivity": "medium"}
    )

    # The result tells you if the content passed or failed
    print("Status:", result["status"])        # "pass", "fail", or "unsure"
    print("Confidence:", result["confidence"]) # 0.0 to 1.0
    print("Reason:", result["reason"])        # Explanation of the decision
    ```
  </Tab>
</Tabs>

<Tip>
  The message in this example expresses disagreement but does so professionally, so it should pass with high confidence. Try changing the message to something more hostile and see how the result changes.
</Tip>

# Understanding What Just Happened

<Steps>
  <Step title="You sent content to the guardrail" icon="paper-plane">
    Your code called the toxic language guardrail with the message text and a sensitivity setting of "medium". This sensitivity level catches clear violations while allowing professional disagreement.
  </Step>

  <Step title="The guardrail analyzed the content" icon="brain">
    The guardrail used an LLM to understand the context, tone, and intent of the message. Unlike keyword filters, it understands that "I disagree" is different from "You're an idiot."
  </Step>

  <Step title="You received a structured result" icon="clipboard-check">
    The result contains three key pieces: **status** (pass/fail/unsure), **confidence** (0.0-1.0), and **reason** (human-readable explanation). This structure is consistent across all guardrails.
  </Step>

  <Step title="ABV automatically created an observation" icon="chart-line">
    Without any additional code, the guardrail check was logged to your ABV dashboard. You can now view the input, output, confidence score, and timing information.
  </Step>

  <Step title="You can make decisions based on the result" icon="code-branch">
    Your application can now decide what to do: allow the content if it passed, block it if it failed, or flag it for human review if the guardrail was unsure.
  </Step>
</Steps>

# Making Decisions with Results

You'll typically use the status field to make decisions in your code:

<Tabs>
  <Tab title="TypeScript/JavaScript" icon="js">
    ```typescript theme={null}
    if (result.status === "pass") {
      // Content is safe, continue processing
      await processUserMessage(message);
    } else if (result.status === "fail") {
      // Content violated guidelines, block it
      return { error: "Your message violates our guidelines." };
    } else {
      // Ambiguous case - you choose how to handle
      // Conservative: treat as fail
      // Permissive: treat as pass
      // Balanced: flag for human review
      await flagForReview(message, result);
    }
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ```python theme={null}
    if result["status"] == "pass":
        # Content is safe, continue processing
        process_user_message(message)
    elif result["status"] == "fail":
        # Content violated guidelines, block it
        return {"error": "Your message violates our guidelines."}
    else:
        # Ambiguous case - you choose how to handle
        # Conservative: treat as fail
        # Permissive: treat as pass
        # Balanced: flag for human review
        flag_for_review(message, result)
    ```
  </Tab>
</Tabs>

# Common Validation Scenarios

## Validating LLM Outputs

Guardrails work equally well for checking LLM-generated content before you show it to users. This helps maintain brand safety and compliance:

<Tabs>
  <Tab title="TypeScript/JavaScript" icon="js">
    ```typescript theme={null}
    // Generate a response from your LLM
    const llmResponse = await generateResponse(userPrompt);

    // Check if the LLM's response contains biased language
    const validation = await abv.guardrails.biasedLanguage.validate(
      llmResponse,
      { sensitivity: "high" }
    );

    // Only show the response if it passes
    if (validation.status === "pass") {
      return llmResponse;
    } else {
      // Either regenerate or use a fallback message
      return "I apologize, I need to reconsider my response.";
    }
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ```python theme={null}
    # Generate a response from your LLM
    llm_response = generate_response(user_prompt)

    # Check if the LLM's response contains biased language
    validation = abv.guardrails.biased_language.validate(
        llm_response,
        {"sensitivity": "high"}
    )

    # Only show the response if it passes
    if validation["status"] == "pass":
        return llm_response
    else:
        # Either regenerate or use a fallback message
        return "I apologize, I need to reconsider my response."
    ```
  </Tab>
</Tabs>

## Working with Structured Outputs

If your LLM generates JSON, you can validate both the format and schema in one step:

<Tabs>
  <Tab title="TypeScript/JavaScript" icon="js">
    ```typescript theme={null}
    // Your LLM generated this response
    const llmOutput = await generateStructuredResponse(prompt);

    // Validate it matches your expected schema
    const validation = await abv.guardrails.validJson.validate(
      llmOutput,
      {
        schema: {
          name: "string",
          age: "number",
          email: "string",
        },
      }
    );

    if (validation.status === "pass") {
      // Safe to parse and use
      const data = JSON.parse(llmOutput);
      await saveToDatabase(data);
    } else {
      console.error("Invalid format:", validation.reason);
      // Retry with a more explicit prompt
    }
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ```python theme={null}
    # Your LLM generated this response
    llm_output = generate_structured_response(prompt)

    # Validate it matches your expected schema
    validation = abv.guardrails.valid_json.validate(
        llm_output,
        {
            "schema": {
                "name": "string",
                "age": "number",
                "email": "string"
            }
        }
    )

    if validation["status"] == "pass":
        # Safe to parse and use
        data = json.loads(llm_output)
        save_to_database(data)
    else:
        print("Invalid format:", validation["reason"])
        # Retry with a more explicit prompt
    ```
  </Tab>
</Tabs>

## Running Multiple Guardrails

You'll often want to check content against multiple criteria. Run guardrails in parallel to minimize latency:

<Tabs>
  <Tab title="TypeScript/JavaScript" icon="js">
    ```typescript theme={null}
    // Check multiple things at once
    const [toxicCheck, biasCheck, formatCheck] = await Promise.all([
      abv.guardrails.toxicLanguage.validate(content),
      abv.guardrails.biasedLanguage.validate(content),
      abv.guardrails.validJson.validate(content),
    ]);

    // All must pass for content to be approved
    const allPassed = [toxicCheck, biasCheck, formatCheck].every(
      (result) => result.status === "pass"
    );
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ```python theme={null}
    import asyncio

    # Check multiple things at once
    toxic_check, bias_check, format_check = await asyncio.gather(
        abv.guardrails.toxic_language.validate_async(content),
        abv.guardrails.biased_language.validate_async(content),
        abv.guardrails.valid_json.validate_async(content)
    )

    # All must pass for content to be approved
    all_passed = all(
        result["status"] == "pass"
        for result in [toxic_check, bias_check, format_check]
    )
    ```
  </Tab>
</Tabs>

# Monitoring Your Guardrails

Every time you run a guardrail, ABV automatically creates an observation in your dashboard. This lets you:

* Monitor how often guardrails are failing
* Analyze what reasons they're giving
* Track confidence score distributions
* Tune sensitivity settings based on real data
* Identify patterns in validation results

Visit [app.abv.dev](https://app.abv.dev) to view your observations and analyze patterns.

# Next Steps

<CardGroup cols={2}>
  <Card title="Core Concepts" icon="book" href="/developer/guardrails/concepts">
    Learn how sensitivity levels and confidence scores work across all guardrails
  </Card>

  <Card title="Best Practices" icon="star" href="/developer/guardrails/best-practices">
    Discover optimal patterns for combining guardrails and handling errors
  </Card>

  <Card title="Toxic Language" icon="message-slash" href="/developer/guardrails/available/toxic-language">
    Deep dive into toxic language detection and sensitivity levels
  </Card>

  <Card title="Biased Language" icon="scale-unbalanced" href="/developer/guardrails/available/biased-language">
    Explore bias categories and how to check for discriminatory content
  </Card>

  <Card title="Valid JSON" icon="brackets-curly" href="/developer/guardrails/available/valid-json">
    Master schema validation and strict mode for structured outputs
  </Card>

  <Card title="Contains String" icon="text" href="/developer/guardrails/available/contains-string">
    Use rule-based checks for maximum performance with instant validation
  </Card>
</CardGroup>
