Overview
One flow, every provider
The AI Helper Flow is a callable child flow. Another flow (or the Cordex viewer, via a thin HTTP wrapper) calls it, passes a few parameters, and gets a value back. A Switch on the Provider input builds the correct HTTP request for the chosen provider and normalises the answer.
You never edit the flow to switch providers - you just pass different inputs. The built-in providers are Anthropic, OpenAI, Microsoft Foundry, xAI (Grok), and Google (Gemini). The Other (custom) option lets you specify the verb, URI, headers, and body yourself and returns the raw response as-is, so any provider not built in still works.
Why a child flow
A child flow is reusable - the customer builds their own flow and calls this one via Run a Child Flow, keeping the AI plumbing in one place. It also runs as the calling identity and holds no key of its own.
Step 1
One-time setup
Import the solution
Solutions → Import solution → choose CordexAIHelperFlow_1_1_0_1_unmanaged.zip for a dev environment, or the managed zip downstream. It imports as a draft flow.
Turn the flow on
Open the solution → open Cordex AI Helper Flow → Turn on. Required A child flow must be on before Run a Child Flow can see it.
Store your API keys as secrets
Create a Key Vault-backed environment variable per provider key: Solutions → New → More → Environment variable → Data type Secret → reference your Key Vault secret. e.g. mitaa_AnthropicKey, mitaa_OpenAIKey.
You pass the key into the flow at call time; keeping it in Key Vault means it never sits in the flow definition or run history in clear text.
Confirm premium
The flow uses the HTTP action (premium). The calling user or service principal needs a Power Automate premium entitlement.
Step 2
Inputs & outputs (the contract)
Inputs the caller passes
| Input | Required | Used by | Notes |
|---|---|---|---|
| Provider | Yes | all | Dropdown that drives the route: Anthropic (Claude), OpenAI (ChatGPT), Microsoft Foundry, xAI (Grok), Google (Gemini), Other (custom). |
| Question | Yes | built-in | The user prompt / question. |
| Model | Yes (built-in) | Anthropic, OpenAI, Foundry, Grok, Gemini | The model id (see each option). |
| ApiKey | Yes (built-in) | all built-in | The provider key. Pass from your Key Vault environment variable. |
| System | Opt | all built-in | System prompt. |
| History | Opt | all built-in | Prior turns as a JSON array string: [{"role":"user","content":"..."},{"role":"assistant","content":"..."}]. |
| MaxTokens | Opt | all built-in | Max output tokens (default 1024). |
| Endpoint | Foundry | Foundry | Full chat/completions URL incl. api-version. |
| Verb | Other | Other | HTTP method, e.g. POST. |
| Uri | Other | Other | Full request URL. |
| Headers | Other | Other | Headers as a JSON object string. |
| Body | Other | Other | Request body as a JSON object string. |
Outputs the caller gets back
| Output | Meaning |
|---|---|
| Answer | The model's answer text on success. For Other, the raw response body passed through as-is. Empty on error. |
| Provider | Echo of the provider that was called. |
| Raw | The provider's full raw response (JSON as text) - for debugging or reading fields the flow doesn't extract. |
| Error | Empty on success; the failure detail (incl. the provider's own error body) on error. |
Caller pattern
Check Error first; if it is empty, use Answer.
Step 3
Calling the flow from your own flow
Identical for every provider - only the input values change.
- In your own flow, add Run a Child Flow.
- Select Cordex AI Helper Flow.
- Fill the inputs (see the provider option below).
- After it, read Answer / Error from the child flow's outputs.
- (Optional) Add a Condition: if Error is empty → use Answer; else handle the error.
Wiring to the Cordex viewer
The viewer's in-tenant flow provider calls an HTTP endpoint. Put a thin HTTP-triggered flow in front: it receives the viewer's POST, calls this child flow, and returns { "answer": <Answer> } with header Access-Control-Allow-Origin: *. The router does the AI work; the wrapper handles the browser path.
Provider option A
Anthropic (Claude)
Set these inputs
- Provider =
Anthropic (Claude) - Model =
claude-sonnet-5(orclaude-opus-5,claude-fable-5-1,claude-haiku-4-5-20251001) - ApiKey = your Anthropic key (from
mitaa_AnthropicKey) - Question = the prompt; System / History optional
POST https://api.anthropic.com/v1/messages, headers x-api-key + anthropic-version: 2023-06-01; answer taken from content[0].text.Provider option B
OpenAI (ChatGPT)
Set these inputs
- Provider =
OpenAI (ChatGPT) - Model =
gpt-6-astra(orgpt-5.6-sol,gpt-5.6-terra,gpt-5.6-luna) - ApiKey = your OpenAI key (from
mitaa_OpenAIKey) - Question / System / History as needed
POST https://api.openai.com/v1/chat/completions, header Authorization: Bearer <key>; System is sent as the first message; answer from choices[0].message.content.Provider option C
Microsoft Foundry
Set these inputs
Foundry is per-tenant, so you also supply the Endpoint.
- In Azure AI Foundry / Azure OpenAI, deploy your model and copy its chat completions endpoint incl. api-version, e.g.
https://<resource>.openai.azure.com/openai/deployments/<deployment>/chat/completions?api-version=2024-10-21
or the Foundry Models inference URLhttps://<resource>.services.ai.azure.com/models/chat/completions?api-version=... - Provider =
Microsoft Foundry - Endpoint = the URL from step 1
- Model = your deployment / model name
- ApiKey = your Foundry / Azure OpenAI key
- Question / System / History as needed
POST to your Endpoint, sending both api-key and Authorization: Bearer headers so it works against Azure OpenAI or the Foundry inference endpoint; answer from choices[0].message.content.Provider option D
xAI (Grok)
Set these inputs
- Provider =
xAI (Grok) - Model =
grok-4(confirm the current id with xAI) - ApiKey = your xAI key
- Question / System / History as needed
POST https://api.x.ai/v1/chat/completions (OpenAI-compatible), header Authorization: Bearer <key>; answer from choices[0].message.content.Provider option E
Google (Gemini)
Set these inputs
- Provider =
Google (Gemini) - Model =
gemini-2.5-proorgemini-2.5-flash(confirm the current id with Google) - ApiKey = your Google AI Studio key
- Question / System / History as needed
POST https://generativelanguage.googleapis.com/v1beta/models/<Model>:generateContent?key=<key>; History roles are mapped (assistant → model); System goes to system_instruction; answer from candidates[0].content.parts[0].text.Provider option F
Other (custom) - any provider not built in
Set these inputs
Use this to call any endpoint - a new provider, an internal gateway, APIM. You specify the whole request; the flow returns the raw response as-is in Answer and Raw.
- Provider =
Other (custom) - Verb =
POST(or GET, etc.) - Uri = the full endpoint URL
- Headers = a JSON object string, e.g.
{"Authorization":"Bearer YOUR_KEY","content-type":"application/json"} - Body = a JSON object string, e.g.
{"model":"my-model","messages":[{"role":"user","content":"Hello"}]}
Step 4
Handling the result
Every call returns the same four outputs. In the calling flow:
- Condition:
Erroris equal to(empty). - If yes - use Answer (write it to a column, return it to the viewer, etc.).
- If no - log Error and, if you need the provider's exact failure, inspect Raw.
Step 5
Security
- Pass
ApiKeyfrom a Key Vault-backed environment variable, not typed inline, so keys are not stored in the flow or its run history in clear text. - The child flow runs as the calling identity; it holds no key itself.
- For Other, treat
Headers/Bodyas sensitive if they carry a key - source them from a secret the same way.
Step 6
Quick reference - minimum inputs
| Provider | Required inputs |
|---|---|
| Anthropic (Claude) | Provider, Model, ApiKey, Question |
| OpenAI (ChatGPT) | Provider, Model, ApiKey, Question |
| Microsoft Foundry | Provider, Endpoint, Model, ApiKey, Question |
| xAI (Grok) | Provider, Model, ApiKey, Question |
| Google (Gemini) | Provider, Model, ApiKey, Question |
| Other (custom) | Provider, Verb, Uri, Headers, Body |
Model ids move
Model ids change over time. The ids in this guide are current as written; confirm the fast-moving ones (Grok, Gemini) against each provider before pinning.