Skip to main content
Use OpenID Connect (OIDC) to pull private images, mirror model weights, or sync data into a volume without storing long-lived credentials in Baseten. Your model code can also use OIDC to access external services at runtime. To authenticate to Baseten from workloads that run elsewhere, such as GitHub Actions or a Kubernetes cluster, see Workload identity federation.

How Baseten OIDC works

Baseten issues a short-lived token that identifies the workload. The provider checks the token against the trust you configure and grants access to the resources you authorize.
  • Issuer: https://oidc.baseten.co.
  • Audience: oidc.baseten.co by default. For Hugging Face weight mirroring and volume sync, Baseten uses https://huggingface.co.

Setup

Find your organization and team IDs

Print your organization ID:
List your teams and copy the ID of the team whose workloads need access:
Set up trust where you store the source you want Baseten to read.
  • AWS for container images in Amazon ECR and weights or data in Amazon S3.
  • GCP for container images in Artifact Registry or GCR and weights or data in Google Cloud Storage.
  • Hugging Face for inference weights and volume sync from private or gated repositories.
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 example iam:CreateOpenIDConnectProvider, iam:CreateRole, iam:PutRolePolicy).
Review each variable before running. Replace the empty values with your actual AWS account ID, S3 bucket name, organization ID, and team ID.
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).
If you prefer to walk through each step manually, or need to customize individual resources, follow the instructions below.

Create an OIDC identity provider

Register Baseten as a trusted OIDC provider in your AWS account:
  1. Sign in to the AWS IAM Console.
  2. Go to Identity providers → Add provider.
  3. Select OpenID Connect.
  4. Configure the provider:
    • For Provider URL, enter https://oidc.baseten.co.
    • Choose Get thumbprint to verify the provider.
    • For Audience, enter oidc.baseten.co.
  5. 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:
  1. Go to Roles → Create role.
  2. Select Web identity as the trusted entity type.
  3. Choose the OIDC provider you created.
  4. For Audience, select oidc.baseten.co, then choose Next.
  5. 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.
  1. 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

After you configure trust with your provider, add OIDC authentication to your model or training configuration.

Use OIDC at runtime

Runtime OIDC is not available for training jobs.
Your model code can exchange a runtime token with a provider that trusts Baseten and accepts the oidc.baseten.co audience. This lets load() and predict() authenticate to external services such as a key management service for BYOK encryption. Hugging Face requires the https://huggingface.co audience. Use its build-time or volume-sync setup to read a repository. To enable it for a deployment, set the following in your Truss config.yaml:
config.yaml
To enable runtime OIDC for a BIS-LLM engine deployment, contact Baseten support.
Baseten mounts the token and refreshes it automatically before expiry (such that at least 5 minutes of TTL remains). To access the token, use the 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
For AWS and GCP, use the same provider setup and scope the trust policy to runtime workloads. Runtime tokens set the type claim to model_container and reflect the deployment’s current environment.
When promoting a deployment between environments, the new OIDC token with the updated environment claim may take up to 30 seconds to appear.

Basic file access

To read an object during predict(), set up trust with AWS or GCP and grant the workload read access to the object. The provider SDK refreshes its credentials using the mounted OIDC token.
Review each variable before running. Replace the empty values with your actual AWS values.
config.yaml
model/model.py

Encrypt weights and payloads with your own keys (BYOK)

Your weights or request payloads stay encrypted with a data key that only your KMS can unwrap. Your model exchanges its runtime token for credentials, asks your KMS to unwrap the data key, and uses the key to decrypt the data. Use a provider that accepts the runtime token audience. The AWS KMS recipes include a setup script and model code.
  • BYOK weight encryption: Keep model weights encrypted in object storage and use runtime OIDC to retrieve the key material needed to decrypt them when the model starts.
  • BYOK payload encryption: Use runtime OIDC to retrieve customer-managed keys, then decrypt requests and encrypt responses during inference.
See the runtime OIDC recipes for more end-to-end examples.

Token structure

An OIDC token carries standard JSON Web Token (JWT) claims and Baseten workload claims. These examples show the decoded payload for an inference build and a training build.
The sub claim uses a structured format that encodes the workload identity:

Claim components

Workload types

  • model_build: Token used to pull container images or mirror model weights for a deployment.
  • model_container: Token used by running model containers (for example, your model code calling cloud services like SQS or DynamoDB at inference time).
  • training_build: Token used to prepare training jobs (for example, pulling a private training image or downloading weights and training data).
  • volume_sync: Token used by volume sync to read a private S3, GCS, or Hugging Face source. Its subject has the form v=1:org={org_id}:team={team_id}:volume_version={volume_version_id}:type=volume_sync.

Subject claim patterns

Use your organization and team IDs in the trust policy. AWS and GCP match the sub claim using the patterns below. Hugging Face matches individual claims. See Hugging Face setup.
  • AWS: Use these in the IAM role trust policy under Condition.StringLike for oidc.baseten.co:sub. Wildcards (*) are supported.
  • GCP: Use these in the workload identity provider’s attribute-condition. Map assertion.sub to google.subject, then match it with startsWith() or contains().

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.

Specific model, all deployments

To restrict access to a single model while allowing all of its deployments and environments, match on the model ID.

Specific environment, all models

To scope access by environment, match workloads deployed to a specific environment like production.

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 the model_build workload type.

Training jobs only

To grant access to training jobs without granting access to inference workloads, match on the training_build workload type.
To scope access to one training project or job, include its ID in the subject pattern, for example v=1:org=abcd1234:team=wxyz5678:project=project123:job=*:type=training_build.

Volume sync only

To let volume sync read a bucket without granting access to models or training jobs, match on the volume_sync workload type. Each sync creates a new volume version, so scope the pattern by organization, team, and type rather than by a volume version ID.

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 the model_container workload type.

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.

Best practices

Use least-privilege access

Scope access to the workloads that need it. For AWS and GCP, use a specific subject claim pattern and create separate roles or workload identity providers when workloads need different permissions. For Hugging Face, scope the publisher or identity by organization, team, and workload type. Test your OIDC configuration in a non-production environment before switching production workloads.
Don’t grant access to v=1:org=*:team=*:*. This allows any Baseten workload to access your resources.

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 AWS or GCP rejects the workload token, check the provider’s issuer, audience, and subject condition.
  1. Confirm the provider trusts the issuer https://oidc.baseten.co and accepts the audience oidc.baseten.co.
  2. Compare the subject condition with the workload’s claims.
  3. Use the CLI commands to confirm the organization and team IDs.
For Hugging Face, check the issuer and org, team, and type claims on the publisher or identity. Verify that the configured resource is the private repository ID or the Hugging Face username with access to the gated repository.

Permission denied errors

If authentication succeeds but operations fail:
  1. Check IAM policies: Ensure the role has the necessary permissions (for example, s3:GetObject, ecr:BatchGetImage).
  2. Verify resource ARNs: Confirm bucket names, registry URLs, and other resource identifiers are correct.
  3. Review resource policies: Some resources (like S3 buckets) have their own policies that may block access.

Common error messages

Check provider audit logs

  • AWS CloudTrail. Look for AssumeRoleWithWebIdentity 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

Start with a non-production deployment or volume sync.
  1. Set up trust with the provider.
  2. Replace the stored credential reference with the OIDC configuration for the build or volume sync.
  3. Deploy the model or run the sync and confirm that it can read the source.
  4. Remove the stored credential after every workload that uses it has migrated.

Limitations

  • Baseten manages OIDC token lifetime and claims.
  • Use stored credentials for private weight sources on Cloudflare R2 and Azure.
  • Training jobs can’t authenticate to Hugging Face with OIDC.
  • GCP doesn’t support wildcard subject claims or subject-based scoping in IAM role conditions. Use the Workload Identity Provider attribute-condition instead.
  • GCP limits the mapped google.subject attribute to 127 bytes, which Baseten’s sub claim can exceed with long environment names. Instead of mapping assertion.sub directly, construct a shorter subject from the top-level claims, such as google.subject = "v=1:org=" + assertion.org + ":team=" + assertion.team, and map any additional claims needed for attribute conditions separately.