Manage AI Profiles
You can create and manage your AI profiles through
            DBMS_CLOUD_AI package.
               
- Use DBMS_CLOUD_AI to Configure AI Profiles
 Autonomous AI Database uses AI profiles to facilitate and configure access to an LLM and to setup for generating, running, and explaining SQL based on natural language prompts. It also facilitates retrieval augmented generation using embedding models and vector indexes and allows for chatting with the LLM.
- Perform Prerequisites for Select AI
 Before you use Select AI, here are the steps to enableDBMS_CLOUD_AI.
- Create and Set an AI Profile
 Describes the steps to create and enable an AI profile.
Use DBMS_CLOUD_AI to Configure AI Profiles
Autonomous AI Database uses AI profiles to facilitate and configure access to an LLM and to setup for generating, running, and explaining SQL based on natural language prompts. It also facilitates retrieval augmented generation using embedding models and vector indexes and allows for chatting with the LLM.
AI profiles include database objects that are the target for natural
                        language queries. Metadata used from these targets can include database
                        table names, column names, column data types, and comments. You create and
                        configure AI profiles using the DBMS_CLOUD_AI.CREATE_PROFILE
                        and DBMS_CLOUD_AI.SET_PROFILE
                        procedures.
                  
In addition to specifying tables and views in the AI profile, you can also specify tables mapped with external tables, including those described in Query External Data with Data Catalog. This enables you to query data not just inside the database, but also data stored in a data lake's object store.
Parent topic: Manage AI Profiles
Perform Prerequisites for Select AI
Before you use Select AI, here are the steps to
                enable DBMS_CLOUD_AI.
                  
The
                                following are required to use DBMS_CLOUD_AI:
                     
- Access to an Oracle Cloud Infrastructure cloud account and to an Autonomous AI Database instance.
- A paid API account of a supported AI provider, one
                                        of: 
                           AI Provider API Keys OpenAI See Use OpenAI to get your API keys. OpenAI-compatible providers See Use OpenAI-Compatible Providers to get your API keys and provider_endpoint.Cohere See Use Cohere to get your secret API keys. Azure OpenAI Service See Use Azure OpenAI Service for more information on how to configure Azure OpenAI Service. OCI Generative AI Google See Use Google to get your API keys. Anthropic See Use Anthropic to get your API keys. Hugging Face See Use Hugging Face to get your API keys. AWS See Use AWS to get your API keys and model ID. 
- Network
                                        ACL privileges to access your external AI provider. 
                           Note
 Network ACL privileges are not required for OCI Generative AI.
- A credential that provides access to the AI provider.
- Grant Privileges for Select AI
 To use Select AI, the administrator must grant theEXECUTEprivilege on theDBMS_CLOUD_AIpackage. Learn about additional privileges required for Select AI and its features.
- Examples of Privileges to Run Select AI
 Review examples of privileges required to use Select AI and its features.
- Configure Select AI to Use Supported AI Providers
 Explore how to enable your AI providers to use with Select AI.
Parent topic: Manage AI Profiles
Grant Privileges for Select AI
To use Select AI, the administrator must grant the
            EXECUTE privilege on the  DBMS_CLOUD_AI package. Learn
        about additional privileges required for Select AI and its features.
                     
DBMS_CLOUD_AI:
                           - 
Grant the EXECUTEprivilege on theDBMS_CLOUD_AIpackage to the user who wants to use Select AI.By default, only the system administrator has EXECUTEprivilege. The administrator can grantEXECUTEprivilege to other users.
- 
Grant EXECUTEprivilege onDBMS_CLOUD_PIPELINEto the user who wants to use Select AI with RAG.Note
 If the user already has theDWROLErole, this privilege is included and additional grant is not required.
- 
Grant network ACL access to the user who wants to use Select AI and for the AI provider endpoint. The system administrator can grant network ACL access. See APPEND_HOST_ACE Procedure for more information. 
- Create a credential to enable access to your AI provider. 
                                 See CREATE_CREDENTIAL Procedure for more information. 
- 
Grant quotas in tablespace to manage the amount of space in a specific tablespace to the user who wants to use Select AI with RAG. 
Parent topic: Perform Prerequisites for Select AI
Examples of Privileges to Run Select AI
Review examples of privileges required to use Select AI and its features.
EXECUTE privilege to
                    ADB_USER:GRANT execute on DBMS_CLOUD_AI to ADB_USER;The following example grants EXECUTE privilege for the
                    DBMS_CLOUD_PIPELINE package required for
                RAG:
                        
GRANT EXECUTE on DBMS_CLOUD_PIPELINE to ADB_USER;To check the privileges granted to a user for the
                    DBMS_CLOUD_AI and DBMS_CLOUD_PIPELINE
                packages, an administrator can run the following:
                        
SELECT table_name AS package_name, privilege 
 FROM DBA_TAB_PRIVS 
 WHERE grantee = '<username>'
 AND   (table_name = 'DBMS_CLOUD_PIPELINE'
        OR table_name = 'DBMS_CLOUD_AI');ADB_USER the privilege to
                use the api.openai.com endpoint. 
                           This procedure is not applicable to OCI Generative AI.
BEGIN  
    DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
         host => 'api.openai.com',
         ace  => xs$ace_type(privilege_list => xs$name_list('http'),
                             principal_name => 'ADB_USER',
                             principal_type => xs_acl.ptype_db)
   );
END;
/
The parameters are:
- 
host: The host, which can be the name or the IP address of the host. You can use a wildcard to specify a domain or an IP subnet. The host or domain name is not case sensitive.AI Provider Host OpenAI api.openai.com OpenAI-compatible providers For example, for Fireworks AI, use api.fireworks.ai Cohere api.cohere.ai Azure OpenAI Service <azure_resource_name>.openai.azure.com See Profile Attributes to know more about azure_resource_name.Google generativelanguage.googleapis.com Anthropic api.anthropic.com Hugging Face api-inference.huggingface.co AWS bedrock-runtime.us-east-1.amazonaws.com 
- 
ace: The access control entries (ACE). TheXS$ACE_TYPEtype is provided to construct each ACE entry for the ACL. For more details, see Creating ACLs and ACEs.
The following example creates a credential to enable access to OpenAI.
EXEC 
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name   => 'OPENAI_CRED', 
username          =>  'OPENAI', 
password          =>  '<your_api_token>');The parameters are:
- 
credential_name: The name of the credential to be stored. Thecredential_nameparameter must conform to Oracle object naming conventions.
- 
username: Theusernameandpasswordarguments together specify your AI provider credentials.The usernameis a user-specified user name.
- 
password: Theusernameandpasswordarguments together specify your AI provider credentials.The passwordis your AI provider secret API key, and depends on the provider:AI Provider API Keys OpenAI See Use OpenAI to get your API keys. OpenAI-compatible providers See Use OpenAI-Compatible Providers to get your API keys and provider_endpoint.Cohere See Use Cohere to get your API keys. Azure OpenAI Service See Use Azure OpenAI Service to get your API keys and to configure the service. Note
 If you are using the Azure OpenAI Service principal to authenticate, you can skip theDBMS_CLOUD.CREATE_CREDENTIALprocedure. See Examples of Using Select AI for an example of authenticating using Azure OpenAI Service principal.OCI Generative AI See Use OCI Generative AI to generate API signing keys. Google See Use Google to generate your API keys. Anthropic See Use Anthropic to generate your API keys. Hugging Face See Use Hugging Face to generate your API keys. AWS See Use AWS to get your API keys and model ID. 
The following example grants quotas on tablespace to the
                    ADB_USER to use Select AI with RAG:
                        
ALTER USER ADB_USER QUOTA 1T ON <tablespace_name>;To the check the tablespace quota granted to a user, run the following:
SELECT TABLESPACE_NAME, BYTES, MAX_BYTES 
FROM DBA_TS_QUOTAS 
WHERE USERNAME = '<username>' AND
      TABLESPACE_NAME LIKE 'DATA%';The parameters are:
- TABLESPACE_NAME: The tablespace for which the quota is assigned. In Autonomous AI Database, tablespaces are managed automatically and have- DATAas a prefix.
- BYTES: The amount of space currently used by the user in the tablespace.
- MAX_BYTES: The maximum quota assigned (in bytes). If- MAX_BYTESis -1, it means the user has unlimited quota on the tablespace. The database user creating the vector index must have- MAX_BYTESsufficiently larger than bytes to accommodate the vector index, or- MAX_BYTESshould be -1 for unlimited quota.
Parent topic: Perform Prerequisites for Select AI
Configure Select AI to Use Supported AI Providers
Explore how to enable your AI providers to use with Select AI.
- Use Anthropic
 To enable Anthropic Developer Console to generate SQL and text responses to your natural language prompts, obtain API keys from your Anthropic Developer Console paid account.
- Use AWS
 To enable AWS, obtain your API key and model ID.
- Use Azure OpenAI Service
 To enable Azure OpenAI Service to generate SQL and text responses to your natural language prompts, configure and provide access to the AI provider.
- Use Cohere
 To enable Cohere to generate SQL and text responses to your natural language prompts, obtain API keys from your Cohere paid account.
- Use Google
 To enable Google AI Studio to generate SQL and text responses to your natural language prompts, obtain API keys from your Google AI Studio paid account.
- Use Hugging Face
 To enable Hugging Face as your AI provider to generate SQL and text responses to your natural language prompts, obtain API keys from your Hugging Face paid account.
- Use OCI Generative AI
 To enable OCI Generative AI to generate SQL and text responses to your natural language prompts, generate an API signing key.
- Use OpenAI
 To enable OpenAI to generate SQL and text responses to your natural language prompts, obtain API keys from your OpenAI paid account.
- Use OpenAI-Compatible Providers
 To enable providers that are compatible with OpenAI, obtain your API key.
Parent topic: Perform Prerequisites for Select AI
Use Anthropic
To enable Anthropic Developer Console to generate SQL and text responses to your natural language prompts, obtain API keys from your Anthropic Developer Console paid account.
Parent topic: Configure Select AI to Use Supported AI Providers
Use AWS
To enable AWS, obtain your API key and model ID.
Obtain your API key and use it to create credentials through DBMS_CLOUD.CREATE_CREDENTIAL. 
                           
Follow this process to obtain your API key and model name:
Parent topic: Configure Select AI to Use Supported AI Providers
Use Azure OpenAI Service
To enable Azure OpenAI Service to generate SQL and text responses to your natural language prompts, configure and provide access to the AI provider.
Parent topic: Configure Select AI to Use Supported AI Providers
Use Cohere
To enable Cohere to generate SQL and text responses to your natural language prompts, obtain API keys from your Cohere paid account.
- 
Login to Cohere's website with your credentials. Cohere Dashboard appears by default. 
- 
Alternately,click Dashboard. 
- 
Click API Keys on the left navigation. Copy the default API key or create another key. See API-Keys for more information. 
Parent topic: Configure Select AI to Use Supported AI Providers
Use Google
To enable Google AI Studio to generate SQL and text responses to your natural language prompts, obtain API keys from your Google AI Studio paid account.
Parent topic: Configure Select AI to Use Supported AI Providers
Use Hugging Face
To enable Hugging Face as your AI provider to generate SQL and text responses to your natural language prompts, obtain API keys from your Hugging Face paid account.
- Go to Hugging Face.
- Sign up for an account if you don't have one already.
- Navigate to your account settings.
- In the navigation menu locate the Access Tokens.
- Click to create a new API key.
- Copy the generated API key and save it.
Parent topic: Configure Select AI to Use Supported AI Providers
Use OCI Generative AI
To enable OCI Generative AI to generate SQL and text responses to your natural language prompts, generate an API signing key.
Parent topic: Configure Select AI to Use Supported AI Providers
Use OpenAI
To enable OpenAI to generate SQL and text responses to your natural language prompts, obtain API keys from your OpenAI paid account.
You can find your secret API key from your profile dashboard under API keys.
Parent topic: Configure Select AI to Use Supported AI Providers
Use OpenAI-Compatible Providers
To enable providers that are compatible with OpenAI, obtain your API key.
OpenAI-compatible providers use bearer authentication. Obtain your API
                key and use it to create credentials through DBMS_CLOUD.CREATE_CREDENTIAL. For example, Fireworks
                AI is an OpenAI-compatible provider. 
                           
Follow the process to obtain your Fireworks AI API key, model base path URL, and model name:
- Sign up for a Fireworks AI account if you don't have one already.
- Create an API key from Fireworks AI console.
- Copy the generated API key and save it.
- Obtain the provider endpoint that you require in DBMS_CLOUD_AI.CREATE_PROFILEprocedure:
- From the same API Example, copy the model name. You require the model name in
                        DBMS_CLOUD_AI.CREATE_PROFILEprocedure. For example,accounts/fireworks/models/llama-v3p2-3b-instruct.
Parent topic: Configure Select AI to Use Supported AI Providers
Create and Set an AI Profile
Describes the steps to create and enable an AI profile.
Use DBMS_CLOUD_AI.CREATE_PROFILE to create an
                AI profile. Run DBMS_CLOUD_AI.SET_PROFILE to enable the AI profile
                so that you can use SELECT AI with a natural language prompt.
                     
You must run DBMS_CLOUD_AI.SET_PROFILE in each new stateful
                    database session (connection) before you use SELECT AI. If you
                    are using a stateless connection, you must use the
                        DBMS_CLOUD_AI.GENERATE function which enables you to
                    specify the profile name in each invocation.
                        
The following example with the OpenAI provider creates an
                    AI profile called OPENAI and sets the
                    OPENAI profile for the current user session.
                     
-- Create AI profile
--BEGIN
  DBMS_CLOUD_AI.CREATE_PROFILE(
  profile_name   => 'OPENAI',
  attributes     =>'{"provider": "openai",
			"credential_name": "OPENAI_CRED",
			"object_list": [{"owner": "SH", "name": "customers"},
					  {"owner": "SH", "name": "sales"},
					  {"owner": "SH", "name": "products"},
					  {"owner": "SH", "name": "countries"}]
       }');
END;
/
 
PL/SQL procedure successfully completed.
 
--
-- Enable AI profile in current session
--
EXEC DBMS_CLOUD_AI.set_profile('OPENAI');
 
PL/SQL procedure successfully completed.Parent topic: Manage AI Profiles