Gemini , Mistral free AI Editoral in Apex 26.1
Trying the New APEX 26.1 AI Providers, for Free, with Gemini and Mistral
One of the features I was itching to try in APEX 26.1 was the expanded Generative AI Service support. Earlier versions only gave us OpenAI, Cohere, and OCI, but 26.1 opened the door to a whole new set of providers. I wanted to see how little effort it really takes, and I wanted to do it without spending a rupee. So I picked the two providers that have genuine free tiers, Google Gemini and Mistral AI, and wired both into the same little app. Here is exactly how it went.
What I set out to build
I kept the goal deliberately small, because the point was to test the integration, not to build a product. One page with a box to type a question, a button, and an area that fills in with the answer from the model. That is enough to prove the round trip works, and once it does, everything bigger is just variations on the same idea.
The part I was most curious about was whether switching from one provider to another would really be as painless as the release notes claimed. Spoiler: it is a one word change, and seeing that work was the best moment of the afternoon.
Both Gemini and Mistral let you create an API key and start calling models without entering a credit card. Gemini gives you a permanent free tier through Google AI Studio (the free tier covers the Flash models). Mistral gives you a free Experiment plan that only needs a verified phone number. That makes them perfect for following along, learning, and recording a demo. Anthropic Claude, by contrast, has no permanent free tier, so I left it out of this hands-on and stuck to what costs nothing.
Step 1: Grab the free API keys
Before opening APEX, I collected one key from each provider.
Gemini key
- Go to Google AI Studio and sign in with a Google account.
- Click Create API key. No card required.
- Copy the key. It comes with a project name and number attached, which is normal.
Mistral key
- Go to console.mistral.ai and sign up for the free Experiment plan.
- Verify your phone number when asked.
- Open the API Keys section, create a key, and copy it.
Treat these keys like passwords. Do not paste them into screenshots or share them in a blog. If one ever leaks, delete it from the provider console and generate a fresh one. APEX will store the key as a secure Web Credential anyway, so it never ends up in your page or in the browser.
Step 2: Create the Gemini service
This lives in App Builder under Workspace Utilities, then Generative AI, then Create. Pick the provider and the form adjusts to show the fields that provider needs. For Gemini I entered the following.
| Field | Value |
|---|---|
| AI Provider | Google Gemini |
| Name | Gemini Chat Service |
| Base URL | https://generativelanguage.googleapis.com/v1beta |
| Credential / API Key | Paste the AI Studio key. Gemini sends it as a URL parameter and APEX handles that for you. |
| AI Model | gemini-2.5-flash |
| Static ID | GEMINI_SVC |
| HTTP Headers | Leave blank |
I used a Flash model on purpose, because the Gemini free tier no longer includes the Pro models. Flash is more than capable for this kind of demo. I clicked Test Connection, waited for Connection Succeeded!, then clicked Create.
Step 3: Create the Mistral service
Exactly the same screen, just a different provider. Mistral uses an OpenAI style API with simple token authentication, so there is nothing special to configure.
| Field | Value |
|---|---|
| AI Provider | Mistral AI |
| Name | Mistral Chat Service |
| Base URL | https://api.mistral.ai/v1 |
| Credential / API Key | Paste the Mistral key. APEX sends it as a Bearer token automatically. |
| AI Model | mistral-small-latest |
| Static ID | MISTRAL_SVC |
| HTTP Headers | Leave blank |
The free Experiment plan actually gives access to all models, so mistral-large-latest works too. I went with the small model because it is fast and the quality is plenty for a Q&A page. Test Connection, then Create.
Side by side, the two services barely differ.
| Setting | Google Gemini | Mistral AI |
|---|---|---|
| Base URL | generativelanguage.googleapis.com/v1beta | api.mistral.ai/v1 |
| Model used | gemini-2.5-flash | mistral-small-latest |
| Key handling | URL parameter (APEX injects it) | Bearer token (APEX injects it) |
| Extra header | none | none |
| Free key from | Google AI Studio | console.mistral.ai |
Step 4: Build the page
I created a new Blank Page named Ask the AI, then added one region and three things inside it.
- A Textarea item named
P1_PROMPTfor the question. - A Display Only item named
P1_ANSWERfor the reply, with Save Session State turned off. - A Button named
ASKwith its Action set to Submit Page.
That is the entire screen. Nothing clever, just enough to see the conversation happen.
Step 5: Wire it to the model
On the Processing tab I created a process of type Execute Code, set it to run when the ASK button is pressed, and dropped in this block. It calls Gemini by its static ID and writes the answer into the display item.
DECLARE
l_messages apex_ai.t_chat_messages;
l_answer clob;
BEGIN
l_answer := apex_ai.chat(
p_prompt => :P1_PROMPT,
p_system_prompt => 'You are a helpful assistant inside an Oracle APEX app. Answer clearly and keep it brief.',
p_service_static_id => 'GEMINI_SVC',
p_messages => l_messages );
:P1_ANSWER := l_answer;
END;
A quick note on APEX_AI.CHAT for anyone new to it. The p_system_prompt sets the ground rules for the model. The p_service_static_id is the static ID you typed when creating the service, and if you leave it out APEX falls back to the application default service. The p_messages collection is how you carry context across turns if you later want a real conversation. Save, run the page, type a question, and the answer lands in the box.
Step 6: The moment that sold me
Here is the bit I really wanted to test. To run the same page on Mistral instead of Gemini, I changed exactly one line.
p_service_static_id => 'MISTRAL_SVC',
That was the whole change. No new payload code, no reshaping the request for a different provider, no fiddling with how the response comes back. APEX normalizes all of that behind the scenes, so my page logic stayed identical while the model answering the question switched completely. If you set one of the services as the application default, you can even leave the static ID out entirely and swap providers from the application AI settings without touching the page at all.
The no code path, in case you prefer it
If you would rather not write PL/SQL, APEX has a fully declarative option too. On a button, add a Dynamic Action with the action Show AI Assistant, point it at your Gemini or Mistral service, and give it a system prompt. That opens a ready made chat dialog with zero code. You set the service and a consent message once on the application level AI page, and the consent prompt shows to the user the first time they open the assistant. I like having both options, the dialog for a quick chat and the API when I want the answer inside my own logic.
What I learned along the way
- Test Connection saves time. Almost every early failure I had was a base URL typo, and the test caught it before I wasted time debugging the page.
- The static ID is the glue. It has to match in the service and in your PL/SQL exactly. A mismatch there was the cause of my one blank answer.
- Free tiers have limits. Both providers rate limit the free plans, which is fine for learning and demos but worth knowing if you script a lot of calls in a row. Check the current limits in the provider console before a big demo.
- Model names change, the setup does not. When a newer Gemini or Mistral model ships, you swap the AI Model field and carry on. Nothing else in the app cares.
Wrapping up
What stayed with me is how little there is to it. Two service definitions, a static ID each, and one API call, and my APEX app was talking to two different families of models, both on free keys. The provider abstraction is the real win here. You are not locking your app to one vendor, you are choosing per task and switching whenever it makes sense, and you can prove the whole thing without spending anything.
If you try this with a different model or build something bigger on top of it, I would love to hear how it goes. This was a genuinely fun afternoon, and that is rare praise for anything involving AI plumbing.
Comments
Post a Comment