> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sunbird.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Summarization

> Summarize text with the Sunflower model

Summarization is now handled by the **Sunflower** conversational AI through the OpenAI-compatible `POST /tasks/chat/completions` endpoint. Instead of a dedicated summarization route, you send the text you want condensed along with a **summarization instruction prompt**.

<Warning>
  The legacy `/tasks/summarise` endpoint is deprecated. Use `/tasks/chat/completions` with a summarization instruction, as shown below.
</Warning>

## How it Works

You drive summarization through the `messages` array:

* A **system** message defines the summarization behavior (length, tone, and any anonymization requirements).
* A **user** message carries the text to be summarized.

This approach is flexible — adjust the instruction to control summary length, language, format (bullets vs. prose), and whether to anonymize personal identifiable information (PII).

### Example Request

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.sunbird.ai/tasks/chat/completions"

  headers = {
      "accept": "application/json",
      "Authorization": "Bearer <your-access-token>",
      "Content-Type": "application/json",
  }

  text = (
      "John Doe, who lives in Kampala, reported that the water supply was cut off "
      "yesterday at 2 PM. He called the utility company but got no response."
  )

  payload = {
      "model": "Sunbird/Sunflower-14B",
      "messages": [
          {
              "role": "system",
              "content": (
                  "You are a summarization assistant. Produce a concise summary of "
                  "the user's text. Anonymize any personal identifiable information "
                  "(names, exact locations, contact details)."
              ),
          },
          {"role": "user", "content": text},
      ],
      "temperature": 0.3,
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json()["choices"][0]["message"]["content"])
  ```

  ```python OpenAI SDK theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="<your-access-token>",
      base_url="https://api.sunbird.ai/tasks",
  )

  completion = client.chat.completions.create(
      model="Sunbird/Sunflower-14B",
      messages=[
          {
              "role": "system",
              "content": (
                  "You are a summarization assistant. Produce a concise summary of "
                  "the user's text. Anonymize any personal identifiable information."
              ),
          },
          {"role": "user", "content": "John Doe, who lives in Kampala, reported that the water supply was cut off yesterday at 2 PM."},
      ],
      temperature=0.3,
  )

  print(completion.choices[0].message.content)
  ```
</CodeGroup>

### Response

The summary is returned in the standard chat completion format:

```json theme={null}
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "Sunbird/Sunflower-14B",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A resident of Kampala reported a water supply interruption yesterday afternoon and was unable to reach the utility company."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 58, "completion_tokens": 24, "total_tokens": 82 }
}
```

<Tip>
  Tune the system instruction to control the output — for example, "Summarize in three bullet points in Luganda" or "Give a one-sentence summary." See the [Sunflower Chat](/guides/sunflower-chat) guide for the full set of supported parameters.
</Tip>
