Limiting Model Inference Access with IAM Policies
Use an IAM policy condition with target.model.id to limit a group's inference access to approved Generative AI models.
Model-level IAM conditions provide a preventative control that limits which models the members of a specified group can use for inference. An inference request from a member of that group is authorized only when its model ID matches the condition in the policy.
Throughout this topic, <group-name> represents the group whose model inference access you want to limit.
The policy examples use the aggregate generative-ai-family resource type, but the target.model.id restriction described in this topic applies only to model inference. The affected inference resource types within generative-ai-family are:
generative-ai-chatgenerative-ai-text-embeddinggenerative-ai-text-rerank
The restriction doesn't apply to management operations for the other resource types included in generative-ai-family. See Generative AI Individual Resource Types for the complete list of included resource types.
When members of that group work in the Console, grant the group both types of access:
- Grant the group the minimum
inspect generative-ai-modelpermission so its members can runListModelsand select a model. - Grant the same group
use generative-ai-familypermission with atarget.model.idcondition so its members can invoke only the approved models.
Although the use verb includes the permissions granted by inspect, the target.model.id condition applies to every permission in the conditional policy statement. For the syntax for single and several conditions and pattern values, see Policy Syntax.
IAM policies are cumulative. To enforce the inference restriction, ensure that no other policy grants that group or its members broader inference access through
generative-ai-family, generative-ai-chat, generative-ai-text-embedding, or generative-ai-text-rerank without a target.model.id condition.Find model IDs on the individual model pages linked from Generative AI Models by Region. For model inference restrictions that apply to a Generative AI API key, see Adding Key Permissions.
Allow Inference Access to Specific Models
For a strict inference allowlist, grant the group use permission only when target.model.id matches an approved model ID. To allow the group to invoke one model, use a single condition. For example:
allow group <group-name> to use generative-ai-family in tenancy
where target.model.id = 'google.gemini-2.5-flash'To allow the group to invoke any one of several models, use ANY, which applies a logical OR to the conditions. The following example uses two model IDs to illustrate the policy syntax. Select models that meet your organization's requirements.
allow group <group-name> to use generative-ai-family in tenancy
where ANY {target.model.id = 'google.gemini-2.5-flash',
target.model.id = 'google.gemini-2.5-pro'}To scope the policy to a compartment instead of the tenancy, use:
allow group <group-name> to use generative-ai-family
in compartment <compartment-name>
where ANY {target.model.id = '<model-1>',
target.model.id = '<model-2>'}For strict compliance requirements, list each approved model ID explicitly. Update the policy when the set of approved models changes.
Allow Inference Access by Model ID Pattern
Use a pattern value to allow the group to invoke models whose IDs begin with the same characters. For example, the following policy allows members of the group to run inference with models whose IDs begin with google.gemini-3.:
allow group <group-name> to use generative-ai-family in tenancy
where target.model.id = /google.gemini-3.*/Pattern matching is case-insensitive. A pattern also grants access to future model IDs that match it. For strict compliance requirements, use an explicit allowlist instead.
Grant Inference Access Except to Specified Models
To grant the group inference access only when the model ID doesn't match any excluded value, combine inequality conditions with ALL, which applies a logical AND to the conditions:
allow group <group-name> to use generative-ai-family in tenancy
where ALL {target.model.id != /google.*/,
target.model.id != '<another-excluded-model>'}This policy grants inference access to every current or future model that doesn't match an exclusion. It isn't an explicit deny, and another applicable policy can still grant inference access to an excluded model. Use an explicit allowlist when inference access must be limited to a known set of approved models.
Grant the Minimum Permission to List Models
The ListModels operation doesn't target an individual model, so the request doesn't include a value for target.model.id. When a variable in a policy condition isn't applicable to a request, the condition evaluates to false and the request is declined. Therefore, the conditional use generative-ai-family policy doesn't authorize ListModels, even though use normally includes inspect permissions. See Conditions in the IAM documentation.
Members of the group can't list or select models in the Console without permission to run ListModels. Grant the same group another unconditional policy to inspect the generative-ai-model resource type:
allow group <group-name> to inspect generative-ai-model in tenancyThis policy allows members of the group to run the ListModels operation. It doesn't grant them permission to invoke models that aren't included in the model allowlist.
If an application is using the API, already knows the model ID, and doesn't call
ListModels, the inspect policy isn't required solely to enforce the model inference restriction.Plan the Allowlist
Before adding the policy:
- Identify the models approved for the workload and use their exact model IDs in the condition.
- Review all policies that apply to the group whose model inference access you want to limit and to its members, including policies that apply because the members belong to other groups. Also review policies for other principals used by the workload. Remove broader inference access that would make the allowlist ineffective.
- Confirm that each approved model is available in the required region. Model-level IAM conditions restrict inference access but don't replace regional availability and data-residency planning.
- Review and update the allowlist when approved models are added, replaced, or retired.