---
title: "Template-based queries using self-learning system (20x faster)"
method: POST
path: "/api/query/ask-learned"
tags: ["Query Tools"]
---

# Template-based queries using self-learning system (20x faster)

`POST /api/query/ask-learned`

## Request

- Base URL: `https://api.cernion.de`
- URL: `https://api.cernion.de/api/query/ask-learned`
- Auth: none declared

Execute queries using learned templates from the Sprint 11 Self-Learning System. Reuses proven query patterns for 20x faster execution compared to cernion_ask. Falls back to LLM generation for new patterns.

**Performance**:
- **Template Match**: 50-200ms (20x faster than LLM)
- **New Pattern**: 2-8 seconds (same as cernion_ask, but learns for future use)
- **Confidence Threshold**: 0.6 (60%) default - higher = stricter matching

**Use Cases**:
- Recurring queries (regional capacity, installation counts)
- Performance-critical applications
- Batch processing (analyze multiple regions)
- Real-time dashboards
- API integrations requiring fast responses

**When to Use**:
- ✅ Recurring query patterns ("PV capacity in {region}")
- ✅ Performance-critical applications
- ✅ Batch processing
- ❌ First-time complex queries → use cernion_ask first
- ❌ Unstructured exploration → use cernion_ask

## Query parameters

- `token` string

## Request body

- object
  - `query` string, required: Natural language query (same format as cernion_ask)
  - `confidence` number: Minimum confidence threshold for template matching (0.0-1.0)
  - `forceGenerate` boolean: Force LLM generation even if template matches (for testing)
  - `verbose` boolean: Show detailed reasoning and statistics (template used, confidence score)
  - `token` string: Optional Cernion MCP token for this request. Overrides CERNION_TOKEN when provided.

## Response `200`

Successful query execution with template information

- object
  - `success` boolean
  - `result` object: Query result data
  - `templateUsed` boolean: Whether a template was used
  - `confidence` number: Template matching confidence (0.0-1.0)
  - `executionTimeMs` number: Execution time in milliseconds
  - `metadata` object: Execution metadata

---

[API](https://skmtc.dev/cernion/apis/cernion-energy-tools-api.md) · [All operations](https://skmtc.dev/cernion/apis/cernion-energy-tools-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cernion/apis/cernion-energy-tools-api/revisions/cdb94473b538?raw)
