# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
result = pc.assistants.evaluate_alignment(
question="What are the capital cities of France, England and Spain?",
answer="Paris is the capital city of France and Barcelona of Spain",
ground_truth_answer="Paris is the capital city of France, London of England and Madrid of Spain",
)
print(result.scores.correctness, result.scores.completeness, result.scores.alignment)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const result = await pc.assistants.evaluate({
question: 'What are the capital cities of France, England and Spain?',
answer: 'Paris is the capital city of France and Barcelona of Spain',
groundTruth: 'Paris is the capital city of France, London of England and Madrid of Spain',
});
console.log(result.metrics.correctness, result.metrics.completeness, result.metrics.alignment);
PINECONE_API_KEY="YOUR_API_KEY"
curl https://prod-1-data.ke.pinecone.io/assistant/evaluation/metrics/alignment \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-Api-Version: 2026-07" \
-d '{
"question": "What are the capital cities of France, England and Spain?",
"answer": "Paris is the capital city of France and Barcelona of Spain",
"ground_truth_answer": "Paris is the capital city of France, London of England and Madrid of Spain"
}'
{
"metrics": {
"correctness": 123,
"completeness": 123,
"alignment": 123
},
"reasoning": {
"evaluated_facts": [
{
"fact": {
"content": "<string>"
},
"entailment": "<string>"
}
]
},
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"message": "<string>"
}{
"message": "<string>"
}Evaluate an answer
Evaluate the correctness and completeness of a response from an assistant or a RAG system. The correctness and completeness are evaluated based on the precision and recall of the generated answer with respect to the ground truth answer facts. Alignment is the harmonic mean of correctness and completeness.
For guidance and examples, see Evaluate answers.
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
result = pc.assistants.evaluate_alignment(
question="What are the capital cities of France, England and Spain?",
answer="Paris is the capital city of France and Barcelona of Spain",
ground_truth_answer="Paris is the capital city of France, London of England and Madrid of Spain",
)
print(result.scores.correctness, result.scores.completeness, result.scores.alignment)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const result = await pc.assistants.evaluate({
question: 'What are the capital cities of France, England and Spain?',
answer: 'Paris is the capital city of France and Barcelona of Spain',
groundTruth: 'Paris is the capital city of France, London of England and Madrid of Spain',
});
console.log(result.metrics.correctness, result.metrics.completeness, result.metrics.alignment);
PINECONE_API_KEY="YOUR_API_KEY"
curl https://prod-1-data.ke.pinecone.io/assistant/evaluation/metrics/alignment \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-Api-Version: 2026-07" \
-d '{
"question": "What are the capital cities of France, England and Spain?",
"answer": "Paris is the capital city of France and Barcelona of Spain",
"ground_truth_answer": "Paris is the capital city of France, London of England and Madrid of Spain"
}'
{
"metrics": {
"correctness": 123,
"completeness": 123,
"alignment": 123
},
"reasoning": {
"evaluated_facts": [
{
"fact": {
"content": "<string>"
},
"entailment": "<string>"
}
]
},
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"message": "<string>"
}{
"message": "<string>"
}# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
result = pc.assistants.evaluate_alignment(
question="What are the capital cities of France, England and Spain?",
answer="Paris is the capital city of France and Barcelona of Spain",
ground_truth_answer="Paris is the capital city of France, London of England and Madrid of Spain",
)
print(result.scores.correctness, result.scores.completeness, result.scores.alignment)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const result = await pc.assistants.evaluate({
question: 'What are the capital cities of France, England and Spain?',
answer: 'Paris is the capital city of France and Barcelona of Spain',
groundTruth: 'Paris is the capital city of France, London of England and Madrid of Spain',
});
console.log(result.metrics.correctness, result.metrics.completeness, result.metrics.alignment);
PINECONE_API_KEY="YOUR_API_KEY"
curl https://prod-1-data.ke.pinecone.io/assistant/evaluation/metrics/alignment \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-Api-Version: 2026-07" \
-d '{
"question": "What are the capital cities of France, England and Spain?",
"answer": "Paris is the capital city of France and Barcelona of Spain",
"ground_truth_answer": "Paris is the capital city of France, London of England and Madrid of Spain"
}'
Authorizations
Headers
Required date-based version header
Body
The request body for the alignment evaluation.
The request for the alignment evaluation.
Response
The evaluation metrics and reasoning for the generated answer.
The response for the alignment evaluation.
The metrics returned for the alignment evaluation.
Show child attributes
Show child attributes
The reasoning behind the alignment evaluation.
Show child attributes
Show child attributes
Contains the token usage details for LLM interactions, including tokens used in requests (prompt_tokens), tokens used in responses (completion_tokens), and the total number of tokens (total_tokens).
Show child attributes
Show child attributes
Was this page helpful?