7.9 Create an OCI Generative AI Credential and AI Profile

An AI credential stores authentication details used by the database to access the selected AI provider or related cloud resources. The AI credential comprises information such as user_ocid, tenancy_ocid, private_key and fingerprint. An AI Profile is information about a user and their attributes, such as provider, credential_name, and object_list.

Prerequisites
  • DBMS_CLOUD_AI package
  • user_ocid
  • tenancy_ocid
  • private_key
  • fingerprint
You can create and manage your AI profiles using the DBMS_CLOUD_AI package.
To create an OCI Generative AI credential and AI Profile:
  1. Create a notebook and in a %script paragraph, run the following command to create an AI credential:
    %script
    DECLARE
    	credential_name VARCHAR2(128) := 'OCI_CRED';
    BEGIN
    	BEGIN
    		dbms_cloud.drop_credential(credential_name => credential_name);
    	EXCEPTION
    		WHEN OTHERS THEN
    			NULL;
    	END;
    	dbms_cloud.create_credential(
    		credential_name => credential_name,
    		user_ocid       => '<ocid1.user.oc1..>',
    		tenancy_ocid    => '<ocid1.tenancy.oc1..>',
    		private_key     => '<private_key>',
    		fingerprint     => '<fingerprint>'
    	);
    END;
    /
    
    This PL/SQL script calls the DBMS_CLOUD.CREATE_CREDENTIAL procedure to create a new credential with the given parameters:
  2. In another %script paragraph in the same notebook, run the following command to create an AI profile by the name GROK_4_3_PROFILE.
    %script
    DECLARE
        profile_name VARCHAR2(128) := 'GROK_4_3_PROFILE';
    BEGIN
        dbms_cloud_ai.drop_profile(
            profile_name,
            TRUE
        );
        dbms_cloud_ai.create_profile(
            profile_name => profile_name,
            attributes   => '{
                "credential_name": "OCI_CRED",
                "model": "xai.grok-4.3",
                "provider": "oci",
                "temperature": 1,
                "max_tokens": 8192,
                "oci_compartment_id": "<ocid1.compartment.oc1..>"            
            }'
        );
    END;
    /
    Define the following attributes for this profile:
    • profile_name: A name for the AI profile. The profile name must follow the naming rules of Oracle SQL identifier. The maximum profile name length is 125 characters.
    • credential_name: This is the name of the credential used to authenticate requests to the selected AI provider.
    • model: The name of the AI model being used to generate responses in the conversation. In this example, it is xai.grok-4.3. For more information, see Recommended Models.
    • provider: This is the provider of the model. It is a mandatory field. Supported providers are:
      • openai
      • cohere
      • azure
      • database
      • oci
      • google
      • anthropic
      • huggingface
      • aws
    • max_tokens: Specify the maximum number of tokens (words and pieces of words) in the response. Prevents overly long outputs and manages cost.
    • oci_compartment_id: This is the OCID of the compartment you are permitted to access when calling the OCI Generative AI service. The compartment ID can contain alphanumeric characters, hyphens and dots.
  3. Check the status of the profile creation by running the following:
    %sql select * from
        user_cloud_ai_profiles;
This completes the task of creating an AI credential and AI Profile.

7.9.1 Recommended Models

Data Science Agent works with large language models accessed through Oracle DBMS_CLOUD_AI and DBMS_CLOUD_AI_AGENT packages. The DBMS_CLOUD_AI package, with Select AI, supports the translation of natural language prompts to generate, run, explain SQL statements, and also enables RAG and natural language-based interactions, including chats with LLMs. For more information, see DBMS_CLOUD_AI Package and DBMS_CLOUD_AI_AGENT Package.

This table lists the recommended large language models and the scenarios in which each should be used.

Note:

Recommended models may change as providers update model availability, latency, pricing, and quality. Check the current list of supported models for your AI provider before creating a profile.

Table 7-3 Recommended Models

Provider Tier Large Language Model
OpenAI or OCI GenAI Top gpt-5.5
OpenAI or OCI GenAI Cost-effective gpt-5.4-mini
OCI GenAI Top xai.grok-4.3

Note:

When using OCI Generative AI, use the provider and model identifiers exactly as documented for OCI GenAI. Some model identifiers may include the original model family or vendor name.
OCI GenAI Cost-effective xai.grok-4-1-fast-reasoning

Note:

When using OCI Generative AI, use the provider and model identifiers exactly as documented for OCI GenAI. Some model identifiers may include the original model family or vendor name.
Google Top gemini-3.5-flash
Google Cost-effective gemini-3-flash-preview
Anthropic Top claude-opus-4-8
Anthropic Cost-effective claude-sonnet-4-6
Explanation of tiers:
  • Top: Represents the best state-of-the-art model from a specific provider. This tier is the strongest option in terms of quality, reliability, and precision.
  • Cost-effective: Represents a good compromise between quality, cost, and speed. These models are typically faster and less expensive. But the trade-off is lower quality and reliability compared to the Top tier.

Profile Creation for GPT-5.5

To create an AI profile for GPT-5.5 through OpenAI, run the following script in a notebook:

DECLARE
    profile_name VARCHAR2(128) := 'OPENAI_GPT_5_5';
BEGIN
    dbms_cloud_ai.drop_profile(profile_name, TRUE);
    dbms_cloud_ai.create_profile(
        profile_name => profile_name,
        attributes => '{
            "credential_name": "OPENAI_CRED",
            "model": "gpt-5.5",
            "provider": "openai",
            "temperature": 1,
            "max_tokens": 8192
        }'
    );
END;
/

To create an AI profile for GPT 5.5 through Oracle Cloud Infrastructure (OCI), run the following script in a notebook:

DECLARE
    profile_name VARCHAR2(128) := 'OCI_GPT_5_5';
BEGIN
    dbms_cloud_ai.drop_profile(profile_name, TRUE);
    dbms_cloud_ai.create_profile(
        profile_name => profile_name,
        attributes => '{
            "credential_name": "OCI_CRED",
            "model": "openai.gpt-5.5",
            "provider": "oci",
            "temperature": 1,
            "max_tokens": 8192,
            "oci_compartment_id": "<your-dep-id>"
          }'
        );
    END;
/

Profile Creation for Grok 4.3

To create an AI profile for Grok 4.3 through Oracle Cloud Infrastructure (OCI), run the following script in a notebook:

DECLARE
    profile_name VARCHAR2(128) := 'OCI_GROK_4_3';
BEGIN
        dbms_cloud_ai.drop_profile(profile_name, TRUE);
        dbms_cloud_ai.create_profile(
            profile_name => profile_name,
            attributes => '{
                "credential_name": "OCI_CRED",
                "model": "xai.grok-4.3",
                "provider": "oci",
                "temperature": 1,
                "max_tokens": 8192,    
                "oci_compartment_id": "<your-dep-id>"
               }'
            );
    END;
/
Parameters:
  • profile_name: Name of the AI profile. It must follow Oracle SQL identifier naming rules.
  • credential_name: Name of the credential used to authenticate with the selected AI provider.
  • model: Model identifier used by the selected provider.
  • provider: AI provider for the profile, for example openai, oci, google, or anthropic.
  • temperature: Recommended value for Data Science Agent examples: 1.
  • max_tokens: Recommended value for these examples: 8192.

    Note:

    Data Science Agent profile inspection treats values below 4096 as not recommended.
  • oci_compartment_id: Required for the OCI GenAI examples. Use the target compartment OCID or documented deployment/compartment identifier.

For more information, see Manage AI Profiles.