# Search & Summarize

> Search + AI summarization in one API call.

Source: http://localhost:3000/docs/endpoints/search-summarize

## Search & Summarize: `POST /v1/search-and-summarize/`

Search plus a short synthesized summary with sources. Cost: 5 credits. Available on the free demo.

```bash
curl -X POST https://api.hushsearch.io/v1/search-and-summarize/ \
  -H "X-API-Key: hs_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "latest stable Python release notes",
  "num_results": 5
}'
```

Combines real-time web search with AI summarization (via Groq Llama). One call returns both raw results AND a synthesized, source-cited summary. Perfect for research assistants and Q&A bots.

## Request

```bash
curl -X POST https://api.hushsearch.io/v1/search-and-summarize/ \
  -H "X-API-Key: hs_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What is retrieval augmented generation and when should I use it?",
    "num_results": 5
  }'
```

### Parameters

Same as [`/v1/search/`](http://localhost:3000/docs/endpoints/search) — all search parameters are supported.

## Response

```json
{
  "summary": "Retrieval-Augmented Generation (RAG) is a technique that combines information retrieval with language model generation [1]. It's best used when you need up-to-date information not in the model's training data [2]...",
  "results": [
    {
      "title": "RAG Explained — AWS Blog",
      "url": "https://aws.amazon.com/what-is/retrieval-augmented-generation/",
      "snippet": "RAG is an AI framework..."
    }
  ],
  "credits_used": 5,
  "credits_remaining": 490,
  "response_time_ms": 2850
}
```

## Python Example

```python

response = requests.post(
    "https://api.hushsearch.io/v1/search-and-summarize/",
    headers={"X-API-Key": "hs_live_..."},
    json={
        "query": "How does Apple Intelligence work on iPhone?",
        "num_results": 5,
        "categories": ["general", "it"]
    }
)

data = response.json()
print("Summary:")
print(data["summary"])
print("\nSources:")
for r in data["results"]:
    print(f"  - {r['title']}: {r['url']}")
```

## Note on AI Summarization

The summary uses Groq's `llama3-8b-8192` model. If `GROQ_API_KEY` is not configured, the endpoint still returns results with a fallback message in the summary field.
