tl login for interactive CLI sessions. OIDC workload authentication exchanges short-lived identity tokens from GitHub Actions, Vercel, Kubernetes, or any HTTPS OIDC issuer for short-lived tl_wt_* Tensorlake tokens so you don’t store long-lived secrets in CI or cloud environments. API keys remain supported alongside OIDC for environments without an OIDC issuer.
Tensorlake account
You need a Tensorlake Cloud account to call the Python SDK, the@tensorlakeai/tensorlake npm package, the Rust SDK, the tl CLI, or the REST API. Create an account at Tensorlake Cloud.
Credential precedence
Tensorlake clients choose a credential by explicit configuration first, then environment variables, then saved CLI contexts. When multiple credentials exist in the same process, clients resolve them in this order:- Explicit API key:
api_key/apiKeypassed to a client constructor,--api-key, orTENSORLAKE_API_KEY - Explicit OIDC credentials:
oidc_token/oidcToken,oidc_policy_id/oidcPolicyId,--oidc-token,--oidc-token-file,TENSORLAKE_OIDC_TOKEN, orTENSORLAKE_OIDC_TOKEN_FILE(in thetlCLI,--oidc-policy-id/TENSORLAKE_OIDC_POLICY_IDselects a trust policy without overriding a savedtl logincontext unless an OIDC token source is also present) - Ambient OIDC runtime:
VERCEL_OIDC_TOKENon Vercel, orACTIONS_ID_TOKEN_REQUEST_URLandACTIONS_ID_TOKEN_REQUEST_TOKENin GitHub Actions, paired withTENSORLAKE_PROJECT_IDorTENSORLAKE_OIDC_POLICY_ID - CLI login context: a 12-hour Personal Access Token (PAT) saved by
tl login(tlCLI only; Python and TypeScript SDKs don’t read CLI login contexts)
tl whoami shows a project you didn’t select with tl login, check your shell environment for TENSORLAKE_API_KEY or TENSORLAKE_OIDC_TOKEN.
OIDC workload authentication
OIDC workload authentication replaces static API keys in Continuous Integration (CI) pipelines and cloud backends with short-lived, project-scoped credentials. Your workload presents an external OIDC JSON Web Token (JWT) to Tensorlake, which verifies the signature against the issuer’s JSON Web Key Set (JWKS), checks your trust policy’s claim rules, and returns a short-livedtl_wt_* bearer token (60s to 3600s, default 900s).
tl_wt_* and is confined to a single project. Workload tokens work with Tensorlake’s Sandboxes API, sandbox proxy, and project-scoped platform routes, and cannot access organization-wide settings, billing, SSO configuration, or API key management.How OIDC token exchange works
Each workload authenticates in two steps without storing static Tensorlake secrets:Create a project trust policy
issuer, expected audience (default https://api.tensorlake.ai), at least one subject or claims match rule, a project role (member or project:admin), and a token Time to Live (TTL).Exchange the OIDC JWT for a workload token
projectId (or policyId) to POST /platform/v1/auth/oidc/token. Tensorlake validates the JWT and returns a short-lived tl_wt_* bearer token.Send authenticated requests
tl_wt_* token in Authorization: Bearer headers. The Rust SDK and the Python and TypeScript Sandbox and Cloud clients exchange and refresh tokens automatically when ambient OIDC environment variables are present, and the tl CLI exchanges a fresh tl_wt_* token automatically at startup for each invocation. For standalone clients that still take a static bearer token (such as UsageClient, RepositoryClient, or FilesystemClient), pass an exchanged tl_wt_* token from exchange_oidc_token / exchangeOidcToken or OidcTokenManager.Create an OIDC trust policy
Only a human organization or project admin signed in directly to the Tensorlake console can create, edit, or delete trust policies. API keys, PATs, workload tokens, and support impersonation sessions are refused. Every policy must constrainsubject, at least one entry in claims, or both. Tensorlake rejects bare * wildcards and unconstrained policies so a policy can never trust an entire public issuer.
Create a policy in the Tensorlake Dashboard
Open your project’s API Keys page
Add an OIDC trust policy
issuer, audience, and subject or claims rules, choose the project role (Member or Project admin), and set the workload token TTL (60s–3600s, default 900s).Copy the policy ID and quickstart snippet
oidc_pol_* policy ID and quickstart snippet for your workload environment. You can edit, disable, revoke active tokens, or delete policies from the same table at any time.Create a policy over the Platform REST API
You can also create and manage trust policies programmatically from an authenticated admin console session. For GitHub Actions, match immutable numeric repository IDs so repository renames or transfers cannot hijack access:id prefixed by oidc_pol_. Pass that id as policyId when managing policies with GET, PATCH, and DELETE on /platform/v1/organizations/{organizationId}/projects/{projectId}/oidc-trust-policies/{policyId}, or when disambiguating token exchange.
For Vercel-hosted apps, set issuer to your team’s issuer URL (https://oidc.vercel.com/your_team_slug), set audience to match your Vercel token’s aud claim (https://vercel.com/your_team_slug for automatic VERCEL_OIDC_TOKEN), and match owner_id, project_id, and environment:
claims must match the verified JWT payload (logical AND across keys). When a claim rule holds an array of strings, any element in that array satisfies the rule (logical OR within the key).
Exchange an OIDC token over REST
Post the external OIDC JWT with eitherprojectId or policyId to POST /platform/v1/auth/oidc/token. Specify policyId if more than one trust policy on the project matches the same token:
token as an Authorization: Bearer credential on any project-scoped API or Sandbox request until expiresAt.
Use OIDC in GitHub Actions
Grantid-token: write to the workflow job and set TENSORLAKE_PROJECT_ID (or TENSORLAKE_OIDC_POLICY_ID). The tl CLI, Python SDK, TypeScript SDK, and Rust SDK automatically request an OIDC JWT for audience https://api.tensorlake.ai and exchange it for a tl_wt_* token:
TENSORLAKE_API_KEY is unset, run_in_sandbox.py calls Sandbox.create() with no credential arguments and authenticates through GitHub Actions OIDC.
Use OIDC on Vercel
Enable Vercel OIDC Federation on your Vercel project and setTENSORLAKE_PROJECT_ID in your Vercel project environment variables. Make sure your Tensorlake OIDC trust policy’s audience matches the aud claim on Vercel’s VERCEL_OIDC_TOKEN (https://vercel.com/<team-slug> by default). On Vercel Functions and builds, @tensorlakeai/tensorlake and the Python SDK detect VERCEL_OIDC_TOKEN automatically when TENSORLAKE_API_KEY is unset:
exchangeOidcToken or OidcTokenManager:
Use OIDC in Python and Kubernetes
The Python SDK (Sandbox, AsyncSandbox, SandboxClient, AsyncSandboxClient, and CloudClient) reads TENSORLAKE_OIDC_TOKEN, TENSORLAKE_OIDC_TOKEN_FILE (for Kubernetes projected ServiceAccount tokens), VERCEL_OIDC_TOKEN, and GitHub Actions OIDC automatically when api_key is omitted, and refreshes tokens in the Rust core 60s before expiry. You can also exchange an external JWT explicitly with exchange_oidc_token:
api_key (such as UsageClient or RepositoryClient), use OidcTokenManager to cache exchanged tl_wt_* tokens and refresh them 60s before expiry. In Rust (tensorlake crate), pass OidcAuthConfig to ClientBuilder::oidc_auth(...) for automatic middleware-based refresh.
Revoke active workload tokens
Activetl_wt_* tokens remain valid until expiresAt unless you revoke the trust policy. In the Tensorlake Dashboard (API Keys → OIDC Trust Policies), use the row actions to revoke active tokens, disable the policy, edit its trust rules, or delete it. Over the REST API, update the policy with PATCH and set "revokeExistingTokens": true, change any trust rule (issuer, audience, subject, claims, or scope), set "enabled": false, or delete the policy with DELETE. Tensorlake increments policyVersion (or removes the policy), immediately drops cached decisions on the handling pod, and rejects previously minted tokens across all replicas within 5s (the forward-auth cache TTL).
API keys
API keys are project-specific credentials for programmatic access when an OIDC issuer isn’t available, such as plain servers, Docker containers, or local scripts. Each API key belongs to a single project and inherits the project member permissions for that project.tl_apiKey_*.Create an API key
Create a project API key in the dashboard:Open your project
Generate a key

SDK and CLI authentication
Tensorlake’s user-facing clients accept project credentials as follows:- Python, TypeScript, and Rust SDKs: pass a project API key via
TENSORLAKE_API_KEY, or configure OIDC workload authentication withTENSORLAKE_PROJECT_ID(orTENSORLAKE_OIDC_POLICY_ID) - REST API calls: send an API key (
tl_apiKey_*) or an exchanged workload token (tl_wt_*) in theAuthorization: Bearerheader tlCLI: runtl loginon your workstation for interactive 12-hour PAT contexts, use OIDC flags (--oidc-token,--oidc-token-file,--oidc-policy-id) or ambient CI OIDC in pipelines, or setTENSORLAKE_API_KEY
- Your own machine: run
tl loginto save a context per project and switch projects without logging in again (see Switch Between Projects in the CLI) - CI or cloud runtime with OIDC: set
TENSORLAKE_PROJECT_ID(andTENSORLAKE_OIDC_TOKEN_FILEon Kubernetes) sotlexchanges a short-livedtl_wt_*token automatically - Container or server without OIDC: set
TENSORLAKE_API_KEYto a project API key
Tensorlake Python SDK
Pass an API key throughTENSORLAKE_API_KEY or directly to Sandbox.create, or omit api_key when OIDC environment variables are configured.
TENSORLAKE_API_KEY.
TypeScript SDK
Install@tensorlakeai/tensorlake for Node.js 22+ and authenticate with either OIDC or TENSORLAKE_API_KEY.
TENSORLAKE_API_KEY. See Sandboxes for lifecycle examples.
REST API
Include your API key (tl_apiKey_*) or exchanged OIDC workload token (tl_wt_*) in the Authorization: Bearer header on every REST request.
Frequently asked questions
Should I use OIDC workload authentication or API keys?
Should I use OIDC workload authentication or API keys?
How do I prevent repository renames from breaking or hijacking GitHub Actions OIDC?
How do I prevent repository renames from breaking or hijacking GitHub Actions OIDC?
repository_owner_id and repository_id) in the policy’s claims object alongside your subject or environment rule, rather than relying only on mutable repository names.How long do exchanged OIDC workload tokens last?
How long do exchanged OIDC workload tokens last?
tokenTtlSeconds between 60s and 3600s (default 900s, or 15 minutes). The Rust ClientBuilder (which also backs Python and TypeScript Sandbox clients) and OidcTokenManager refresh tokens automatically 60s before expiry.Can I use the same API key or OIDC workload token across multiple projects?
Can I use the same API key or OIDC workload token across multiple projects?
tl_wt_* OIDC workload tokens are confined to the single project where the key or trust policy was created. Create a separate trust policy or API key for each project.What should I do if an API key is compromised?
What should I do if an API key is compromised?
What’s the difference between API keys, OIDC workload tokens, and user sessions?
What’s the difference between API keys, OIDC workload tokens, and user sessions?