Inspiration

Legal AI is becoming easier to access, but that also creates a new problem: how do we know when an AI-generated legal response is unsafe to trust?

I was interested in the gap between an AI answer that sounds convincing and an answer that actually handles uncertainty and missing information responsibly.

Instead of building another legal chatbot, I wanted to build a safety layer that challenges AI-generated legal responses before someone relies on them.

What it does

VeriLex — Verify Legal AI Before You Trust It.

VeriLex takes an AI-generated legal-information response and stress-tests it for potential safety issues.

It checks things like:

  • Context awareness
  • Overconfidence
  • Unsupported claims
  • Jurisdiction awareness
  • Internal consistency
  • Uncertainty handling
  • High-stakes awareness

The main feature is Attack This Answer. It generates adversarial questions that challenge the assumptions behind the response and explore situations where the original answer could become unsafe or misleading.

It then generates a structured safety report with key findings, recommended safeguards, limitations, and a safer reformulation.

VeriLex does not try to determine whether an answer is legally correct. Its purpose is to evaluate whether the AI response behaves responsibly based on the information provided.

How I built it

I built VeriLex using React, Supabase, Gemini, and server-side AI processing.

The frontend handles the analysis experience and displays the results. Supabase is used for authentication, database storage, and analysis history. Gemini is used for contextual reasoning, identifying potential safety issues, and generating adversarial scenarios.

I also combined AI reasoning with deterministic checks for obvious risk signals, such as missing information and overly absolute language.

The Gemini API key is kept on the server side so it is not exposed in the frontend.

Challenges I ran into

One of the biggest challenges was making VeriLex useful without accidentally turning it into another legal-answer generator.

I had to carefully define the AI's role so that it focuses on safety and reliability signals instead of pretending to determine whether something is legally correct.

Another challenge was dealing with the uncertainty involved in legal information. A response can depend heavily on the jurisdiction, the specific situation, or details that were not included in the original question.

I also had to make the AI output structured and consistent enough to display clearly in the application and store in the database.

Accomplishments that I'm proud of

I'm proud that VeriLex goes beyond simply sending a prompt to an LLM and displaying its response.

The Attack This Answer workflow makes the evaluation more active. Instead of only looking for problems in an answer, VeriLex tries to challenge the assumptions behind it using adversarial scenarios.

I'm also proud that I kept the project focused on AI safety rather than trying to replace lawyers or authoritative legal sources.

The result is a working concept for a safety layer that can be placed between AI-generated legal information and the people who may rely on it.

What I learned

I learned that building an AI application is not just about making a model generate better answers.

A big part of responsible AI is asking:

What happens when the model is wrong, overconfident, missing important context, or faced with an edge case?

While building VeriLex, I also learned more about structured AI outputs, deterministic validation, secure API handling, authentication, database design, and adversarial testing.

Most importantly, I learned that sometimes the better use of AI is not to generate another answer, but to question and test the answers AI has already generated.

What's next for VeriLex

The next step is to make VeriLex capable of evaluating responses from multiple AI systems using the same safety test suite.

Some features I would like to add are:

  • Automated multi-turn red teaming
  • More specialized safety test suites
  • Citation and source verification
  • More detailed jurisdiction-aware checks
  • An API for developers building legal AI applications
  • Continuous monitoring of AI responses in production

The long-term goal is to make VeriLex a testing and safety layer for high-stakes AI systems, starting with legal information.

Built With

Share this project:

Updates