---
schema_version: "1"
id: 1064da77e6e51655d4718a326ec8b08aef506f205f0dbf573465624c8d52bb5a
title: Send Generation Feedback Using Models API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/genai/agentforce/guides/models/models-api/models-api-feedback.md
canonical_url: https://developer.salesforce.com/docs/ai/agentforce/guide/models-api-feedback.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f6e88cc772400bd0674421ea636ebf1b817de0e035025d07d33627b9b3133a7b
products:
  - Agentforce Developer Guide
  - Agentforce and Einstein Generative AI
---
# Send Generation Feedback Using Models API

Send feedback about a generative AI provider’s response using the Feedback REST endpoint or Apex class. For example, you can send feedback about a generated email containing misinformation about a product.

## How It Works

When you send a request with a prompt, the response can return one or more generation objects, each with a unique ID. Use this identifier (or your own unique identifier value) to provide feedback to the feedback REST endpoint or the feedback Apex class. This feedback can include additional details about explicit feedback or telemetry data. Feedback data is stored in Data 360.

Each feedback call requires at least two IDs: one that identifies this unique piece of feedback (`id`) and one that identifies the target of this feedback (`generationId`). You can provide information about the feedback sentiment (`feedback`), free-form feedback text (`feedbackText`), and any other use-case-specific data (`appFeedback`). The Models API doesn’t do any semantic validation on this information and is only meant for you to identify and filter the feedback in the datastore. The Models API doesn't limit the size of `feedbackText` in a request. However, the data is truncated to 1024 characters when it's stored in Data 360.

See [Einstein Audit and Feedback Data](https://help.salesforce.com/s/articleView?id=ai.generative_ai_feedback.htm) in Salesforce Help.

## REST Example

In this example, the client sends feedback when the user specified a thumbs down for an incomplete response. The sample code shows the request body when making an HTTP POST request to the `/feedback` endpoint.

```json
{
  "id": "78w60870345-2335840385-4857348-803483",
  "generationId": "89t608-46756v66y-23r4wqxe43-096mi",
  "feedback": "BAD",
  "feedbackText": "The suggested summary was confusing and incomplete",
  "source": "HUMAN"
}
```

See [Submit Feedback REST Endpoint](/docs/ai/agentforce/references/models-api#operation/submitFeedback).

## Apex Example

In this Apex example, the client sends feedback when the user is satisfied with the response.

```apex
// Create feedback request
aiplatform.ModelsAPI.submitFeedback_Request request = new aiplatform.ModelsAPI.submitFeedback_Request();

// Provide feedback information in body
aiplatform.ModelsAPI_FeedbackRequest feedbackRequest = new aiplatform.ModelsAPI_FeedbackRequest();
feedbackRequest.id = '78w60870345-2335840385-4857348-803483';
feedbackRequest.generationId = '89t608-46756v66y-23r4wqxe43-096mi';
feedbackRequest.feedback = 'GOOD';
feedbackRequest.feedbackText = 'The generation was helpful and did not require any changes';
feedbackRequest.source = 'HUMAN';
request.body = feedbackRequest;

// Submit feedback
try {
    aiplatform.ModelsAPI modelsAPI = new aiplatform.ModelsAPI();
    aiplatform.ModelsAPI.submitFeedback_Response response = modelsAPI.submitFeedback(request);
    System.debug('Models API response: ' + response.Code202.message);

// Handle error
} catch(aiplatform.ModelsAPI.submitFeedback_ResponseException e) {
    System.debug('Response code: ' + e.responseCode);
    System.debug('The following exception occurred: ' + e);
}
```

## See Also

- _Models API Developer Guide_: [Access Models API with REST](https://developer.salesforce.com/docs/ai/agentforce/guide/access-models-api-with-rest.md)
- _Models API Developer Guide_: [Access Models API with Apex](https://developer.salesforce.com/docs/ai/agentforce/guide/access-models-api-with-apex.md)
- _Models API Reference_: [Submit Feedback REST Endpoint](/docs/ai/agentforce/references/models-api#operation/submitFeedback)
- _Models API Reference_: [submitFeedback Apex method](/docs/ai/agentforce/references/models-apex-api/models-apex-reference.html#submitfeedback)
- _Salesforce Help_: [Einstein Audit and Feedback Data](https://help.salesforce.com/s/articleView?id=ai.generative_ai_feedback.htm)
