top of page

Building AI-Powered Oracle APEX Apps with Ollama and AWS Bedrock

  • Nick
  • 6 days ago
  • 5 min read

The APEX team has recently introduced a range of new AI features that are built directly into the Oracle APEX low-code app builder. These features can be used to assist during application building, helping developers work faster and more efficiently, or they can be embedded into applications themselves using the new AI capabilities. Together, they make it easier for Oracle APEX developers to take advantage of modern generative AI while keeping development simple and streamlined.


Whilst these built-in AI integrations are powerful and will suit a wide range of use cases, they typically require an API key for services such as OpenAI, OCI Generative AI, or Cohere. Oracle Cloud Infrastructure (OCI) stands out here as a strong and highly competitive platform, offering enterprise-grade performance, compelling pricing, and deep alignment with Oracle APEX and the wider Oracle ecosystem.


However, in some scenarios, relying on a managed AI service and an external API key may still present challenges. These can include ongoing service costs at scale, data sovereignty or privacy requirements, and limited flexibility when it comes to fine-tuning or selecting specific models. In addition, choosing a single AI provider can constrain the range of models and deployment patterns available to you.


With these considerations in mind, a natural question arises: what if you want the flexibility and control of running large language models outside of managed AI services, while still taking full advantage of Oracle APEX’s built-in AI capabilities? Whether driven by cost optimisation, data residency requirements, or the need for greater freedom in model selection and deployment, there are practical ways to achieve this. This blog explores how Oracle APEX can be extended to work with externally hosted and privately managed AI models, demonstrating techniques that make it possible to combine modern generative AI with a self-directed infrastructure strategy. These have not been tested in a production environment however should be a good demonstration of how extensible and versatile the AI capability is.


Ollama

Ollama is a lightweight runtime that makes it easy to download and run large language models (LLMs) locally or on your own infrastructure. It supports many popular open-source models (such as Llama, Mistral, and Gemma) and exposes a simple HTTP API that is compatible with common ChatGPT-style request/response patterns. This makes it a direct plug and play with Oracle APEX, all you need to do is configure a ‘Generative AI Service’ with the endpoint of your Ollama server making it cleanly integrate with Oracle APEX.


Running 'ollama ls' allows you to view the models you have downloaded to your system.
Running 'ollama ls' allows you to view the models you have downloaded to your system.

On my laptop, I have the gemma3:1b model downloaded. This is a capable model that runs very quickly on my laptop and due to it being only 1 billion parameters, it is very small and doesn’t require much RAM to run. You can validate if the model is downloaded and working correctly with the ‘ollama run’ command. 


The 'ollama run' command allows you to test the model in your terminal to ensure it performs well.
The 'ollama run' command allows you to test the model in your terminal to ensure it performs well.

There are hundreds of downloadable models available and easily installable on Ollama, the full list is available here: https://ollama.com/search. Please note that the speed and quality of model responses is heavily dependent on your hardware.



I have a local Oracle APEX installation running inside a docker container, to let it access the Ollama service that is running on the host, I used ‘http://host.docker.internal:11434/v1. This is a special endpoint that allows docker containers to send requests to the host network.


The credential supplied can be whatever you want, Ollama does not provide any client authentication it simply serves requests and ignores the supplied credential, this means that you should never publicly expose an Ollama server to the internet without adequate protection.


You will also need to configure a host ace, I did this with the following PL/SQL. Without configuring the host ace, APEX will not be able to make requests to the endpoint.


Ollama runs on port 11434 and the APEX_VERSION schema requires access in order to make requests, otherwise you will get an error.
Ollama runs on port 11434 and the APEX_VERSION schema requires access in order to make requests, otherwise you will get an error.

Once you have configured this, you will be able to use the AI features in Oracle APEX builder and start embedding them in your application. Using this technique, you get full choice over the model and are in full control of the data passed to it. Larger models may require a powerful computer and GPU whilst some of the smaller ones are capable of running on a Raspberry Pi, you can experiment with the ‘ollama run’ command to find a model that works well on your hardware.


AWS Bedrock

AWS Bedrock is a fully managed service that makes it easy to build and scale generative AI applications using foundation models (FMs) from leading providers through a single API. It supports popular models from Amazon and third parties (such as Claude, Llama, and Mistral) while handling infrastructure, security, and scaling for you.


Firstly, we need to configure the Bedrock Access Gateway, this acts as a middleman for AWS Bedrock and APEX. It is an official AWS tool that exposes a ChatGPT like endpoint and forwards them to Bedrock using the native AWS API, similar to Ollama this means it can connect directly with Oracle APEX.


  1. Firstly clone the Bedrock Access Gateway repository, it is available here: https://github.com/aws-samples/bedrock-access-gateway

  2. Change directory to /src/

  3. Build the Dockerfile_ecs into an image: docker build . -f Dockerfile_ecs -t bedrock-gateway

  4. Run the following command, adding your AWS credentials, desired region. You will also need to generate a secure API_KEY, this will be used as the credential in the APEX Builder so ensure you take note of it. 

  5. Create a host ACE to allow APEX to make requests to the Bedrock Access Gateway

  6. Configure the AWS Builder, similar to Ollama except this time your credential must be whatever you set the API_KEY variable to in the above command.


Closing Thoughts

Oracle APEX’s built-in AI capabilities significantly lower the barrier to adopting generative AI within low-code applications. While managed services such as OCI Generative AI and OpenAI are an excellent fit for many production use cases, they are not always viable due to cost, policy, or data residency constraints.


By integrating APEX with self-hosted platforms like Ollama or intermediary services such as the AWS Bedrock Access Gateway, developers gain greater control over model selection, data flow, and deployment architecture. This approach is particularly valuable for development and non-production environments, where lightweight models can deliver meaningful AI functionality at minimal cost, perfect for testing with.


Most importantly, this highlights the flexibility of Oracle APEX’s AI architecture. Developers are not locked into a single AI provider and can select the most appropriate strategy for each environment, allowing models to be changed or replaced with minimal effort. This enables rapid experimentation, supports compliance and cost optimisation requirements, and ensures teams can evolve their AI approach without sacrificing innovation.

 
 
bottom of page