Quick Overview
This sub-workflow is called via Execute Workflow and routes a prompt to Anthropic, Google Gemini, Mistral, or OpenAI, then normalizes the model output into a single response field while estimating token usage and cost.
How it works
- Receives input from another workflow via the Execute Workflow trigger.
- Applies default settings, normalizes fields (provider, model, prompts, temperature, token limit, response format), and builds the provider-specific request payload.
- Estimates input tokens and stops the run if the prompt exceeds a safety threshold of the selected model’s context limit.
- Routes the request to the selected provider and calls the corresponding API (Anthropic Messages, Google Gemini generateContent, Mistral chat completions, or OpenAI chat completions).
- Extracts and normalizes the returned text (or an error message) into
llm_response, and captures actual token usage when the provider returns it.
- Estimates output tokens and cost from a built-in pricing table, then returns the original input merged with response, model/provider used, token counts, and cost fields.
Setup
- Create credentials for each provider you plan to use: Anthropic API, Google AI (PaLM) API for Gemini, Mistral Cloud API, and/or OpenAI API.
- Set your preferred defaults in the CONFIG step (default provider, default model per provider, temperature, max tokens, and response format).
- Call this workflow from other workflows using Execute Workflow and pass at minimum a
userPrompt field (optionally systemPrompt, llm_provider, model overrides, temperature, max_tokens, and response_format).
- Activate the workflow so it can be executed as a sub-workflow.