← Back to Blog
Tutorial · SDK · Integration

Integrating Governance in 5 Minutes with the Python SDK

Step-by-step guide to installing the EVE Governance SDK, making your first verification call, and handling veto responses in your AI pipeline.

D
Integrating Governance in 5 Minutes with the Python SDK

Adding governance to an existing AI application shouldn't require rearchitecting your entire stack. The EVE Governance Python SDK is designed to be a single function call between your model's output and your user's screen. In this guide, we'll go from zero to a fully governed AI pipeline in under five minutes.

Step 1: Install the SDK

The SDK is published on PyPI and has zero heavy dependencies. Install it with pip:

# Install the EVE Governance SDK
pip install eve-governance

The package includes the governance client, response types, and helper utilities. It works with Python 3.9+ and has no dependency on any specific AI framework — it integrates with OpenAI, Anthropic, Google, Hugging Face, or any custom model pipeline.

Step 2: Initialize the Client

You'll need an API key from your EVE AI Core dashboard. The client handles authentication, connection pooling, and automatic retry with exponential backoff.

from eve_governance import GovernanceClient

# Initialize with your API key
client = GovernanceClient(
    api_key="eve_sk_your_api_key_here",
    # Optional: specify your domain for CRD floor selection
    domain="financial"
)

API keys: Generate your key at api.eveaicore.com/dashboard. Keys are scoped to your organization and include rate limits based on your plan tier. Free tier includes 10,000 verification calls per month.

Step 3: Verify an AI Output

The core API is a single method: verify(). Pass in the AI's output text, optional context about the conversation, and get back a structured governance verdict.

# Verify an AI-generated response
result = client.verify(
    text="Based on clinical trials, this medication reduces symptoms by 73%.",
    context={
        "conversation_id": "conv_abc123",
        "user_query": "Does this medication work?",
        "domain": "medical"
    }
)

print(result.verdict)     # "APPROVED", "CONDITIONED", or "BLOCKED"
print(result.crd_score)   # 0.0 - 1.0 (Confidence-Reality Divergence)
print(result.charter_ok)  # True/False (charter compliance)

Step 4: Handle the Verdict

The verify() method returns one of three verdicts, each requiring a different response in your application:

if result.verdict == "APPROVED":
    # Safe to send directly
    send_to_user(result.text)

elif result.verdict == "CONDITIONED":
    # Apply suggested modifications
    modified_text = result.suggested_text
    send_to_user(modified_text)
    print(f"Conditions: {result.conditions}")

elif result.verdict == "BLOCKED":
    # Do not send. Log the reason and regenerate.
    log_governance_event(
        reason=result.block_reason,
        rules=result.violated_rules,
        crd=result.crd_score
    )
    # Optionally regenerate with governance context
    regenerated = regenerate_with_context(result.governance_hint)

Complete Working Example

Here's a complete example that wraps an OpenAI call with EVE governance:

from openai import OpenAI
from eve_governance import GovernanceClient

openai_client = OpenAI(api_key="sk-...")
gov_client = GovernanceClient(api_key="eve_sk_...", domain="general")

def governed_chat(user_message: str) -> str:
    # 1. Generate with your model
    completion = openai_client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": user_message}]
    )
    ai_output = completion.choices[0].message.content

    # 2. Verify with EVE governance
    result = gov_client.verify(
        text=ai_output,
        context={"user_query": user_message}
    )

    # 3. Handle the verdict
    if result.verdict == "BLOCKED":
        return "I need to rephrase that. Let me try again."
    elif result.verdict == "CONDITIONED":
        return result.suggested_text
    else:
        return ai_output

# Use it
response = governed_chat("What medication should I take for headaches?")
print(response)

That's it. Three lines of governance code wrapping your existing AI pipeline. The SDK handles charter evaluation, CRD scoring, evidence lookup, and verdict generation — all in a single API call that typically completes in under 50 milliseconds.

What Happens Behind the Scenes

When you call verify(), the SDK sends the text and context to the EVE governance API. On the server side, the request passes through the full Three-Plane Architecture:

The result object includes the governance verdict, the CRD score, any charter violations, suggested text modifications, and a correlation ID for audit trail queries. Full API documentation is available at api.eveaicore.com.

Five minutes from install to governed AI. No architecture changes required.

End
Python SDK Tutorial AI Governance Integration Quick Start API Developer Tools