# Sending Feedback

The Feedback API allows users to provide feedback on responses created from the [Chat API](https://docs.cohere.com/fern/pages/-ARCHIVE-/api-reference/chat-1/chat.mdx).

The endpoint accepts preference and performance feedback, which we use to improve our models.  This guide provides a starting point for using the Feedback endpoint.

You can see a live example of the Feedback API in action on our [playground](https://dashboard.cohere.ai/playground/generate). In the image below, we've asked the model to generate titles for a blog post on quantum computing. If you look in the bottom right (where the red arrow is pointing), you'll see you can give a "thumbs up" or a "thumbs down" to provide feedback on the quality of the model's output. The other "stack of papers" icon let's you easily copy the output.

<img src="/current/media/t/75c5dc71-055f-4496-bcaf-6966eeb0b645/p/c4d0babb-28a1-4a78-a85d-f753e1d49ea7/d95a437c2708271f84515e8c3e4a3a608e61ed77a4eb3be2a56a9ae59d0ee55f.png/raw" alt="">

Or, you can read below to learn how to call the feedback endpoint with our API.

***

## Generate Feedback

You can produce detailed feedback based on the annotator's acceptance of the generated response using the `generate_feedback` endpoint.

### **Parameters**

The endpoint has a number of settings you can use to control the kind of output it generates:

- `request_id` (String, required): The request\_id of the generation request to give feedback on.
- `good_response` (Boolean, required): Whether the response was good or not.
- `model` (String): The unique ID of the model.
- `desired_response` (String): The desired response. Used when an annotator edits a suggested response.
- `flagged_response` (Boolean): Whether the response was flagged or not.
- `flagged_reason` (String):  The reason the response was flagged.
- `prompt`(String): The original prompt used to generate the response.
- `annotator_id` (String): The annotator's ID.

### **Example Requests**

If the annotator _accepts_ the suggested response, you could format a request like this:

```python PYTHON
generations = co.generate(
    prompt=f"Write me a polite email responding to the one below: {email}. Response:"
)
if user_accepted_suggestion:
    co.generate_feedback(
        request_id=generations[0].id, good_response=True
    )
```

If the annotator _edits_ the suggested response, you could format a request like this:

```python PYTHON
generations = co.generate(
    prompt=f"Write me a polite email responding to the one below: {email}. Response:"
)
if user_edits_suggestion:
    co.generate_feedback(
        request_id=generations[0].id,
        good_response=False,
        desired_response=user_edited_suggestion,
    )
```

### **Example Response**

## Generate Preference Feedback

Alternatively, you can generate feedback based on which response an annotator prefers with the `generate_preference_feedback` endpoint.

### **Parameters**

- `ratings` (List\[PreferenceRating], required): A list of PreferenceRating objects.
- `model` (String):  The unique ID of the model.
- `prompt` (String): The original prompt used to generate the response.
- `annotator_id` (String):  The annotator's ID.

### **Example Request**

A user accepts a model's suggestion in an assisted writing setting, and prefers it to a second suggestion. Here's what a request might look like:

```python PYTHON
generations = co.generate(
    prompt=f"Write me a polite email responding to the one below: {email}. Response:",
    num_generations=2,
)
if user_accepted_idx:  # prompt user for which generation they prefer
    ratings = []
    if user_accepted_idx == 0:
        ratings.append(PreferenceRating(request_id=0, rating=1))
        ratings.append(PreferenceRating(request_id=1, rating=0))
    else:
        ratings.append(PreferenceRating(request_id=0, rating=0))
        ratings.append(PreferenceRating(request_id=1, rating=1))
    co.generate_preference_feedback(ratings=ratings)
```

## Related pages

- [Changelog](../changelog.md)
- [Cohere](../index.md)
- [Cohere API](./cohere-api-index.md)
- [Cohere Labs](./cohere-labs-index.md)
- [Cohere Platform](./cohere-platform-index.md)
- [Cookbooks](./cookbooks-index.md)
- [Deployment Options](./deployment-options-index.md)
- [Embeddings (Vectors, Search, Retrieval)](./embeddings-vectors-search-retrieval-index.md)
- [Get Started](./get-started-index.md)
- [Going to Production](./going-to-production-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
