Skip to content

OCI

The UC AI OCI package provides integration with Oracle Cloud Infrastructure’s Generative AI models, allowing you to use state-of-the-art language models within your Oracle database applications.

  • Support for Cohere, Meta Llama, xAI Grok models, and Google Gemini models
  • Features vary by model
  1. Create OCI API Key and APEX Web Credential (see guide)
  2. Oracle database with internet access to OCI’s API endpoints
  3. UC AI package installed

Note that OCI uses a complex credential-based authentication system with a private key and three other components rather than a simple API key. Unfortunately Oracle does not provide a PL/SQL SDK to do the cryptographic operations, so the UC AI package builds on Oracle APEX Web Credentials which can do the work.

If you have a way to do the cryptographic operations in PL/SQL, please contact me or open a pull request to improve allow this to work without having to use APEX. Also if you know a way to get Auth tokens (simple API keys) to work with the AI APIs, please let me know.

Which models are available to you is highly dependent on the region where your OCI tenant is located.

Currently Oracle provides Cohere, Meta Llama, xAI Grok models, and Google Gemini models.

Refer to this list of available models for more information. Click on a model to see where it is available.

  • uc_ai_oci.c_model_llama_4_scout
  • uc_ai_oci.c_model_llama_4_maverick
  • uc_ai_oci.c_model_llama_3_3_70b
  • uc_ai_oci.c_model_cohere_command_a_03_2025
  • uc_ai_oci.c_model_grok_4
  • uc_ai_oci.c_model_grok_3
  • uc_ai_oci.c_model_grok_3_mini
  • uc_ai_oci.c_model_grok_3_fast
  • uc_ai_oci.c_model_grok_3_mini_fast

Coming soon…

declare
l_result json_object_t;
begin
uc_ai_oci.g_compartment_id := 'your_compartment_id_here';
uc_ai_oci.g_region := 'eu-frankfurt-1';
uc_ai_oci.g_apex_web_credential := 'NAME_OF_YOUR_APEX_WEB_CREDENTIAL';
-- optional
uc_ai_oci.g_serving_type := 'ON_DEMAND'; -- ON_DEMAND or DEDICATED, default is ON_DEMAND
l_result := uc_ai.generate_text(
p_user_prompt => 'What is Oracle APEX?',
p_provider => uc_ai.c_provider_oci,
p_model => uc_ai_oci.c_model_cohere_command_a_03_2025
);
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));
end;
/
declare
l_result json_object_t;
begin
uc_ai_oci.g_compartment_id := 'your_compartment_id_here';
uc_ai_oci.g_region := 'eu-frankfurt-1';
uc_ai_oci.g_apex_web_credential := 'NAME_OF_YOUR_APEX_WEB_CREDENTIAL';
-- optional
uc_ai_oci.g_serving_type := 'ON_DEMAND'; -- ON_DEMAND or DEDICATED, default is ON_DEMAND
l_result := uc_ai.generate_text(
p_user_prompt => 'I have tomatoes, salad, potatoes, olives, and cheese. What can I cook with that?',
p_system_prompt => 'You are an assistant helping users to get recipes. Please just list 3 possible dish names without instructions.',
p_provider => uc_ai.c_provider_oci,
p_model => uc_ai_oci.c_model_cohere_command_a_03_2025
);
dbms_output.put_line('Recipe suggestions: ' || l_result.get_string('final_message'));
end;
/

Tools / function calling is supported. Refer to the model documentation page to see which models support it.

OCI provides Cohere embedding models for semantic search, clustering, and other vector-based operations:

  • uc_ai_oci.c_model_cohere_embed_4 - Latest Cohere v4 embedding model
  • uc_ai_oci.c_model_cohere_embed_english_3 - English-optimized v3 model
  • uc_ai_oci.c_model_cohere_embed_english_light_3 - Lightweight English model
  • uc_ai_oci.c_model_cohere_embed_multi_3 - Multilingual v3 model
  • uc_ai_oci.c_model_cohere_embed_multi_light_3 - Lightweight multilingual model

Image-capable embedding models are also available:

  • uc_ai_oci.c_model_cohere_embed_english_image_3
  • uc_ai_oci.c_model_cohere_embed_english_light_image_3
  • uc_ai_oci.c_model_cohere_embed_multi_image_light_3

Also refer to the OCI documentation for any new models that might not be listed here and region availability.

declare
l_result json_array_t;
begin
uc_ai_oci.g_compartment_id := 'your_compartment_id_here';
uc_ai_oci.g_region := 'eu-frankfurt-1';
uc_ai_oci.g_apex_web_credential := 'NAME_OF_YOUR_APEX_WEB_CREDENTIAL';
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_oci,
p_model => uc_ai_oci.c_model_cohere_embed_english_3
);
-- 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.