<budget_name>!ADD_SHARED_RESOURCE¶
Adds a shared resource to a custom budget. When you add a shared resource, consumption is tracked only if the resource is used by certain users. These users are tagged with a tag-value pair that was added to the budget using the SET_USER_TAGS method.
For more information, see Using budgets for AI features (shared resources).
Syntax¶
<budget_name>!ADD_SHARED_RESOURCE( '<domain>' [ , '<instance>' ] )
Arguments¶
'domain'The type of resource being added to the budget. Valid values:
AI FUNCTIONCORTEX CODECORTEX AGENTSNOWFLAKE INTELLIGENCE
Unless you specify a second argument, the budget tracks consumption for all resources within the specified domain.
'instance'Optional. Specifies a specific resource within the selected
domainto add to the budget.For domains that support instance-level selection (such as
AI FUNCTIONandCORTEX CODE), this argument allows you to track a specific function or interface.If you don’t specify a second argument, the budget tracks all instances within the domain.
Examples:
AI Functions:
AI_CLASSIFY,AI_COMPLETECortex Code:
CORTEX_CODE_CLI,CORTEX_CODE_SNOWSIGHT
Instance-level selection is not applicable to all domains. For example,
CORTEX AGENTandSNOWFLAKE INTELLIGENCEare currently tracked at the domain level only.
Returns¶
Returns a VARCHAR value that indicates whether or not the resource was successfully added to the budget.
If the resource could not be added to the budget, the function returns an error message.
Access control requirements¶
The following privileges and roles are required to call this method for a custom budget:
ADMIN instance role for the budget instance.
USAGE privilege on the database and schema that contain the budget instance.
USAGE privilege on the database and schema that contain the resource being added (for schema objects).
For more information, see Budgets roles and privileges.
Usage notes¶
You can only add shared resources to custom budgets.
To verify the results of the method, call the GET_BUDGET_SCOPE method.
When all objects of the specified entity type are added (for example, all AI Functions), you can’t add individual resources of that type.
Calling this method does not return the object. Because of this, you can’t use method chaining to call another method on the return value of this method. Instead, call each method in a separate SQL statement.
Examples¶
Add all AI Functions to the budget:
CALL finance_budget!ADD_SHARED_RESOURCE('AI FUNCTION');
Add a specific AI function to the budget:
CALL finance_budget!ADD_SHARED_RESOURCE('AI FUNCTION', 'AI_CLASSIFY');
Add all Cortex Code workloads to the budget:
CALL finance_budget!ADD_SHARED_RESOURCE('CORTEX CODE');
Add the Cortex Code CLI workload to the budget:
CALL finance_budget!ADD_SHARED_RESOURCE('CORTEX CODE', 'CORTEX_CODE_CLI');
Add the Cortex Code Snowsight workload to the budget:
CALL finance_budget!ADD_SHARED_RESOURCE('CORTEX CODE', 'CORTEX_CODE_SNOWSIGHT');
Add Cortex Agent workloads to the budget:
CALL finance_budget!ADD_SHARED_RESOURCE('CORTEX AGENT');
Note
Cortex Agent budgets are available at the domain level only. To track the cost of specific agents, use resource budgets through resource tags instead. For more information, see Resource budgets for Cortex Agents.
Add all Snowflake Intelligence workloads to the budget:
CALL finance_budget!ADD_SHARED_RESOURCE('SNOWFLAKE INTELLIGENCE');
Note
Snowflake Intelligence budgets are available at the domain level only.