New to Kestra?
Use blueprints to kickstart your first workflows.
Build an AI model router on Kestra. Classify prompts with OpenAI, then route coding, reasoning, search, and general queries to the best-fit LLM.
Build an AI model router that classifies each incoming prompt and dispatches it to the most suitable large language model, so you stop paying frontier prices for simple questions and stop sending hard problems to weak models. A lightweight OpenAI classifier reads the request, tags it as coding, reasoning, search, or general, and a single routing decision picks the right provider for the job. This solves the core problem of multi-provider AI: choosing the right model per request, with full observability over every classification and response.
classify_request task (io.kestra.plugin.openai.ChatCompletion, model gpt-4o-mini) classifies the user prompt into one of four categories using a constrained jsonResponseSchema and a small maxTokens budget, keeping classification fast and cheap.route_to_model task (io.kestra.plugin.core.flow.Switch) reads the category with a jq expression over the classifier output and selects a branch.coding_model (io.kestra.plugin.anthropic.ChatCompletion, Claude Opus). Reasoning prompts go to reasoning_model (io.kestra.plugin.gemini.ChatCompletion, Gemini 2.5 Flash). Search prompts go to search_model (io.kestra.plugin.perplexity.ChatCompletion, Sonar) for real-time web retrieval.defaults, hitting general_model (io.kestra.plugin.openai.ChatCompletion, gpt-4o-mini) for cost-efficient general answers.A provider SDK can call one model, but it cannot coordinate classification, branching, retries, and lineage across several vendors. Kestra adds event and schedule triggers, automatic retries on transient API errors, and full execution lineage so every routing decision is logged and replayable. The entire pipeline is declarative YAML you can version and review, filling the gap that no single LLM provider's own client can cover: vendor-agnostic routing with auditability.
>= 0.16).OPENAI_API_KEY: used by the classifier and the general fallback model.ANTHROPIC_API_KEY: used by the coding branch.GEMINI_API_KEY: used by the reasoning branch.PERPLEXITY_API_KEY: used by the search branch.OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, and PERPLEXITY_API_KEY as Kestra secrets.question input, or supply your own prompt.