Skip to content

Google

The UC AI Google package integrates Google’s Gemini models into your Oracle database applications.

  • Support for the current Gemini models (Gemini 3.x Flash and Flash-Lite, Gemini 3.1 Pro, Gemini 2.5 series)
  • Full function calling (tools) support
  • Reasoning capabilities with reasoning budget control
  • Multi-modal support (text, images, PDFs)
  1. Google AI API key
  2. Oracle database with internet access to Google AI API endpoints (see Network Setup (ACL & Wallet))
  3. UC AI package installed
  4. Set up API key (guide)

You can get an API key by signing up at Google AI Studio.

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 configuration:

  • Authentication Type: URL Query String
  • Credential Name: key
  • Credential Secret: <your_api_key>

Also set 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 the current models:

  • uc_ai_google.c_model_gemini_3_8_flash - Latest Flash model, fast and good for most tasks
  • uc_ai_google.c_model_gemini_3_5_flash_lite - Lightweight model for simple tasks
  • uc_ai_google.c_model_gemini_3_1_pro - Most capable model for complex tasks

This list shows the newest model of each family. The package keeps the constants of older models for code that still references them.

Google shut down the Gemini 2.0 models, the Gemini 1.5 models, and the gemini-3-pro-preview model. The package keeps their constants for code that still references them, but requests with these models fail.

See Google’s model documentation for detailed model information and Artificial Analysis for a comparison of intelligence, speed, and price.

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_3_7_flash
);
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));
end;
/
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_3_1_pro
);
dbms_output.put_line('SQL Query: ' || l_result.get_string('final_message'));
end;
/

All current Gemini 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.

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.

Google’s Gemini models reason natively. 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_3_7_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

You cannot disable reasoning for the Pro models. They always use some level of reasoning.

Refer to Google’s thinking documentation for more details on reasoning capabilities.

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

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 input
end;
/

For more information about the generate_embeddings function, visit its documentation page.