# quotientai
[](https://pypi.org/project/quotientai)
## Overview
`quotientai` is an SDK and CLI for logging data to [Quotient](https://quotientai.co), and running hallucination and document attribution detections for retrieval and search-augmented AI systems.
## Installation
```console
pip install quotientai
```
## Usage
Create an API key on Quotient and set it as an environment variable called `QUOTIENT_API_KEY`. Then follow the examples below or see our [docs](https://docs.quotientai.co) for a more comprehensive walkthrough.
Send your first log and detect hallucinations. Run the code below and see your Logs and Detections on your [Quotient Dashboard](https://app.quotientai.co/dashboard).
```python
from quotientai import QuotientAI
from quotientai.types import DetectionType
quotient = QuotientAI()
quotient.logger.init(
# Required
app_name="my-app",
environment="dev",
# dynamic labels for slicing/dicing analytics e.g. by customer, feature, etc
tags={"model": "gpt-4o", "feature": "customer-support"},
detections=[DetectionType.HALLUCINATION, DetectionType.DOCUMENT_RELEVANCY],
detection_sample_rate=1.0,
)
log_id = quotient.log(
user_query="How do I cook a goose?",
model_output="The capital of France is Paris",
documents=["Here is an excellent goose recipe..."]
)
print(log_id)
```
You can also use the async client if you need to create logs asynchronously.
```python
from quotientai import AsyncQuotientAI
from quotientai.types import DetectionType
import asyncio
quotient = AsyncQuotientAI()
quotient.logger.init(
# Required
app_name="my-app",
environment="dev",
# dynamic labels for slicing/dicing analytics e.g. by customer, feature, etc
tags={"model": "gpt-4o", "feature": "customer-support"},
detections=[DetectionType.HALLUCINATION, DetectionType.DOCUMENT_RELEVANCY],
detection_sample_rate=1.0,
)
async def main():
# Mock retrieved documents
retrieved_documents = [{"page_content": "Sample document"}]
log_id = await quotient.log(
user_query="Sample input",
model_output="Sample output",
# Page content from Documents from your retriever used to generate the model output
documents=[doc["page_content"] for doc in retrieved_documents],
# Message history from your chat history
message_history=[
{"role": "system", "content": "You are an expert on geography."},
{"role": "user", "content": "What is the capital of France?"},
{"role": "assistant", "content": "The capital of France is Paris"},
],
# Instructions for the model to follow
instructions=[
"You are a helpful assistant that answers questions about the world.",
"Answer the question in a concise manner. If you are not sure, say 'I don't know'.",
],
# Tags can be overridden at log time
tags={"model": "gpt-4o-mini", "feature": "customer-support"},
)
print(log_id)
# Run the async function
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": null,
"name": "quotientai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "quotient, evaluation, llms, machine learning, ai, logging, tracing, hallucinations",
"author": "Freddie Vargus",
"author_email": "freddie@quotientai.co",
"download_url": "https://files.pythonhosted.org/packages/b7/f6/1f75b6e6add1b2507cfcef498285b9de638256576c818d2bd1695ddd7f6a/quotientai-0.4.6.tar.gz",
"platform": null,
"description": "# quotientai\n[](https://pypi.org/project/quotientai)\n\n## Overview\n\n`quotientai` is an SDK and CLI for logging data to [Quotient](https://quotientai.co), and running hallucination and document attribution detections for retrieval and search-augmented AI systems.\n\n## Installation\n\n```console\npip install quotientai\n```\n\n## Usage\n\nCreate an API key on Quotient and set it as an environment variable called `QUOTIENT_API_KEY`. Then follow the examples below or see our [docs](https://docs.quotientai.co) for a more comprehensive walkthrough.\n\nSend your first log and detect hallucinations. Run the code below and see your Logs and Detections on your [Quotient Dashboard](https://app.quotientai.co/dashboard).\n\n```python\nfrom quotientai import QuotientAI\nfrom quotientai.types import DetectionType\n\nquotient = QuotientAI()\nquotient.logger.init(\n # Required\n app_name=\"my-app\",\n environment=\"dev\",\n # dynamic labels for slicing/dicing analytics e.g. by customer, feature, etc\n tags={\"model\": \"gpt-4o\", \"feature\": \"customer-support\"},\n detections=[DetectionType.HALLUCINATION, DetectionType.DOCUMENT_RELEVANCY],\n detection_sample_rate=1.0,\n)\n\nlog_id = quotient.log(\n user_query=\"How do I cook a goose?\",\n model_output=\"The capital of France is Paris\",\n documents=[\"Here is an excellent goose recipe...\"]\n)\n\nprint(log_id)\n```\n\nYou can also use the async client if you need to create logs asynchronously.\n\n```python\nfrom quotientai import AsyncQuotientAI\nfrom quotientai.types import DetectionType\nimport asyncio\n\nquotient = AsyncQuotientAI()\n\nquotient.logger.init(\n # Required\n app_name=\"my-app\",\n environment=\"dev\",\n # dynamic labels for slicing/dicing analytics e.g. by customer, feature, etc\n tags={\"model\": \"gpt-4o\", \"feature\": \"customer-support\"},\n detections=[DetectionType.HALLUCINATION, DetectionType.DOCUMENT_RELEVANCY],\n detection_sample_rate=1.0,\n)\n\n\nasync def main():\n # Mock retrieved documents\n retrieved_documents = [{\"page_content\": \"Sample document\"}]\n\n log_id = await quotient.log(\n user_query=\"Sample input\",\n model_output=\"Sample output\",\n # Page content from Documents from your retriever used to generate the model output\n documents=[doc[\"page_content\"] for doc in retrieved_documents],\n # Message history from your chat history\n message_history=[\n {\"role\": \"system\", \"content\": \"You are an expert on geography.\"},\n {\"role\": \"user\", \"content\": \"What is the capital of France?\"},\n {\"role\": \"assistant\", \"content\": \"The capital of France is Paris\"},\n ],\n # Instructions for the model to follow\n instructions=[\n \"You are a helpful assistant that answers questions about the world.\",\n \"Answer the question in a concise manner. If you are not sure, say 'I don't know'.\",\n ],\n # Tags can be overridden at log time\n tags={\"model\": \"gpt-4o-mini\", \"feature\": \"customer-support\"},\n )\n\n print(log_id)\n\n\n# Run the async function\nasyncio.run(main())\n```\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Python library for tracing, logging, and detecting problems with AI Agents",
"version": "0.4.6",
"project_urls": null,
"split_keywords": [
"quotient",
" evaluation",
" llms",
" machine learning",
" ai",
" logging",
" tracing",
" hallucinations"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "5de31a190001c1c10751a90c2438c3deddfa972e78bc11adebcd599c85a404fa",
"md5": "3669595035bcb790197d512eba017549",
"sha256": "57aa7e5cb6091e54029871d3b71bda7629620cfde21bdb6220a410bb747872d3"
},
"downloads": -1,
"filename": "quotientai-0.4.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3669595035bcb790197d512eba017549",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 43976,
"upload_time": "2025-07-29T14:28:51",
"upload_time_iso_8601": "2025-07-29T14:28:51.407257Z",
"url": "https://files.pythonhosted.org/packages/5d/e3/1a190001c1c10751a90c2438c3deddfa972e78bc11adebcd599c85a404fa/quotientai-0.4.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b7f61f75b6e6add1b2507cfcef498285b9de638256576c818d2bd1695ddd7f6a",
"md5": "670d29f4fd94e739eefbe4a04cdc6bce",
"sha256": "9da1096b8e85dc1792f0c4b68383739242cc72baf411ac1aecfddd6413756f28"
},
"downloads": -1,
"filename": "quotientai-0.4.6.tar.gz",
"has_sig": false,
"md5_digest": "670d29f4fd94e739eefbe4a04cdc6bce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 31324,
"upload_time": "2025-07-29T14:28:52",
"upload_time_iso_8601": "2025-07-29T14:28:52.531259Z",
"url": "https://files.pythonhosted.org/packages/b7/f6/1f75b6e6add1b2507cfcef498285b9de638256576c818d2bd1695ddd7f6a/quotientai-0.4.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-29 14:28:52",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "quotientai"
}