Cordex Relationship Map Cordex Relationship Map
Cordex Relationship Map · AI helper flow · Admin guide

AI Helper Flow - Admin Guide

A single callable child flow that routes an AI request to Anthropic, OpenAI, Microsoft Foundry, xAI Grok, Google Gemini, or any custom endpoint. Import it, turn it on, and call it from your own flow with a small set of parameters - the ready-made router behind the in-tenant flow option.

Solution: CordexAIHelperFlow 1.1.0.1Type: Child flow (instant)Audience: Admins / makersUsed by the in-tenant flow option

Download PDF opens your browser's print dialog - choose "Save as PDF".

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

1

Import the solution

SolutionsImport solution → choose CordexAIHelperFlow_1_1_0_1_unmanaged.zip for a dev environment, or the managed zip downstream. It imports as a draft flow.

2

Turn the flow on

Open the solution → open Cordex AI Helper FlowTurn on. Required A child flow must be on before Run a Child Flow can see it.

3

Store your API keys as secrets

Create a Key Vault-backed environment variable per provider key: SolutionsNewMoreEnvironment 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.

4

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

InputRequiredUsed byNotes
ProviderYesallDropdown that drives the route: Anthropic (Claude), OpenAI (ChatGPT), Microsoft Foundry, xAI (Grok), Google (Gemini), Other (custom).
QuestionYesbuilt-inThe user prompt / question.
ModelYes (built-in)Anthropic, OpenAI, Foundry, Grok, GeminiThe model id (see each option).
ApiKeyYes (built-in)all built-inThe provider key. Pass from your Key Vault environment variable.
SystemOptall built-inSystem prompt.
HistoryOptall built-inPrior turns as a JSON array string: [{"role":"user","content":"..."},{"role":"assistant","content":"..."}].
MaxTokensOptall built-inMax output tokens (default 1024).
EndpointFoundryFoundryFull chat/completions URL incl. api-version.
VerbOtherOtherHTTP method, e.g. POST.
UriOtherOtherFull request URL.
HeadersOtherOtherHeaders as a JSON object string.
BodyOtherOtherRequest body as a JSON object string.

Outputs the caller gets back

OutputMeaning
AnswerThe model's answer text on success. For Other, the raw response body passed through as-is. Empty on error.
ProviderEcho of the provider that was called.
RawThe provider's full raw response (JSON as text) - for debugging or reading fields the flow doesn't extract.
ErrorEmpty 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.

1
  1. In your own flow, add Run a Child Flow.
  2. Select Cordex AI Helper Flow.
  3. Fill the inputs (see the provider option below).
  4. After it, read Answer / Error from the child flow's outputs.
  5. (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)

A

Set these inputs

  • Provider = Anthropic (Claude)
  • Model = claude-sonnet-5 (or claude-opus-5, claude-fable-5-1, claude-haiku-4-5-20251001)
  • ApiKey = your Anthropic key (from mitaa_AnthropicKey)
  • Question = the prompt; System / History optional
Behind the scenes: 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)

B

Set these inputs

  • Provider = OpenAI (ChatGPT)
  • Model = gpt-6-astra (or gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna)
  • ApiKey = your OpenAI key (from mitaa_OpenAIKey)
  • Question / System / History as needed
Behind the scenes: 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

C

Set these inputs

Foundry is per-tenant, so you also supply the Endpoint.

  1. 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 URL https://<resource>.services.ai.azure.com/models/chat/completions?api-version=...
  2. Provider = Microsoft Foundry
  3. Endpoint = the URL from step 1
  4. Model = your deployment / model name
  5. ApiKey = your Foundry / Azure OpenAI key
  6. Question / System / History as needed
Behind the scenes: 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)

D

Set these inputs

  • Provider = xAI (Grok)
  • Model = grok-4 (confirm the current id with xAI)
  • ApiKey = your xAI key
  • Question / System / History as needed
Behind the scenes: 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)

E

Set these inputs

  • Provider = Google (Gemini)
  • Model = gemini-2.5-pro or gemini-2.5-flash (confirm the current id with Google)
  • ApiKey = your Google AI Studio key
  • Question / System / History as needed
Behind the scenes: POST https://generativelanguage.googleapis.com/v1beta/models/<Model>:generateContent?key=<key>; History roles are mapped (assistantmodel); System goes to system_instruction; answer from candidates[0].content.parts[0].text.

Provider option F

Other (custom) - any provider not built in

F

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.

  1. Provider = Other (custom)
  2. Verb = POST (or GET, etc.)
  3. Uri = the full endpoint URL
  4. Headers = a JSON object string, e.g. {"Authorization":"Bearer YOUR_KEY","content-type":"application/json"}
  5. Body = a JSON object string, e.g. {"model":"my-model","messages":[{"role":"user","content":"Hello"}]}
Behind the scenes: the flow issues your exact request. Answer = the raw response body; parse it in your calling flow, or read Raw. Question / Model / System / History are not used for Other - you build the full request yourself.

Step 4

Handling the result

Every call returns the same four outputs. In the calling flow:

  1. Condition: Error is equal to   (empty).
  2. If yes - use Answer (write it to a column, return it to the viewer, etc.).
  3. If no - log Error and, if you need the provider's exact failure, inspect Raw.
Common causes of an error: wrong or expired key, wrong Model id, wrong Endpoint (Foundry), or a malformed Headers / Body JSON string (Other). The flow is fail-closed with a Try/Catch, so a provider failure returns a populated Error rather than crashing the run.

Step 5

Security

  • Pass ApiKey from 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 / Body as sensitive if they carry a key - source them from a secret the same way.

Step 6

Quick reference - minimum inputs

ProviderRequired inputs
Anthropic (Claude)Provider, Model, ApiKey, Question
OpenAI (ChatGPT)Provider, Model, ApiKey, Question
Microsoft FoundryProvider, 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.