This topic describes the permissions for AI function services, including the AI MODEL and ACCESS AI MODEL permissions for legacy APIs, as well as the AI PROVIDER and AI GATEWAY permissions for new APIs.
Notice
The AI_SPLIT_DOCUMENT function does not require AI model permissions.
Note
The AI PROVIDER and AI GATEWAY permissions related to new APIs are supported starting from V4.6.2.1. Permissions related to legacy APIs are fully retained, and existing usage can continue to work.
AI MODEL
AI MODEL-related permissions are used to manage AI models, including the CREATE AI MODEL, ALTER AI MODEL, and DROP AI MODEL permissions.
Syntax
The syntax for granting permissions is as follows:
-- Grant the permission to create AI models.
GRANT CREATE AI MODEL ON *.* TO 'username'@'host';
-- Grant the permission to modify AI models.
GRANT ALTER AI MODEL ON *.* TO 'username'@'host';
-- Grant the permission to delete AI models.
GRANT DROP AI MODEL ON *.* TO 'username'@'host';
GRANT CREATE AI MODEL, ALTER AI MODEL, DROP AI MODEL ON *.* TO 'username'@'host';
The syntax for revoking permissions is as follows:
-- Revoke the permission to create AI models.
REVOKE CREATE AI MODEL ON *.* FROM 'username'@'host';
-- Revoke the permission to modify AI models.
REVOKE ALTER AI MODEL ON *.* FROM 'username'@'host';
-- Revoke the permission to delete AI models.
REVOKE DROP AI MODEL ON *.* FROM 'username'@'host';
-- Check the permissions.
SHOW GRANTS FOR 'username'@'host';
Examples
Create a user
CREATE USER test_ai_user@'%' IDENTIFIED BY '123456';Log in to the test_ai_user user
obclient -h 127.0.0.1 -P 2881 -u test_ai_user@'%' -p *** -A -D test;Call the
CREATE_AI_MODEL_ENDPOINTprocedureCALL DBMS_AI_SERVICE.CREATE_AI_MODEL_ENDPOINT ( 'user_ai_model_endpoint_1', '{ "ai_model_name": "my_model1", "url": "https://api.deepseek.com", "access_key": "sk-xxxxxxxxxxxx", "request_model_name": "deepseek-chat", "provider": "deepseek" }');An error is reported because the
CREATE AI MODELpermission is missing.ERROR 42501: Access denied; you need (at least one of) the create ai model endpoint privilege(s) for this operationGrant the
CREATE AI MODELpermission to thetest_ai_useruserGRANT CREATE AI MODEL ON *.* TO test_ai_user@'%';Verify the permission
CALL DBMS_AI_SERVICE.CREATE_AI_MODEL_ENDPOINT ( 'user_ai_model_endpoint_1', '{ "ai_model_name": "my_model1", "url": "https://api.deepseek.com", "access_key": "sk-xxxxxxxxxxxx", "request_model_name": "deepseek-chat", "provider": "deepseek" }');The execution is successful.
ACCESS AI MODEL
The ACCESS AI MODEL permission is used to call AI functions, including the AI_COMPLETE, AI_EMBED, AI_RERANK, and AI_PROMPT functions.
Syntax
The syntax for granting the permission is as follows:
GRANT ACCESS AI MODEL ON *.* TO 'username'@'host';
The syntax for revoking the permission is as follows:
REVOKE ACCESS AI MODEL ON *.* FROM 'username'@'host';
Examples
Call the
AI_COMPLETEfunctionSELECT AI_COMPLETE("ob_complete","You are a translation master. Please translate the following text into English: {{Hello world.}}, and output only the translation result") as ans;An error is reported because the
ACCESS AI MODELpermission is not granted.ERROR 42501: Access denied; you need (at least one of) the access ai model endpoint privilege(s) for this operationGrant the
ACCESS AI MODELpermission to thetest_ai_useruserGRANT ACCESS AI MODEL ON *.* TO test_ai_user@'%';Verify the permission
SELECT AI_COMPLETE("ob_complete","You are a translation master. Please translate the following text into English: {{Hello world.}}, and output only the translation result") as ans;The execution is successful.
+----------------+ | ans | +----------------+ | "Hello world." | +----------------+ 1 row in set
AI PROVIDER
The AI PROVIDER permission is used to manage provider configurations and model parameters at the provider/model level. It is granted or revoked by the root user.
Syntax
The syntax for granting the permission is as follows:
-- Grant the registration permission, corresponding to REGISTER_PROVIDER.
GRANT REGISTER ON AI PROVIDER * TO 'username'@'host';
-- Grant modification permissions, corresponding to ALTER_PROVIDER and ALTER_MODEL_PROFILE.
GRANT ALTER ON AI PROVIDER * TO 'username'@'host';
-- Grant the UNREGISTER_PROVIDER and DROP_MODEL_PROFILE permissions.
GRANT UNREGISTER ON AI PROVIDER * TO 'username'@'host';
-- Grant the model access permission.
GRANT ACCESS ON AI PROVIDER * TO 'username'@'host';
The syntax for revoking the permission is as follows:
-- Revoke the registration permission, corresponding to REGISTER_PROVIDER.
REVOKE REGISTER ON AI PROVIDER * FROM 'username'@'host';
-- Revoke the modification permission, corresponding to ALTER_PROVIDER and ALTER_MODEL_PROFILE.
REVOKE ALTER ON AI PROVIDER * FROM 'username'@'host';
-- Revoke the unregistration permission, corresponding to UNREGISTER_PROVIDER and DROP_MODEL_PROFILE.
REVOKE UNREGISTER ON AI PROVIDER * FROM 'username'@'host';
-- Revoke the model access permission.
REVOKE ACCESS ON AI PROVIDER * FROM 'username'@'host';
After granting a user the AI PROVIDER permission, it takes effect for all providers and models within the tenant.
AI GATEWAY
The AI GATEWAY permission is used to manage gateway configurations and call AI functions through the gateway. It is granted or revoked by the root user.
Syntax
The syntax for granting the permission is as follows:
-- Grant the permission to create a gateway, which corresponds to CREATE_AI_GATEWAY.
GRANT CREATE ON AI GATEWAY * TO 'username'@'host';
-- Grant the permission to modify gateways, which corresponds to ALTER_AI_GATEWAY.
GRANT ALTER ON AI GATEWAY * TO 'username'@'host';
-- Grant the permission to drop gateways, which corresponds to DROP_AI_GATEWAY.
GRANT DROP ON AI GATEWAY * TO 'username'@'host';
-- Grant gateway access permissions.
GRANT ACCESS ON AI GATEWAY * TO 'username'@'host';
GATEWAY ACCESS and PROVIDER ACCESS are independent. After granting GATEWAY ACCESS, users can only access the models contained within that gateway without the need to additionally grant PROVIDER ACCESS.
The syntax for revoking the permission is as follows:
-- Revoke the permission to create gateways.
REVOKE CREATE ON AI GATEWAY * FROM 'username'@'host';
-- Revoke the permission to modify gateways.
REVOKE ALTER ON AI GATEWAY * FROM 'username'@'host';
-- Revoke the permission to drop gateways.
REVOKE DROP ON AI GATEWAY * FROM 'username'@'host';
-- Revoke gateway access permissions.
REVOKE ACCESS ON AI GATEWAY * FROM 'username'@'host';
After granting a user the AI GATEWAY permission, it takes effect for all gateways within the tenant.