Authenticating the uv client
pyx is supported as a first-class package registry in the uv client as of uv v0.8.15. You can install uv with our standalone installers, or with your package manager of choice:If you’re running in a headless environment, e.g., when SSH’d into a remote
server, you’ll be prompted to open a browser window to authenticate.
API key authentication
uv also supports API key-based authentication. You can create API keys in the pyx dashboard and authenticate the client by setting thePYX_API_KEY environment variable:
Trusted Access
Trusted Access is currently in preview. If you’re interested in using Trusted
Access for your CI/CD systems, please get in touch.
Supported providers
pyx supports three Trusted Access providers:At the moment, support for GitHub Actions and GitLab CI/CD as Trusted Access
parties is limited to their hosted offerings, i.e.
github.com and
gitlab.com. Self-hosted instances may be used via the “generic” provider
option.Enrolling a Trusted Accessor
You can enroll a Trusted Accessor on the pyx dashboard under Team > Trusted Access. A Trusted Accessor can be given access to one or more non-default views, or to your entire workspace.Only team administrators can enroll Trusted Accessors.
- GitHub Actions
- GitLab CI/CD
- Generic OIDC IdP
A GitHub Actions Trusted Accessor has one mandatory component:
-
The Repository pattern specifies which repositories can use this
accessor. This pattern uses a restricted subset of the fnmatch
syntax.
For example,
acme/examplewould allow only theacme/examplerepository to use this accessor, whileacme/*would allow any repository under theacmeorganization on GitHub.
- The Subject pattern is an optional fnmatch
pattern that constrains the OIDC subject claim (
sub) in the token presented by GitHub Actions. See GitHub’s example subject claims for details.
Using a Trusted Accessor
Once you’ve enrolled a Trusted Accessor, you can use it to obtain short-lived read tokens for accessing pyx from your CI/CD.A future version of uv will automatically perform the flow below. Until then,
beta users of Trusted Access must explicitly perform these exchange steps.
Obtain an OIDC token from your CI/CD provider
Obtain an OIDC token with audience
pyx:trusted-access from your CI/CD provider.Every CI/CD provider has a different method for obtaining an OIDC token;
refer to your provider’s documentation for detail. For example:- GitHub Actions: Methods for requesting the OIDC token
- Buildkite:
buildkite-agent oidc - GitLab CI/CD: Configure ID tokens in a CI/CD job
Exchange the OIDC token for a pyx access token
Once you have the OIDC token from your CI/CD provider, exchange it
for a pyx access token:
ci.yml
Authenticating external tools
pyx uses JWT-based authentication. When authenticating via theuv auth login
command, uv will store a JWT token on your machine, alongside a refresh token.
When making API requests, uv will include the JWT token in the Authorization
header. If the JWT token is expired, uv will automatically refresh it using the
refresh token. When authenticating via PYX_API_KEY, uv will perform a similar
process, but without the need for a refresh token.
If necessary, you can use uv auth token pyx.dev to generate a JWT token for
use with the pyx API:
ruff with:
__token__ and the password to the JWT token, e.g.:
PYX_AUTH_TOKEN
environment variable:
Authenticating with Docker
In Docker builds, we recommend using Docker’s built-in support for build secrets. When invokingdocker buildx build, you can pass an API key as a build secret.
For example, assuming that your API key is stored in the PYX_API_KEY
environment variable, you can pass it as a build secret with:
pyx_api_key build secret as
follows:
uv auth token pyx.dev and pass
it to Docker as a build secret:
pyx_auth_token build secret as
follows:
Build secrets do not persist across builds, and do not invalidate layer
caches. As such, re-running a Docker build with a regenerated access token
will retain the cached layers from the previous build.
docker/build-push-action GitHub Action, you can pass the
API key as a build secret to the action directly:
ci.yml
Authenticating with Bazel
Bazel versions 7 and newer allow using a custom credential helper to inject credentials into remote file requests in a secure way without affecting caching. uv v0.9.16 and newer has built-in support for this protocol. Once uv is logged in to pyx, you can use the following.bazelrc to enable the credential helper for all pyx urls:
.bazelrc
bazel/uv-auth-helper is a script that invokes uv auth helper with the
right arguments:
bazel/uv-auth-helper
Authenticating with Dependabot
pyx can be configured as a private registry in GitHub’s Dependabot, allowing Dependabot to update dependencies from pyx. To configure Dependabot to use pyx, add the following to your.github/dependabot.yml:
dependabot.yml
acme/main with the appropriate pyx index for your organization (e.g.,
public/pypi, astral-sh/cu126, or your organization’s private index).
Both the
pyx and files registries must be included. The pyx registry
serves the package index, while the files registry serves the package files
from the CDN.PYX_API_KEY in your
GitHub repository settings under Settings > Secrets and variables >
Dependabot.
Authenticating with Artifactory
pyx can be configured as an upstream (remote) repository in JFrog Artifactory, allowing Artifactory to proxy requests to pyx. To configure pyx as a remote repository in Artifactory, first create a read-only API key in the pyx dashboard (pyx-sk-...), then create
a PyPI-compatible remote repository with the following settings.
In the Basic tab:
| Setting | Value |
|---|---|
| URL | https://files.astralhosted.com |
| User Name | __token__ |
| Password / Access Token | pyx-sk-... |
| Enable Token Authentication | ✅ |
| Registry URL | https://api.pyx.dev |
| Registry Index Location Suffix | simple/acme/main |
api.pyx.dev) and the CDN
(files.astralhosted.com), set the following options in the Advanced tab:
| Setting | Value |
|---|---|
| Lenient Host Authentication | ✅ |
| Bypass HEAD Requests | ✅ |
If you’re configuring a pyx View as an upstream, set the URL to
https://views.astralhosted.com instead of https://files.astralhosted.com.
When using static IPs, use https://api-static.pyx.dev,
https://files-static.astralhosted.com, or
https://views-static.astralhosted.com accordingly.Migrating off the uv alpha
Prior to v0.8.15, pyx support shipped in a separate, pyx-enabled alpha build of uv. If you’re migrating off the uv alpha (e.g., v0.8.12-alpha.3), note the following changes to the authentication interface:uv auth loginis nowuv auth login pyx.devuv auth logoutis nowuv auth logout pyx.devuv auth tokenis nowuv auth token pyx.devUV_API_KEYis nowPYX_API_KEY(UV_API_KEYwill continue to be supported temporarily for backwards-compatibility)UV_AUTH_TOKENis nowPYX_AUTH_TOKEN(UV_AUTH_TOKENwill continue to be supported temporarily for backwards-compatibility)