The UC AI Google package provides integration with Googleâs Gemini models, allowing you to use Googleâs advanced language models within your Oracle database applications.
Features
Section titled âFeaturesâ- Support for latest Gemini models (Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 2.0 Flash, Gemini 1.5 series)
- Full function calling (tools) support
- Advanced reasoning capabilities with reasoning budget control
- Multi-modal support (text, images, PDFs)
Prerequisites
Section titled âPrerequisitesâ- Google AI API key
- Oracle database with internet access to Google AI API endpoints
- UC AI package installed
- Set up API key (guide)
You can get an API key by signing up at Google AI Studio.
Creating a Web Credential
Section titled âCreating a Web CredentialâTo use your Google key with APEX Web Credentials, create a new web credential in your APEX workspace (Workspace Utilities â Web Credentials) with the following settings:
- Authentication Type: URL Query String
- Credential Name:
key - Credential Secret:
<your_api_key>
We generally recommend also setting Valid for URLs to the Google API (https://generativelanguage.googleapis.com/) to limit the scope of the credential.
To use the web credential in your PL/SQL code, set the package variable uc_ai_google.g_apex_web_credential to the static ID of your web credential before calling any UC AI functions:
uc_ai_google.g_apex_web_credential := 'GOOGLE';Google offers the Gemini family of models with different capabilities and performance characteristics. The UC AI Google package provides constants for all current models:
Gemini 3 Series
Section titled âGemini 3 Seriesâuc_ai_google.c_model_gemini_3_pro- Most capable model for complex tasks
Gemini 2.5 Series
Section titled âGemini 2.5 SeriesâEnhanced second generation models:
uc_ai_google.c_model_gemini_2_5_pro- Most capable model for complex tasksuc_ai_google.c_model_gemini_2_5_flash- Fast and efficient for most tasksuc_ai_google.c_model_gemini_2_5_flash_lite- Lightweight version for simple tasks
Gemini 2.0 Series
Section titled âGemini 2.0 SeriesâSecond generation Gemini models:
uc_ai_google.c_model_gemini_2_0_flashuc_ai_google.c_model_gemini_2_0_flash_lite
Gemini 1.5 Series
Section titled âGemini 1.5 Seriesâuc_ai_google.c_model_gemini_1_5_prouc_ai_google.c_model_gemini_1_5_flashuc_ai_google.c_model_gemini_1_5_flash_8b
See Googleâs model documentation for detailed model information and Artificial Analysis for a comparison of intelligence, speed, and price.
Usage Examples
Section titled âUsage ExamplesâBasic Text Generation
Section titled âBasic Text Generationâdeclare l_result json_object_t;begin l_result := uc_ai.generate_text( p_user_prompt => 'What is Oracle APEX?', p_provider => uc_ai.c_provider_google, p_model => uc_ai_google.c_model_gemini_2_5_flash );
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));end;/With System Prompt
Section titled âWith System Promptâdeclare l_result json_object_t;begin l_result := uc_ai.generate_text( p_user_prompt => 'Write a SQL query to find all employees hired this year', p_system_prompt => 'You are a helpful SQL expert. Write clean, efficient queries.', p_provider => uc_ai.c_provider_google, p_model => uc_ai_google.c_model_gemini_2_5_pro );
dbms_output.put_line('SQL Query: ' || l_result.get_string('final_message'));end;/Using Tools/Function Calling
Section titled âUsing Tools/Function CallingâAll Gemini 2.5 models support tools/function calling. You can define tools in your application and Gemini will call them as needed.
See the tools guide for details on how to set up and use tools. Also see Googles best practices for function calling.
Multi-modal Analysis
Section titled âMulti-modal AnalysisâAll latest Gemini models have vision capabilities for Image and PDF Analysis.
Refer to the file analysis guide for examples on how to analyze images and PDFs.
Reasoning / Thinking
Section titled âReasoning / ThinkingâGoogleâs Gemini models support native reasoning capabilities. You can control the reasoning budget to balance thoroughness with speed and cost:
declare l_result json_object_t;begin uc_ai.g_enable_reasoning := true; uc_ai_google.g_reasoning_budget := 512; -- Number of thinking tokens
l_result := uc_ai.generate_text( p_user_prompt => 'Answer in one sentence. If there is a great filter, are we before or after it and why.', p_provider => uc_ai.c_provider_google, p_model => uc_ai_google.c_model_gemini_2_5_flash );
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));end;/The reasoning budget parameter controls how many thinking tokens the model uses:
-1- Dynamic budget (model decides)0- No reasoning budget- Positive number - Fixed token budget
Note that reasoning cannot be disabled with Gemini 2.5 Pro models as they always use some level of reasoning.
Refer to Googleâs thinking documentation for more details on reasoning capabilities.
Generating Embeddings
Section titled âGenerating EmbeddingsâGoogle provides the Gemini Embedding model for semantic search, clustering, and other vector-based operations:
uc_ai_google.c_model_gemini_embedding_001- Latest embedding model
Configuration Options
Section titled âConfiguration OptionsâGoogleâs embedding API supports additional configuration parameters:
- Task Type - Optimize embeddings for a specific task (default:
SEMANTIC_SIMILARITY) - Output Dimensions - Control the size of the embedding vectors (default:
1536)
See Googleâs embedding documentation for supported task types.
declare l_result json_array_t;begin -- Optional: Configure embedding parameters uc_ai_google.g_embedding_task_type := 'SEMANTIC_SIMILARITY'; -- or RETRIEVAL_QUERY, RETRIEVAL_DOCUMENT, etc. uc_ai_google.g_embedding_output_dimensions := 768; -- Reduce dimensions for smaller vectors
l_result := uc_ai.generate_embeddings( p_input => json_array_t('["Oracle APEX is a low-code development platform.", "UC AI allows you to easily use AI from PL/SQL."]'), p_provider => uc_ai.c_provider_google, p_model => uc_ai_google.c_model_gemini_embedding_001 );
-- l_result.get_size â 2 (one embedding per input string) -- l_result.get(0) â JSON array of embedding values for first inputend;/For more information about the generate_embeddings function, visit its documentation page.