Skip to main content

What it does

The X-Lectr-Task header tells Lectr what kind of work a request is doing. Without it, Lectr guesses from signals like prompt length and response length — educated guesses, medium confidence. With it, Lectr knows with certainty and generates high-confidence model recommendations.
X-Lectr-Feature: classifier
X-Lectr-Task: classification   ← this one
That’s it. One extra header.

The five task types

ValueUse when you’re…
classificationSorting input into categories — sentiment, intent, priority
summarisationCondensing content into a shorter form
extractionPulling structured data out of unstructured text
generationCreating new content — copy, emails, code
reasoningMulti-step thinking, analysis, complex problem solving
Values outside this list are stored as-is and visible in your dashboard but don’t influence recommendations.

Adding the header

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: "https://proxy.lectr.ai/v1",
  defaultHeaders: {
    "X-Lectr-Key": process.env.LECTR_KEY,
    "X-Lectr-Feature": "classifier",
    "X-Lectr-Task": "classification",
  },
});
If your feature handles multiple task types, override per request:
const response = await client.chat.completions.create(
  { model: "gpt-4o", messages },
  { headers: { "X-Lectr-Task": isComplex ? "reasoning" : "generation" } },
);

How Lectr uses it

Model recommendations

Task type is the highest-confidence signal in the recommendation engine — it overrides heuristic signals when present.
Task typeWhat Lectr does
classificationStrong downgrade candidate — smaller models handle this well
summarisationDowngrade candidate — more conservative if prompts are long
extractionDowngrade candidate — conservative for complex nested extraction
generationNeutral — relies on other signals, not task type alone
reasoningNever recommended for downgrade. Ever.
The reasoning protection is hardcoded. No signal, no matter how strong, will produce a downgrade recommendation for a reasoning task.

Dashboard visibility

Task type appears as a column in your request logs table — you can see exactly which task type was tagged on each request and filter by it.

Using with routing rules

Routing rules can use task type to automatically direct requests to the right model. For example:
If X-Lectr-Task = classification
→ Route to gpt-4o-mini
This allows you to:
  • run simple tasks on cheaper models
  • reserve powerful models for complex reasoning
  • optimize cost without changing application code
Task type becomes a reliable signal for automated routing — no heuristics, no guesswork. See Routing Rules for how to configure this.

Reference

HeaderX-Lectr-Task
RequiredNo
Valid valuesclassification summarisation extraction generation reasoning
Invalid valuesStored as-is, no influence on recommendations
MissingRequest processed normally, heuristic signals used

FAQ

No — they’re independent. But combining them gives Lectr the most context and produces the most confident recommendations.
Override per request. A chat feature might use reasoning for complex questions and generation for drafting — tag each request with what it’s actually doing.
No. Lectr reads the header and stores it as metadata. Your prompt, model choice, and response are untouched.
No. The header is read on ingress and stored after the request completes. Zero hot path impact.