A lesson is completed when you tick it, when you watch its video to the end or when you score 80% on its quiz. The certificate is issued online after the final assessment, from a score of 32 out of 40.
Lesson 19, module 5: Plugging an AI into a flow Plugging OpenAI, Claude, Gemini or Mistral into a flow: the key, the model and the cost Is your ChatGPT subscription enough to plug an AI into a flow?
No. The API is paid for separately, per token, with its own key. A developer account, not the subscription One named key per flow Stored in the credentials A call is set up in six layers, once and for all. [Diagram: What a call to an AI contains] The credential The model The system prompt The flow data The output format The token limit Each layer is set once in the module or the node, then used on every run. Sorting a thousand short e-mails costs a few tens of pence. Price per million tokens Output costs more than input The platform often weighs more The smallest model first, the biggest only if the test requires it. [Diagram: Which model for which task] Vertically, task difficulty; horizontally, call volume. Mid-range model Mid-range, but measured The cheapest Preferred: The cheapest, in batches Always start with the highlighted box, then move up a notch if the test on your data requires it. Test the key on a real case before building the rest. Prompt: Classify this message into a single category from quote, after-sales, other. Reply with the word only. Message: “ Hello, could you price three oak windows?” Response: A single word: quote. If the key is pasted wrongly, the node shows an authentication error instead of a response. Cap spending in the console before the first real call. A low monthly cap to start with An alert before the cap One revocable key per flow In the exercise, you choose the AI for the joinery firm in Pessac and work out its cost. Your turn: Choose the AI for the joinery firm's quote request flow The written lesson, the corrected exercise and the quiz are below the video.
Lesson 19 of 50 · module 5, connect ai to a workflow
Connecting OpenAI, Claude, Gemini or Mistral to a workflow: the key, the model and the cost
Connecting an AI to a workflow takes three settings: a paid API key stored in the tool’s credentials, a model chosen for the task, and a spending cap. Classifying a thousand short emails costs a few tens of cents in tokens; the platform, with its tasks and credits, often costs more.
28 min of reading
1 min 49 of video
6 diagrams
1 demande to copy
3 exemples pratiques
4 exercices answerss
5 questions
1 ressource
By the end of this lesson, you will know how to
Create an API key and store it in the n8n, Make or Zapier credentials
Choose a provider and a model based on the task, the data and the volume
Estimate a workflow’s monthly cost in tokens and cap spending before the first call
What’s covered
Three ways to bring AI into a flow
Create the key and store it in the right place
Choose the provider based on your data
Choose the model, smallest first
Cap spending before the first real call
3 worked examples, followed from start to finish
Exercise with answers · Choose the AI for the joinery’s quote request workflow
3 practice exercises, from guided to demanding cases
The quiz
Key points
An AI’s API is a separate account from the subscription, billed per token, opened with a key.
One key per flow, stored in the tool's credentials, never in a text field or a spreadsheet.
Choose the provider on data first: paid plan, training excluded, contract accepted, Europe if possible.
The cheapest model first; the biggest only if a test on your data requires it.
A spending cap is set in the console on the day the key is created.
So far, the Pessac joinery firm’s reference workflow copies quote requests and applies written rules. For it to read a request and say whether it’s about a window, a staircase or a complaint, it needs an AI. You don’t open it in a browser like ChatGPT: you call it through its API, an entry point for programs, with a key, a model and a per-token bill. Your ChatGPT, Claude or Gemini subscription doesn’t cover it: it’s a separate account with the same vendor.
Three ways to bring AI into a flow
The three possible connections, checked on 15 November 2026
Connection
How
Who bills you
Who it's for
The AI supplied by the platform
AI by Zapier, Make’s AI provider, n8n Cloud “Gateway credits”: no key to create
The platform, in tasks or credits
Try it in an hour, small volumes
Your own key in a module
The tool’s OpenAI, Anthropic, Gemini or Mistral module, with your key in its credentials
The AI provider per token, plus the action counted by the platform
The general case of an SME in production
A direct HTTP call
The n8n HTTP Request node or the Make HTTP module, with the request written by hand
The AI provider, per token
A setting the module does not offer yet
Our advice: try the AI provided by the platform if you want to see the result the same day, then switch to your own key as soon as the flow handles customer data. You then choose the provider, you read its data policy, and the token bill comes to you, itemised, instead of disappearing into a bundle of credits. On n8n Cloud, Gateway credits go through OpenAI, Anthropic or Gemini without a key of your own: handy for a test, but the balance is shared by the whole instance and the nodes stop when it reaches zero.
What a call to an AI contains
The credential
The API key, stored in the tool’s credentials. It says who pays.
The model
The cheapest for classifying, a mid-range one for drafting. It sets the token price.
The system prompt
The role, the rules, the allowed categories. The same on every call.
The workflow’s data
The e-mail, the form, the spreadsheet row, inserted by an expression.
The output format
Free text or JSON enforced by a schema, the subject of the next lesson.
The token limit
The cap on response length. It also limits the cost of a call.
Each layer is set once in the module or node, then used on every run.
Create the key and store it in the right place
Create an Anthropic key and store it in n8n
Sign in to the Claude console with the company account, not a personal account.
Open Settings › API Keys (the keys page), then click “+ Create Key”.
Name the key after the flow and the tool, for example “n8n-devis-menuiserie”, then copy it: it will not be shown again.
In n8n, open an Anthropic node (or the model sub-node of an AI node), go to the “Credential” field, then “Create new credential”.
Paste the key into the “API Key” field, save, and check that the node shows a successful connection.
Clear the clipboard: paste any text to overwrite the copied key.
The path is the same elsewhere: the “API keys” page on the OpenAI platform (“Create new secret key” button), the Mistral console, or Google AI Studio for Gemini, then the tool’s credential (“credential” in n8n, “connection” in Make, “account” in Zapier). These consoles’ labels change often: look for “API keys” in the settings menu if it has moved.
Before building anything around it, check that the key responds. The command below runs in the Terminal on a Mac or Linux machine. The key is read from an environment variable: it appears neither in the command nor in the terminal history if you enter it with the first line.
Test an Anthropic key with a one-line classification (Mac or Linux)Terminal
# 1. Saisir la clé sans l'afficher (collez-la puis Entrée)
read -s ANTHROPIC_API_KEY && export ANTHROPIC_API_KEY
# 2. Un appel minimal : le modèle le plus économique, 20 jetons de réponse au plus
# (en-tête de version tel qu'il figure dans la documentation au 15/11/2026)
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "content-type: application/json" \
-d '{
"model": "claude-haiku-5-5",
"max_tokens": 20,
"messages": [{"role": "user",
"content": "Classe ce message dans une seule catégorie parmi devis, sav, autre. Réponds par le mot seul. Message : Bonjour, pouvez-vous chiffrer trois fenêtres en chêne ?"}]
}'
# 3. Dans la réponse, lisez "text" (le mot attendu) et "usage" (les jetons comptés)
A response that starts with an authentication error means the key was pasted incorrectly or has been revoked. This call costs around a thousandth of a cent.
Choose the provider based on your data
Choosing a provider depends less on quality, which is similar for classifying or extracting, than on three questions: where your data is processed, whether it is used to train models, and what contract binds you. Two facts noted on 15 November 2026 matter for a French SME. At Anthropic, the API processes requests by default with “global” routing, in any available region; the “us” option keeps them in the United States for a 10% surcharge; no European option is offered on the direct API. At Google, the Gemini API terms state that the free tier may be used to improve products, with human review; for a user located in the European Economic Area, the paid-tier rules apply to all services, and an application open to EEA users must use the paid services.
Before connecting to emails
1Is the key on a paid plan, in the company’s name?
No Open a business account with billing before connecting a single e-mail.
2Does the data policy exclude training on your calls?
No Opt out of training in the console, or change provider.
3Does the workflow send only the fields the task needs?
No Remove signatures, attachments and unnecessary threads before the call.
4Is a spending cap set in the console?
No Set it before the first real call, even if low.
Yes to allConnect it, and record the provider, model and cap on the workflow sheet.
Go through this before pasting a key into a workflow that reads customer data.
Our position for a flow that reads customer e-mails: a paid key in the company's name, training opted out, the data processing agreement accepted, and a European region when the tool offers one. Mistral, a French vendor, and OpenAI's regional processing (with a 10% surcharge on models released since 5 March 2026) meet this last requirement; the lesson on GDPR in your flows compares contracts and hosting provider by provider.
Choose the model, smallest first
Public prices per million tokens, in dollars, checked on 15 November 2026 (excl. tax, excl. batch processing)
Supplier
Budget model (input / output)
Mid-range model (input / output)
OpenAI
gpt-5-nano: about $0.05 / $0.40
gpt-5-mini: about $0.25 / $2
Anthropic
Claude Haiku 5.5: about $0.10 / $0.50 (requests up to 100,000 tokens)
Claude Sonnet 5.5: about $2 / $10
Google
Gemini 2.5 Flash-Lite: about $0.10 / $0.40
Gemini 3 Flash Preview: about $0.50 / $3
Three takeaways from this table. Price is counted in tokens, fragments of words: what you send (prompt and e-mail) is billed as input, and what the AI writes as output, which costs several times more. Next, batch processing, when the result can wait a few hours, is half price at OpenAI, Anthropic and Google. Finally, these names change: Google has announced that Gemini 2.5 Flash will be redirected to another model on 1 December 2026, and two of its models double in price on 1 January 2027. Record the model on the flow sheet and check the pricing page each time you review the sheet. Mistral connects the same way; check its prices on its pricing page on the day you choose.
Which model for which task
Reasoning, long-form writingTask difficultyClassify, extract a field
Mid-range model
Few calls: price matters little, text quality matters a lot.
Mid-range, but used sparingly
Split the task: the small model sorts, the mid-range model drafts what remains.
The cheapest
It classifies and extracts very well when the instruction is clear.
The cheapest, in batches
High volume, not urgent: batch processing at half price.
A few dozen a monthCall volumeThousands a month
Always start with the highlighted box, then move up a level if testing on your data requires it.
Have an assistant work out a workflow’s monthly cost, with the calculation run
You are a management controller at an SME with 12 employees.
Context: a flow calls an AI for every quote request received. Volume: [number] requests per month. Tokens per call, measured over five test executions: [number] input, [number] output. Model prices checked on [date]: $[price] per million input tokens, $[price] output. The platform bills [number] actions per execution; plan price: $[price] per month for [number] actions.
Task: calculate the monthly AI cost, the share of the platform plan used, and the total cost if the volume doubles.
Format: a three-row table (today, double volume, triple volume), then two sentences. Calculate by running code and show the formulas. Do not add any price I have not given.
Roughly what you should get
A three-row table showing, for each volume, the token cost in dollars, the number of actions used and the percentage of the plan, then two sentences along the lines of “The AI cost stays below one dollar; the platform plan is reached from so many requests”. Redo one row on a calculator before copying the figure onto the sheet.
The actual tokens can be read in the AI node's execution history (the “usage” field or equivalent): measure them on five real messages rather than estimating them.
Cap spending before the first real call
Set a monthly cap in the Claude console
Open the Spend limits page in the console settings (platform.claude.com/settings/spend-limits).
Next to “Monthly spend limit”, click “Adjust limit” or “Set limit”.
Enter a low amount for the first month, for example $20, and save.
Record this cap on the flow sheet, in the Control box, along with the person notified if it is reached.
Once the cap is reached, calls are refused until the following month or until you raise it. The flow fails with an error, which is better than a surprise bill. Each Anthropic account tier also has its own mandatory monthly cap ($500 on the first paid tier, checked on 15 November 2026). The OpenAI, Google and Mistral consoles each have their own page for limits and billing alerts: set it up the day you create the key, not the day the bill arrives. An SME's bill rarely climbs because of normal volume. It climbs when a flow runs in a loop: a reply e-mail that triggers the flow again, or a webhook called again after every error. The cap and a token limit on each call are your two safeguards. The lesson on the real cost of a flow in tasks, credits, executions and tokens adds month-by-month monitoring.
Mistakes to avoid
Looking in Make or n8n for where to paste your ChatGPT Plus login, or believing the subscription covers the API.
The subscription gives access to the ChatGPT app; the API is a separate account, billed per token, that only works with a key.
Create an API account in the company’s name, with its own billing, and one key per workflow.
Pasting the key into a Set node, a hand-written header field or a spreadsheet cell “so you can find it again”.
The key then appears in plain text in the execution history, in workflow exports and to anyone with access to the spreadsheet.
Store it in the tool’s credentials (credential, connection, account) and select that credential in the node.
Use the most capable model on the plan to classify e-mails, with no limit on response tokens.
The token price can be dozens of times that of the economy model, for a classification that gains nothing from it.
Start with the budget model, test it on thirty real messages and limit the response to what the flow needs.
Leaving API billing on an employee’s or contractor’s card, with no cap.
The day the person leaves or the card expires, the workflow stops; the day the workflow loops, nobody is warned before the bill.
Open the account in the company's name, set a monthly cap in the console and name the person notified on the sheet.
3 SME situations followed from start to finish: the prompts exactly as they were written, the model answer to aim for, and what was checked before sending.
Example 1
An accountancy firm that classifies incoming documents with a Mistral key
Hélène is office manager at a 25-employee accountancy firm in Mérignac. The pieces@ mailbox receives around 900 e-mails a month from clients sending invoices, statements and questions all mixed together. She wants an n8n Cloud workflow that files each message in the right client folder and flags questions to the staff member in charge.
The pieces@ mailbox sorted by Mistral
1Email received
A client sends a document or a question to pieces@.
2Model call
The firm’s key, budget model, category alone in the response.
3Storage
The document goes into the client’s folder according to its category.
4Question flagged
The staff member receives only “question” and “other”.
Request 1
Credential set-up in n8n: Mistral Cloud Chat Model node, “Create new credential”, key created in the Mistral console under the name “n8n-pieces-clients”, training opted out in Admin › Privacy in the console.
Model answer
Connection successful. Credential saved: “Mistral - pieces clients (Hélène)”. The node offers the list of models available for the key.
Hélène names the credential after the workflow and her first name: the day she leaves the firm, her successor knows what to revoke. She checks where the training opt-out sits in the console before writing it into the procedure.
Request 2
Node system prompt: “You sort the e-mails received by an accountancy firm. Allowed categories: facture_achat, facture_vente, releve_bancaire, question, autre. Reply with the category only, in lower case. If the message matches no category, reply autre.”
Model answer
question
Test on a real, anonymised e-mail: “Hello, do we need to keep motorway toll receipts for the expense claim?”. Correct answer. She runs twenty more messages: nineteen correct, and one subcontractor invoice filed as a question, fixed by adding an example to the prompt.
Request 3
Cost measurement: reading the token field in the history of five executions, then calculating for 900 messages with the cheapest model on the plan.
Model answer
Measured average: 650 input tokens, 4 output. For 900 messages: about 585,000 input tokens and 3,600 output, a few cents a month. On n8n Cloud: 900 executions out of the 2,500 on the Starter plan.
Hélène sets a €15 cap in the console and notes on the sheet that the AI costs less than Monday’s coffee. What weighs is the n8n executions.
What was checked before sending
The facts: twenty real, anonymised e-mails run through the flow before go-live, with each category compared against the one Hélène would have chosen.
The “no category” case: an advertising e-mail sent on purpose, filed under “other”.
The data: paid key in the firm’s name, training refused, Mistral’s European hosting checked on its help page.
Order of magnitude: sorting the pieces@ inbox goes from about an hour a day to a quarter of an hour checking the “question” and “other” cases.
Example 2
An online shop that leaves Make's AI provider for its own key
Julien runs operations single-handed for a 6-employee online shop selling solid cosmetics in La Rochelle. His Make scenario summarises each customer review and classifies it as positive, negative or question. He started with Make’s AI provider, with no key, and finds his credits are draining faster than expected.
Before and after the clean key
Make’s AI provider
No key to create
Tokens converted into credits
Handy for trying out
Cost hard to predict
The shop’s OpenAI key
One credit per operation on Make
Tokens billed separately, itemised
European region selected
Cap set in the console
Request 1
Review of the scenario history over a week: number of executions, credits used by the AI module, comparison with the other modules.
Model answer
Week of 3 to 9 November: 410 reviews processed. AI module with Make's provider: 1 credit per operation plus credits calculated on tokens, considerably more than the single credit of the other modules.
Julien realises that Make’s provider converts tokens into credits. With his own key, the module costs only one credit per operation, and tokens are billed separately at the provider’s price.
Request 2
An OpenAI key created in the shop’s name, on a project set to European processing, then the Make OpenAI module connected with this key and the EU region selected in the advanced settings.
Model answer
“OpenAI - avis boutique” connection saved, EU region. First test on a review: “Le shampoing tient trois mois, mais le savon fond trop vite dans la douche” classified as “négatif”, summarised in one line.
Julien checks in Make’s documentation that using your own connection is limited to paid plans: he’s on the Core plan, so that’s fine. He notes that the 10% surcharge for OpenAI’s regional processing is only a matter of cents at his volume.
What was checked before sending
The calculations: credits for one week before and after the change, taken from the scenario history.
The facts: thirty real reviews checked, with particular attention to mixed reviews, the ones most often misclassified.
The data: key in the company’s name, European region chosen when the project was created and noted on the sheet.
Order of magnitude: the AI module's credit consumption brought down to one credit per review, and tokens billed at a few cents a month.
Example 3
An estate agency that moves its Gemini key to the paid tier
Patrice runs a 5-person estate agency in Pau. An intern connected a Gemini key, created on a personal Google account without billing, to a Zap that summarises viewing requests. The Zap fails on some Monday mornings, when the weekend's requests arrive all at once.
From the broken Zap to the agency’s own key
Monday 8amTwelve errors
Quota exceeded on a free, personal key.
Monday 10amAgency account
Project with billing, new key in the agency's name.
Monday 10:30amReplay
The twelve runs relaunched from the Zap history.
Monday 11amOld key revoked
Procedure recorded in the flow register.
Request 1
Review of the Zap history: error message from the failed runs on Monday 10 November between 8am and 9am.
Model answer
Twelve failed runs, all rejected for exceeding the API quota; the others succeeded. The enquiries concerned were not summarised.
Patrice realises the key was not created for production: without billing, rate limits are low, and the key belongs to an intern who leaves in December.
Request 2
A Google Cloud project created in the agency’s name with a billing account, a new key in Google AI Studio, the connection replaced in the Zap, and the twelve failed runs replayed.
Model answer
Twelve runs replayed successfully. Sample summary: “Viewing requested for the two-bedroom flat on rue Montpensier, Saturday morning preferred, couple with one child, mortgage approved.”
Patrice revokes the old key the same day and files the procedure in the flow register. For an agency in France, Google's terms apply the paid-tier rules anyway; the real reason for the change is reliability and ownership of the key.
What was checked before sending
The facts: the twelve replayed summaries compared with the original requests, with no phone number or price added.
The data: key attached to an agency account, no longer to a person; old key revoked.
The deliberate error: a batch of twenty enquiries sent at once to check the quota holds.
Order of magnitude: no more weekend requests forgotten on Monday, and an hour of manual catch-up saved every week.
Choose the AI for the joinery’s quote request workflow
The Pessac joinery firm (12 employees; windows, staircases and interior fit-outs) receives around 150 quote requests a month through its form and by e-mail. Élodie, sales assistant, wants the workflow to classify each request (window, door, staircase, fit-out, complaint, other) and extract the name, town and type of work. The messages contain private individuals’ names, phone numbers and addresses. The workflow runs on the platform chosen in module 3. Choose the connection method, the provider and the model, work out the AI’s monthly cost, and set the safeguards.
Fill in the five boxes on the sheet for the flow's AI step.
Work through the lesson's decision diagram to choose a provider, justifying your choice by the data involved.
Choose the model with the matrix, then measure tokens on five real anonymised requests.
Calculate the monthly AI cost and the platform cost for 150 requests, then for 300.
Record the spending cap, the person notified and the key name.
See the answers
The AI step sheet
Box
Content
Trigger
A quote request arrives (form submitted or e-mail in the devis@ inbox)
Data
The text of the request, without the signature or history; personal data: yes (a private individual’s name, phone number and address)
Decisions
The AI classifies into six allowed categories, “other” if none fits; it extracts name, town and type of work
Actions
Call to the budget model with the “devis-menuiserie” key, 300 response tokens at most; result written to the requests spreadsheet
Inspection
Green for internal classification; cap of $20 a month; Élodie alerted if there is an error; owner Élodie, back-up the manager
Provider: a paid key in the joinery firm’s name, training excluded, the data processing agreement accepted, and preferably processing in Europe (Mistral, or OpenAI’s regional processing). Model: the cheapest on offer, because classifying into six categories and extracting three fields is the bottom-left box of the matrix.
Safeguards: a $20 monthly cap in the console, a 300-token response limit on the node, a key named “devis-menuiserie” that can be revoked on its own. The cap looks huge next to a few cents: it isn’t there for a normal month, it’s there for the month a workflow loops.
Practise
Three more exercises, from the most guided to the most demanding. The material is provided in full: copy it into your tool, then check your work against the criteria before opening the answers.
Level 1 · guided10 min
Cost three workflows with a calculator
Without opening any account, calculate the monthly token cost of each of the three flows below, using the prices given. Then say, for each one, whether the AI cost or the platform cost weighs more.
The material to work on
MODEL PRICES (rounded for the exercise): $0.10 per million input tokens, $0.50 per million output tokens.
FLOW A, sorting e-mails for a garage in Libourne: 2,000 e-mails a month, 600 input tokens and 10 output tokens per call. Platform: Make, 1 credit per call for the AI module.
FLOW B, summarising site reports for a roofing company: 80 reports a month, 4,000 input tokens, 400 output. Platform: n8n Cloud Starter, one execution per report.
FLOW C, draft replies for a 15-person customer service team: 3,000 messages a month, 1,500 input tokens, 600 output. Platform: Zapier, one task per call.
Check your work
Tokens are converted into millions before being multiplied by the price
Input and output are calculated separately, then added together
Each cost is rounded and shown with “about” and the currency
The comparison with the platform cites the unit it counts (credit, execution, task)
See the answers
The three calculations
Flow
Starter
Output
Total AI per month
What counts
A
1.2 M × 0.10 = $0.12
0.02 M × 0.50 = $0.01
about $0.13
Make: 2,000 credits
B
0.32 M × 0.10 = $0.032
0.032 M × 0.50 = $0.016
about $0.05
n8n: 80 executions, very few
C
4.5 M × 0.10 = $0.45
1.8 M × 0.50 = $0.90
about $1.35
Zapier: 3,000 tasks
Check your calculations with an assistant
By running code, calculate the monthly cost in dollars of three AI workflows, at $0.10 per million input tokens and $0.50 per million output tokens. Workflow A: 2,000 calls, 600 input and 10 output tokens per call. Workflow B: 80 calls, 4,000 and 400. Workflow C: 3,000 calls, 1,500 and 600. Give a table with the input, output and total breakdown, and show the formulas.
Roughly what you should get
A table identical to the one in the answer key, with the formulas visible. Any discrepancy points to an error converting into millions, on one side or the other.
Level 2 · independent15 min
Choose how to connect three workflows
For each of the three flows described, choose the connection (AI provided by the platform, your own key in a module, direct HTTP call), the type of model (budget or mid-range) and a safeguard. Justify your choice in two lines based on the data processed and the volume.
The material to work on
1. A driving school in Agen (4 employees) wants to test, for one week on Zapier Professional, a summary of enrolment requests received via a form. 40 requests expected. Candidates’ name, phone number and date of birth.
2. A haulier in Bègles (40 employees) wants to classify 2,500 customer emails a month (complaint, quote request, parcel tracking, other) on n8n Cloud. The emails contain delivery addresses.
3. An engineering consultancy in Talence (9 employees) wants self-hosted n8n to write a two-page summary of each 30-page test report, around 12 a month. The chosen model must accept a parameter that the node doesn’t offer yet.
Check your work
The one-week test with no sensitive data involved can use the supplied AI; everything else goes through its own key
High-volume classification gets the economy model
The long, infrequent summary gets the mid-range model
The parameter missing from the node justifies the direct HTTP call
Each workflow has a named safeguard (cap, token limit, dedicated key)
See the answers
The expected choices
Flow
Connection
Model
Garde-fou
1. Driving school
One-week trial with the AI supplied by Zapier, then its own key if the workflow stays (candidates’ dates of birth)
Economy
End of trial dated on the sheet
2. Haulier
Clean key in the model sub-node, contract accepted
Economy
Monthly cap and 50 response tokens at most
3. Engineering consultancy
HTTP Request node with the provider's credential
Intermediate
Dedicated key, cap, one run per report
The workflow 3 request in the n8n HTTP Request node (JSON body)JSON
{
"model": "[nom exact du modèle intermédiaire, recopié de la page des modèles]",
"max_tokens": 1500,
"system": "Tu rédiges la synthèse d'un rapport d'essai pour un bureau d'études. Deux pages au plus. N'ajoute aucune valeur absente du rapport.",
"messages": [
{ "role": "user", "content": "{{ $json.texte_du_rapport }}" }
]
}
The key isn’t in this body: it comes from the credential chosen under the node’s “Authentication”, which adds the header to every call.
Level 3 · demanding case30 min
Audit how an inherited workflow is connected
You are taking over the flow below, built by a contractor who has since left. List every problem with the key, the model and the cost, rank them from most to least urgent, and write the corrected sheet for the AI step (five fields).
The material to work on
EXTRAIT DE L'EXPORT DU WORKFLOW N8N « Réponses SAV » (négoce de matériel agricole, 30 salariés, Marmande)
Nœud 1 : Gmail Trigger, boîte sav@, vérification chaque minute.
Nœud 2 : Set, champs : cle_openai = "sk-...[clé du prestataire]" ; client = {{ $json.from }} ; message = {{ $json.text }} (message complet, avec l'historique des échanges et les signatures).
Nœud 3 : HTTP Request vers l'API d'OpenAI, en-tête Authorization = Bearer {{ $json.cle_openai }}, modèle : le plus capable de l'offre, aucune limite de jetons de réponse.
Nœud 4 : Gmail, Send, destinataire {{ $json.client }}, corps = la réponse de l'IA.
Notes du prestataire : « Facture OpenAI sur ma carte, je refacture tous les mois. Aucun plafond, ça coûte trois fois rien. »
Volume : 1 800 courriels par mois. Dernière facture refacturée : 96 $.
Check your work
The key in plain text in a Set node, in the contractor’s name, is ranked most urgent (revoke and replace)
Direct sending to the customer without review is flagged and brought down to amber
The most capable model and the lack of a token limit are linked to the $96 bill
Sending the full message with its history is flagged as unnecessary data
The corrected sheet names the key, the cap, the model and the owner
See the answers
Contractor’s key in plain text in the Set node and in every run: ask the contractor to revoke it the same day, create a key in the merchant’s name and store it in an n8n credential.
Direct sending to the customer: replace the Send node with draft creation, reviewed by the after-sales team (next lesson on drafting within a workflow).
Bill: most capable model, no limit, full message with history. Switch to the economy model for classifying, mid-range only for drafting, limit the response to 500 tokens, cut the history.
Billing on a third party’s card: open the API account in the merchant’s name and set a monthly cap.
Check every minute: enough, but add a filter that ignores automatic replies to avoid a loop.
The corrected AI step sheet
Box
Content
Trigger
An e-mail arrives at sav@, excluding auto-replies and messages sent by the merchant
Data
Sender, subject, latest message only; personal data: yes (customer’s name and address)
Decisions
The AI classifies (breakdown, part, warranty, other) then suggests a reply; “other” goes to a person
Actions
Credential “OpenAI SAV négoce”, economy model for classifying, mid-range for drafting, 500 tokens maximum; draft in Gmail
Inspection
Orange: review before sending; cap of $30 a month; error alert to the after-sales manager; owner: the after-sales manager
The HTTP Request node header, once correctedText
Authentication : Predefined Credential Type
Credential Type : OpenAI
OpenAI : « OpenAI SAV négoce » (identifiant chiffré, créé avec la clé du négoce)
# Plus aucun champ Authorization écrit à la main,
# plus aucune clé dans un nœud Set ni dans une expression.
All the course prompts to copy, both for the assistant that helps you build and for the AI step of a flow, including answers, practical examples and practice tasks, sorted by module and lesson, with filters to find the right one.
For each lesson, the main exercise and the three graded practice tasks with their materials, to do on paper or alongside your automation platform; all the answers are grouped at the end.
The course’s practical examples, job by job: the situation, the prompt as it was written, the model answer and what was checked before letting the flow run.
All the lessons in a single PDF: objectives, written course with its diagrams, tables and requests, common mistakes, exercise and key takeaways. The practice exercises and answers are in the workbook, the examples in the collection.
Your notes stay on this device; they are not sent anywhere.
A question for the tutor
A result that doesn’t match the model answer, a prompt that gets you nowhere, a case specific to your business: write to us with your prompt and the response you got. A Bonbay Académie trainer replies within 24 working hours, on your case.