How Baseten OIDC works
Baseten acts as an OIDC identity provider with the following configuration:- Issuer:
https://oidc.baseten.co - Audience:
oidc.baseten.co
Token structure
Each OIDC token includes standard JWT claims and custom claims that identify the workload. Here’s an example unsigned payload:sub claim uses a structured format that encodes the workload identity:
Claim components
Workload types
model_build: Token used during model builds (for example, pulling base images from ECR/GCR or downloading model weights from S3/GCS).model_container: Token used by running model containers (for example, your model code calling cloud services like SQS or DynamoDB at inference time).
Subject claim patterns
Usetruss whoami --show-oidc to view your organization and team IDs, issuer, audience, and subject claim format needed for configuring cloud provider trust policies. The patterns below use these identifiers.
Common patterns for scoping which workloads can access your resources:
- AWS: Use these in the IAM role trust policy under
Condition.StringLikeforoidc.baseten.co:sub. Wildcards (*) are supported. - GCP: Use these in the Workload Identity Provider attribute-condition. With the mapping
google.subject=assertion.sub(see Create a Workload Identity Provider), reference the sub claim asgoogle.subject. GCP does not support wildcards; usestartsWith()(andcontains()where needed).
All workloads in a team
To give every workload in your team access to a resource, match on the team ID with a wildcard for everything else.- AWS (trust policy)
- GCP (attribute-condition)
Specific model, all deployments
To restrict access to a single model while allowing all of its deployments and environments, match on the model ID.- AWS (trust policy)
- GCP (attribute-condition)
Specific environment, all models
To scope access by environment, match workloads deployed to a specific environment likeproduction.
- AWS (trust policy)
- GCP (attribute-condition)
Build-time only access
To limit access to the build phase, like pulling base images from a private registry or downloading model weights, match on themodel_build workload type.
- AWS (trust policy)
- GCP (attribute-condition)
Runtime only access
To limit access to running containers, like your model code calling cloud services such as SQS or DynamoDB at inference time, match on themodel_container workload type.
- AWS (trust policy)
- GCP (attribute-condition)
Specific model and environment
To apply the most restrictive access, combine model and environment matching so only a specific model in a specific environment can authenticate.- AWS (trust policy)
- GCP (attribute-condition)
Cloud provider setup
When using OIDC for images and weights, Baseten OIDC currently supports:- AWS: Amazon ECR (container images) and Amazon S3 (model weights)
- Google Cloud: Artifact Registry, GCR (container images), and Google Cloud Storage (model weights)
- AWS
- GCP
Provision all resources with a single script
Provision all resources with a single script
Run this script to create the OIDC provider, IAM role, and permission policies. Set the variables at the top, then execute the entire script.Prerequisites
- AWS CLI 2.x.
- Bash 3.2+.
- AWS credentials configured for the target account (
aws configure, environment variables, or an IAM role) with permission to create OIDC identity providers, IAM roles, and inline role policies (for exampleiam:CreateOpenIDConnectProvider,iam:CreateRole,iam:PutRolePolicy).
This creates a single role with both ECR and S3 permissions. If you only need ECR or S3 access (not both), comment out or remove the policy section you don’t need (step 4 or step 5).
Create an OIDC identity provider
Register Baseten as a trusted OIDC provider in your AWS account:- Sign in to the AWS IAM Console.
- Go to Identity providers → Add provider.
- Select OpenID Connect.
- Configure the provider:
- For Provider URL, enter
https://oidc.baseten.co. - Choose Get thumbprint to verify the provider.
- For Audience, enter
oidc.baseten.co.
- For Provider URL, enter
- Choose Add provider.
If your AWS account requires
sts.amazonaws.com as a trusted audience, add it to the OIDC provider first, then add oidc.baseten.co as an additional audience.Create an IAM role
Create a role that your Baseten workloads can assume through OIDC:- Go to Roles → Create role.
- Select Web identity as the trusted entity type.
- Choose the OIDC provider you created.
- For Audience, select
oidc.baseten.co, then choose Next. - On the next page, attach permissions policies for the resources your models need to access:
ECR access (for base images)
Attach this policy to allow pulling container images from ECR.S3 access (for model weights)
Attach this policy to allow reading model weights from S3.- Configure the trust policy to include subject claim conditions: after creating the role, go to the role → Trust relationships → Edit and use a policy like this:
Replace
<aws-account-id> with your AWS account ID, and adjust the sub claim pattern to match your security requirements.Use OIDC at build time
Once you’ve completed the AWS or GCP setup above, you can configure OIDC authentication in your Truss. Baseten uses these tokens while it builds and deploys your model, to pull images and download weights:Private registries (ECR, GCR)
For authenticating to private Docker registries using OIDC, see:- AWS ECR OIDC: Configure OIDC for AWS Elastic Container Registry.
- GCP Artifact Registry OIDC: Configure OIDC for Google Container Registry / Artifact Registry.
Model weights (S3, GCS)
For downloading model weights from cloud storage using OIDC, see:- AWS S3 OIDC: Configure OIDC for S3 model weights.
- GCS OIDC: Configure OIDC for Google Cloud Storage model weights.
Use OIDC at request time
Runtime OIDC makes a short-lived Baseten OIDC token available directly to your running model so your code, including anyload() and predict() logic, can authenticate to OIDC-compatible external systems at request time, without storing long-lived credentials.
To enable it for a deployment, set the following in your Truss config.yaml:
config.yaml
B10_OIDC_TOKEN_PATH environment variable. The file contains only the encoded JWT string. To decode and examine the contents, you can use the pyjwt Python package. The following snippet prints the claims of the token during __init__:
config.yaml
model.py
type claim to model_container. Otherwise, the claims and token structure are identical to the ones used for images and weights. Token claims reflect the current state of the deployment, including environment even if updated between promotions.
When promoting a deployment between environments, the new OIDC token with the updated
environment claim may take up to 30 seconds to appear.Runtime file access (S3, GCS)
Use this pattern when your request payload contains a cloud object location (for example, an S3 key or GCS key) and your model needs to fetch that content duringpredict().
The examples below intentionally keep the flow minimal:
- Read a file from S3/GCS and print its contents during
predict(). - If the provider client session is expired, re-create the client (which re-exchanges the current OIDC token) and retry once.
- AWS
- GCP
Get a file from object storage in predict
Get a file from object storage in predict
config.yaml
model.py
Best practices
Use least-privilege access
Use the most specific subject claim pattern that fits your use case. Create separate roles or Workload Identity providers for different environments, workload types, or models rather than one role with broad permissions. Always test your OIDC configuration in a non-production environment first.Monitor and audit
- Enable CloudTrail (AWS) or Cloud Audit Logs (GCP) to track OIDC token usage.
- Set up alerts for unexpected access patterns.
- Regularly review which roles are being used.
Troubleshooting
Authentication failures
If your model fails to authenticate:- Verify the trust relationship: Ensure your IAM role trusts the Baseten OIDC provider (
https://oidc.baseten.co). - Check the audience: Confirm the audience is set to
oidc.baseten.co. - Review subject claim conditions: Verify your
subclaim pattern matches the workload identity. - Inspect your identifiers: Run
truss whoami --show-oidcto confirm your org and team IDs.
Permission denied errors
If authentication succeeds but operations fail:- Check IAM policies: Ensure the role has the necessary permissions (for example,
s3:GetObject,ecr:BatchGetImage). - Verify resource ARNs: Confirm bucket names, registry URLs, and other resource identifiers are correct.
- Review resource policies: Some resources (like S3 buckets) have their own policies that may block access.
Common error messages
Debug with CloudWatch/Cloud Logging
Enable detailed logging to see exactly why authentication or authorization is failing: AWS CloudTrail: Look forAssumeRoleWithWebIdentity events to see token validation attempts.
GCP Cloud Audit Logs: Check iam.googleapis.com logs for workload identity authentication events.
Migration from long-lived credentials
If you’re currently using long-lived AWS or GCP credentials:- Set up OIDC as described above.
- Update your Truss configuration to use OIDC authentication.
- Deploy and test your model.
- Once confirmed working, remove the long-lived credentials.
- Delete any secrets containing long-lived credentials from Baseten.
Both OIDC and long-lived credential authentication methods are supported. You can migrate gradually, starting with non-production environments.
Limitations
- OIDC tokens can’t be customized.
- Baseten manages token lifetime and claims.
- Only AWS and GCP are supported as providers for images and weights. Cloudflare R2, Azure containers, and Hugging Face aren’t yet supported for that use. At runtime, any OIDC-supporting provider works.
- GCP doesn’t support wildcard subject claims or subject-based scoping in IAM role conditions. Use the Workload Identity Provider
attribute-conditioninstead.