Source
yaml
id: ai-agent-calling-flows
namespace: tutorial
description: AI Agent
inputs:
- id: use_case
type: SELECT
displayName: Select Your Orchestration Use Case
defaults: Just Exploring
values:
- Business Automation
- Business Processes
- Data Engineering Pipeline
- Data Warehouse and Analytics
- Infrastructure Automation
- Microservices and APIs
- Just Exploring
tasks:
- id: agent
type: io.kestra.plugin.ai.agent.AIAgent
prompt: |
Execute a flow that best matches the {{inputs.use_case}} use case selected by the user. Use the following mapping of use cases to flow ids:
- Business Automation: business-automation
- Business Processes: business-processes
- Data Engineering Pipeline: data-engineering-pipeline
- Data Warehouse and Analytics: dwh-and-analytics
- Infrastructure Automation: infrastructure-automation
- Microservices and APIs: microservices-and-apis
- Just Exploring: hello-world
Remember that all those flows are in the tutorial namespace.
Return only the Execution URI with no extra characters - the structure of URL is {{ kestra.url ?? 'http://localhost:8080/'}}ui/<tenantId>/executions/<namespace>/<flowId>/<id>
provider:
type: io.kestra.plugin.ai.provider.GoogleGemini
modelName: gemini-2.5-flash
apiKey: "{{ kv('GEMINI_API_KEY', errorOnMissing=false) }}"
tools:
- type: io.kestra.plugin.ai.tool.KestraFlow
- id: uri
type: io.kestra.plugin.core.debug.Return
format: "{{ (kestra.url ?? 'http://localhost:8080/') ~ 'ui/' ~
fromJson((outputs.agent.toolExecutions | first).result).tenantId ~
'/executions/tutorial/' ~ fromJson((outputs.agent.toolExecutions |
first).result).flowId ~ '/' ~ fromJson((outputs.agent.toolExecutions |
first).result).id }}"
About this blueprint
Getting Started AI
This flow is a simple example of an AI agent use case,
where the agent can autonomously decide which flow to execute based on user input.
Before using this flow, make sure to set up your Google Gemini API key and add it to your Kestra instance as a KV pair with the key GEMINI_API_KEY
, or even better, add it as a secret and change the apiKey
property to {{ secret('GEMINI_API_KEY') }}
.