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

# Hallucination

This detector takes a request text and the corresponding response text to check for potential Hallucination in the output of a LLM response. If the response text contains Hallucination, is\_hallucination will be set to 1, otherwise, it will be set to 0. The detector also provides a prompt\_based score to indicate the extent to which the hallucination is based on the prompt.

* **NOTE: This is unavailable at the moment.** *(Coming soon)*

## Example request:

```python Python theme={"system"}
import requests
import json
import os

url = "https://api.enkryptai.com/guardrails/hallucination"

payload = json.dumps({
  "request_text": "What is the capital of France?",
  "response_text": "Tokyo is the capital of france.",
  "context": ""
})

headers = {
    'Content-Type': 'application/json',
    'apikey': os.getenv('ENKRYPTAI_API_KEY')
}

response = requests.request("POST", url, headers=headers, data=payload)

formatted_response = json.dumps(json.loads(response.text), indent=4)
print(formatted_response)
```

```python Python SDK theme={"system"}
import os
from enkryptai_sdk import *
from dotenv import load_dotenv

load_dotenv()

ENKRYPT_API_KEY = os.getenv("ENKRYPTAI_API_KEY")
ENKRYPT_BASE_URL = os.getenv("ENKRYPTAI_BASE_URL") or "https://api.enkryptai.com"

guardrails_client = GuardrailsClient(api_key=ENKRYPT_API_KEY, base_url=ENKRYPT_BASE_URL)

request_text = "What is the capital of France?"
response_text = "Tokyo is the capital of france."
context = ""

hallucination_response = guardrails_client.hallucination(
    request_text=request_text,
    response_text=response_text,
    context=context
)

print(hallucination_response)

# Print as a dictionary
print(hallucination_response.to_dict())
```

## Example response:

```json JSON theme={"system"}
{
  "summary": {
    "is_hallucination": 1
  },
  "details": {
    "prompt_based": 1.0
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.