curl --request POST \
--url https://api.helicone.ai/v1/request/{requestId}/feedback \
--header 'Content-Type: application/json' \
--data '{
"rating": true
}'{
"data": null,
"error": {}
}Add thumbs up/down feedback to a specific request
curl --request POST \
--url https://api.helicone.ai/v1/request/{requestId}/feedback \
--header 'Content-Type: application/json' \
--data '{
"rating": true
}'{
"data": null,
"error": {}
}Add user feedback to a request to track quality and satisfaction. This endpoint allows you to mark requests as positive or negative, which can be used for filtering, analytics, and improving your LLM application.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/helicone/helicone/llms.txt
Use this file to discover all available pages before exploring further.
true for positive (thumbs up) and false for negative (thumbs down).Helicone-Id response header when making requests through Helicone.Example: req_abc123def456true - Positive feedback (thumbs up)false - Negative feedback (thumbs down)curl --request POST \
--url https://api.helicone.ai/v1/request/req_abc123def456/feedback \
--header 'Authorization: Bearer <HELICONE_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"rating": true
}'
const requestId = 'req_abc123def456';
const response = await fetch(
`https://api.helicone.ai/v1/request/${requestId}/feedback`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
rating: true
})
}
);
const result = await response.json();
console.log('Feedback added successfully');
import os
import requests
request_id = "req_abc123def456"
response = requests.post(
f"https://api.helicone.ai/v1/request/{request_id}/feedback",
headers={
"Authorization": f"Bearer {os.environ['HELICONE_API_KEY']}",
"Content-Type": "application/json"
},
json={
"rating": True
}
)
result = response.json()
print("Feedback added successfully")
curl --request POST \
--url https://api.helicone.ai/v1/request/req_abc123def456/feedback \
--header 'Authorization: Bearer <HELICONE_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"rating": false
}'
const requestId = 'req_abc123def456';
const response = await fetch(
`https://api.helicone.ai/v1/request/${requestId}/feedback`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
rating: false
})
}
);
const result = await response.json();
console.log('Negative feedback recorded');
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://gateway.helicone.ai/v1',
defaultHeaders: {
'Helicone-Auth': `Bearer ${process.env.HELICONE_API_KEY}`
}
});
// Make a request and capture the request ID
const { data, response } = await client.chat.completions
.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Explain quantum computing' }]
})
.withResponse();
const requestId = response.headers.get('helicone-id');
// Display response to user
const assistantMessage = data.choices[0].message.content;
console.log('Response:', assistantMessage);
// Later, when user provides feedback (e.g., thumbs up/down button)
const userFeedback = true; // User clicked thumbs up
await fetch(
`https://api.helicone.ai/v1/request/${requestId}/feedback`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ rating: userFeedback })
}
);
// Query all requests with positive feedback
const queryPositiveFeedback = async () => {
const response = await fetch(
'https://api.helicone.ai/v1/request/query',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
filter: {
feedback: {
rating: {
equals: true
}
}
},
limit: 100
})
}
);
const result = await response.json();
console.log(`Found ${result.data.length} requests with positive feedback`);
return result.data;
};
// Query all requests with negative feedback
const queryNegativeFeedback = async () => {
const response = await fetch(
'https://api.helicone.ai/v1/request/query',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
filter: {
feedback: {
rating: {
equals: false
}
}
},
limit: 100
})
}
);
const result = await response.json();
console.log(`Found ${result.data.length} requests with negative feedback`);
return result.data;
};
// Version A
const testPromptA = async () => {
const { data, response } = await client.chat.completions
.create(
{
model: 'gpt-4',
messages: [{
role: 'system',
content: 'You are a helpful assistant.'
}, {
role: 'user',
content: userQuery
}]
},
{
headers: {
'Helicone-Property-Prompt-Version': 'A',
'Helicone-Property-Experiment': 'prompt-test-1'
}
}
)
.withResponse();
return {
requestId: response.headers.get('helicone-id'),
content: data.choices[0].message.content
};
};
// Version B
const testPromptB = async () => {
const { data, response } = await client.chat.completions
.create(
{
model: 'gpt-4',
messages: [{
role: 'system',
content: 'You are a concise assistant that provides brief answers.'
}, {
role: 'user',
content: userQuery
}]
},
{
headers: {
'Helicone-Property-Prompt-Version': 'B',
'Helicone-Property-Experiment': 'prompt-test-1'
}
}
)
.withResponse();
return {
requestId: response.headers.get('helicone-id'),
content: data.choices[0].message.content
};
};
// Collect feedback and compare
const collectFeedback = async (requestId: string, userRating: boolean) => {
await fetch(
`https://api.helicone.ai/v1/request/${requestId}/feedback`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ rating: userRating })
}
);
};
const addAutomatedFeedback = async (requestId: string, responseData: any) => {
// Example: Mark as negative if response is too short
const responseText = responseData.choices[0].message.content;
const isGoodResponse = responseText.length > 50 &&
!responseText.includes('[error]');
await fetch(
`https://api.helicone.ai/v1/request/${requestId}/feedback`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ rating: isGoodResponse })
}
);
};
// Initial feedback
await fetch(
`https://api.helicone.ai/v1/request/${requestId}/feedback`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ rating: true })
}
);
// Update feedback later
await fetch(
`https://api.helicone.ai/v1/request/${requestId}/feedback`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.HELICONE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ rating: false })
}
);