Implementing Oracle APEX AI Assistant Using OCI Generative AI - Step-by-Step Guide
Introduction
Oracle APEX provides built-in integration with Generative AI services such as OCI Generative AI, OpenAI, and Cohere. By configuring the OCI Generative AI service, developers can use the APEX AI Assistant to generate SQL queries, PL/SQL code, and application logic directly inside the development environment.
In this article, we will configure OCI Generative AI in Oracle APEX and use the AI Assistant to generate SQL and PL/SQL code.
The implementation includes:
-
Configuring OCI API Keys
-
Creating Web Credentials
-
Configuring OCI Generative AI Service
-
Testing the AI connection
-
Using APEX AI Assistant
-
Generating SQL / PL SQL using natural language
Prerequisites
Before starting, ensure the following requirements are completed.
| Requirement | Description |
|---|---|
| OCI Account | Oracle Cloud Infrastructure account |
| Oracle APEX | APEX workspace created |
| OCI Generative AI | Service enabled |
| OCI API Key | Required for authentication |
Step by Step Approaches
Step 1 - Generate OCI API Keys
Start directly with OCI API Key creation because it is required for authentication.
Explain:
-
Login to OCI Console
-
Navigate to Profile → API Keys
-
Click Add API Key
-
Select Generate API Key Pair
-
Download Private Key
-
Copy:
-
User OCID
-
Tenancy OCID
-
Fingerprint
-
Region
Step 3 - Configure OCI Generative AI Service
Navigation:
Workspace Utilities
→ Generative AI
→ Create
Enter:
-
AI Provider → OCI Generative AI Service
-
Compartment ID
-
Region
-
Model ID
-
Base URL
-
Credential
Then Test Connection. If successful, click 'Create'.
Step 4 - Creating a Custom Data Model Using AI
Step 5 - Creating an App from a Prompt
After Created Application.
Step 6 - APEX Assistant in Code Editors
APEX AI Assistant is also available in the PL/SQL Code Editor.
Open:
Page Designer
→ Process
→ PL/SQL Code Editor
Click
APEX Assistant
Example prompt:
Insert sample employee record
Generated code:
declare
v_employee_id number := 1;
v_first_name varchar2(50) := 'John';
v_last_name varchar2(50) := 'Doe';
v_email varchar2(100) := 'john.doe@example.com';
v_hire_date date := sysdate;
v_salary number := 60000;
begin
insert into employees (
employee_id,
first_name,
last_name,
email,
joining_date
)
values (
v_employee_id,
v_first_name,
v_last_name,
v_email,
v_hire_date
);
commit;
exception
when others then
dbms_output.put_line('Error: ' || sqlcode || ' - ' || sqlerrm);
rollback;
end;
This helps developers generate code quickly.
Step 7 - Show AI Assistant Dynamic Action
Step 8 - Generate Text with AI
- Configuration → AI Service. Service → OCI Gen AI.
- Input Value Type → Item. Use Response Type → Item.
Step 9 - Create and Use AI Configurations
Step 10 - AI Features Available in Oracle APEX
Once configured, AI can be used in multiple areas.
| Feature | Description |
|---|---|
| AI Assistant | Chat-based coding assistant |
| Text to SQL | Convert natural language to SQL |
| Code Generation | Generate PL/SQL, JS, HTML |
| Code Explanation | Explain existing code |
| Code Improvement | Optimize code automatically |
These capabilities significantly increase developer productivity.
Conclusion
Oracle APEX integrates seamlessly with OCI Generative AI, enabling developers to build smarter applications and generate code using natural language prompts.
By configuring:
-
OCI API Keys
-
Web Credentials
-
Generative AI Service
you can activate APEX AI Assistant and leverage AI directly inside the development environment.
This makes Oracle APEX a powerful platform for AI-assisted low-code development.
.png)
.png)
Comments
Post a Comment