Claude Code with Okta JWT authentication on LiteLLM

Connect each developer's Claude Code session to a self-hosted LiteLLM gateway using their own Okta access token, with per-person identity, spend and logs.

On this page

How Claude Code signs in to LiteLLM with Okta JWTs

Developers need Claude Code access through the gateway without a shared key, and the platform team needs every request attributed to a person so spend and logs can be read per developer. The supported method for this is an apiKeyHelper script that supplies a fresh Okta access token to Claude Code on each session. Claude Code sends that token as its API key, LiteLLM checks the token signature against Okta's JWKS keys, and the request is mapped to a user record, which LiteLLM creates on first request through user_id_upsert. The helper script is the piece that handles token retrieval and refresh, so the platform team owns its behavior on every developer laptop.

JWT authentication requires a LiteLLM Enterprise license. The open source proxy does not provide this path, so the license decision comes before the design work. Confirm the license terms and the number of developers in scope with LiteLLM before rollout, because the SSO limits that apply to the admin UI are a separate question from JWT authentication for API traffic. The tutorial describes Okta, but any OIDC provider that issues JWT access tokens, such as Azure AD, Keycloak or Auth0, follows the same pattern. The adaptation work lies in the token claims, the audience and the JWKS endpoint, so confirm each of those values with the identity provider before copying the Okta settings.

Plan the token lifetime, the claims LiteLLM must read to build user identity, and what happens when a developer leaves the company. User records are created automatically, so deprovisioning in Okta stops new tokens but does not remove existing LiteLLM users or their spend history unless you add a separate process for that. Ask LiteLLM and your identity team to confirm how revoked or disabled users are handled before any developer receives access. Test the helper on a managed device first, and record which Okta application, scopes and audience values the gateway expects so the configuration can be reviewed.

What you need before configuring the Okta JWT flow

Five components have to be in place before the Claude Code client can authenticate with an Okta access token. Most failed setups trace back to a gap in the license, the database, the identity provider configuration or the transport layer, so confirm each one before editing the gateway configuration.

LiteLLM version and Enterprise license

JWT authentication with identity provider tokens is an Enterprise feature, so an open source deployment cannot follow this flow as written. Confirm the LiteLLM release line you will run against the current release listed on the GitHub releases page, and confirm with LiteLLM that your license covers JWT authentication before you start. Plan to stay on a supported minor version, since LiteLLM maintains only the four most recent stable minors.

Supported minor versions
4
Enterprise docs

PostgreSQL for keys and users

Virtual keys need a PostgreSQL database, and the automatic user creation step writes user records there on first request. Provision PostgreSQL as the primary database, with backups and access restricted to the proxy. Confirm that the proxy's database credentials are stored in your secret manager rather than in the configuration file.

Production guide

Redis once you run several proxies

A single proxy instance can run without Redis, but once more than one instance serves Claude Code traffic, rate limits, router state and cache must be shared. Use Redis 7.0 or newer. Check this before scaling out, because per-user limits enforced on separate instances will otherwise drift apart.

Okta authorization server issuing access tokens

The token Claude Code presents must be an Okta access token from an authorization server, not an ID token, and it must carry the audience and claims LiteLLM expects. Confirm which authorization server, audience and scopes your organization uses, and confirm that the developer application is allowed to request them. Record the issuer URL, because the JWKS lookup depends on it.

Reachable JWKS endpoint and TLS

LiteLLM validates each token signature against the public keys published at the identity provider's JWKS endpoint, so the gateway must be able to reach that URL from its network, including through any egress proxy. Serve the gateway itself over TLS, because developer tokens travel in every request. Test the JWKS URL from the gateway host before blaming the configuration.

Master key and Claude Code client version

Store LITELLM_MASTER_KEY, which must start with sk-, in a secret manager and keep it out of developer machines and shell profiles. Then confirm the Claude Code client version against the LiteLLM Claude Code Okta tutorial, since the apiKeyHelper behavior depends on it. Pin that version in your rollout so developers do not drift.

Okta tutorial

Configuring Okta, the apiKeyHelper script and LiteLLM in sequence

This sequence connects Okta, LiteLLM and Claude Code so each developer signs in with their own Okta access token, and LiteLLM creates their user record on first use. Each step ends with a check you can run before moving on.

  1. Confirm the Okta authorization server and token claims

    An Okta administrator creates or confirms a custom authorization server that issues access tokens for the Claude Code application, then adds the claims LiteLLM will read, such as the user's email or a stable subject identifier and group membership if you plan to map teams from groups. Record the issuer URL and the JWKS URI from the server's metadata. Check: sign in as a test developer, request an access token, and decode it to confirm the issuer, audience, expiry and the expected claims are present before continuing.

  2. Enable JWT authentication on the LiteLLM proxy

    The platform team adds the JWT auth settings to the proxy configuration, pointing the issuer and JWKS URL at the Okta authorization server and setting the claim that identifies the user. JWT authentication requires a LiteLLM Enterprise license, so confirm the license is in place before this step. Keep the master key in your secret manager, not in the config file. Check: restart the proxy, then send a request with a token that has a wrong audience or an expired expiry and confirm LiteLLM rejects it.

  3. Enable automatic user creation with user_id_upsert

    Turn on user_id_upsert so LiteLLM creates a user record the first time a valid token from a new developer arrives, instead of requiring an administrator to provision each person in advance. Decide which claim becomes the LiteLLM user ID, because that value sets how spend and logs are attributed later and is hard to change once records exist. Check: make one valid request from a developer who has no LiteLLM record, then confirm the proxy log shows a new user record created for that claim value.

  4. Write the apiKeyHelper script

    Claude Code calls the script named in its apiKeyHelper setting to get the credential it sends as the API key. The script requests an Okta access token using the developer's existing sign-in session, caches it, and fetches a fresh one before expiry, so developers are not prompted on every request. Store the script in a location the developer's device managers control, and keep client secrets out of it where the Okta flow allows. Check: run the script directly in a terminal and confirm it prints a token that decodes to the same claims you verified in the first step, and that a second run within the token lifetime reuses the cached value.

  5. Point Claude Code at the gateway through managed settings

    Configure Claude Code's base URL to your LiteLLM gateway and set apiKeyHelper to the script path using managed settings, so developers cannot override the gateway address on their own machines. Confirm the Claude Code version you deploy supports the settings and the helper mechanism, since this is a version-dependent behavior to verify with Anthropic's Claude Code documentation and your own test build. Check: on a managed test machine, run Claude Code and confirm the session starts without a manually entered key and the proxy receives a request authenticated with a JWT.

  6. Test with a single developer account end to end

    Before wider rollout, have one developer account complete a real coding session that exercises model access, a token refresh after the cached token expires, and a request to a model the developer should not be allowed to use. The platform team confirms the expected outcome for each: successful completion, a refreshed token with no sign-in prompt, and a denied request. Check the LiteLLM logs for the user record, the spend entry tied to that user, and the denial, then compare them with the expected results written down before the test.

  7. Adapt the setup for Entra ID or Keycloak

    If your identity provider is Microsoft Entra ID or a Keycloak realm, the same pattern applies: an identity provider that issues JWT access tokens, a JWKS endpoint that LiteLLM can reach, and a claim that identifies the user. Confirm each provider's issuer format, audience value and claim names against its own documentation, because these differ between providers. Repeat the decode and rejection checks from the earlier steps for the new issuer before moving developers onto it.

How the token flows from Okta to LiteLLM on each request

The key point is that LiteLLM never sees a password or a shared key: each Claude Code request carries the developer's own Okta access token, and LiteLLM decides on every call whether that token still earns access. The apiKeyHelper script obtains the token when the developer starts a session and refreshes it before it expires, so Claude Code can send it as the API key in each request. When a request arrives, LiteLLM checks the token's signature against the public keys published at the Okta JWKS endpoint, then checks the issuer, the audience and the expiry time. Only a token that passes all four checks is accepted. On the first valid request from a new developer, LiteLLM creates the user record through user_id_upsert, so no manual user provisioning is needed in the gateway.

Confirm the exact claim names, issuer URL and audience value with your Okta authorization server before you write the LiteLLM JWT settings, because a mismatch in any of them causes every request to fail with an authentication error rather than a partial result. Also confirm which claims LiteLLM maps to users and teams, since access decisions depend on those claims and the team mapping you configure, not on the fact that a token is valid. A developer who belongs to a group that is not mapped to any team may authenticate successfully yet have no models, budgets or limits assigned as you intended.

Expiry and deprovisioning behave differently. An expired token stops working at the next request, and the helper's refresh is what keeps sessions running, so test refresh behavior on managed laptops and in headless environments. When a person is deprovisioned or disabled in Okta, the gateway does not learn of it from the token alone: a previously issued token can remain valid until it expires, and LiteLLM's user record persists unless an administrator removes or blocks it. Plan a short token lifetime, a documented offboarding step that disables the LiteLLM user, and a test that confirms both behaviors in your environment.

Where trust boundaries sit in the Okta to LiteLLM login path

The walk starts on the developer laptop, where Claude Code calls the apiKeyHelper script to fetch and refresh an Okta access token. Claude Code then sends that token to the LiteLLM proxy as its API key, which sits outside the device in infrastructure you control. LiteLLM validates the token against the Okta JWKS keys before it creates the user with user_id_upsert and forwards the request to the model provider. Check that the device-to-gateway hop uses TLS, that the gateway accepts only tokens from your Okta issuer and expected audience, and that PostgreSQL holds the user and spend records while the provider key never leaves the gateway.

Developer device to gateway is the trust boundary; Okta and the model provider sit on the far side of it.

Mapping Okta claims, LiteLLM users and team budgets

This table traces one developer's Okta access token from the claims it carries to the LiteLLM user record, team membership, model access and spend limits that follow. Read each row as a decision point: the claim names and group values are set in your own Okta authorization server, so confirm them there before you map anything in LiteLLM. The main takeaway is that budgets and rate limits only attach to a person or team once the identity field LiteLLM reads is stable and unique.

Mapping elementWhat it doesWhat to confirm in your setup
Subject claim (sub)Usually the stable Okta user identifier that identifies the developer in the token.Confirm which claim your authorization server puts in the token and whether LiteLLM's JWT settings read it as the user ID.
Email or username claimA human-readable identity that is easier to match against spend reports and access reviews.Confirm the claim name, whether it is present in access tokens (not only ID tokens), and that values are unique per person.
Group claimCarries Okta group membership that can drive team assignment and model access in LiteLLM.Confirm the claim is included in access tokens, the group names match your team structure, and nested or large group lists are handled.
LiteLLM user record (user_id_upsert)Created on the first authenticated request, so each developer gets a user record without manual provisioning.Confirm the record key matches the claim you chose, and test that a second login reuses the same record instead of creating a duplicate.
Team membership and model accessMaps identity groups to LiteLLM teams, which determine which models a developer can call.Confirm the mapping from Okta group to LiteLLM team is written down and reviewed, and that removing a user from a group removes model access.
Per-user and per-team budgetsCaps spend for an individual or a team, and records spend against that identity.Confirm budget values, reset periods and who approves temporary increases with your finance and engineering owners before rollout.
TPM and RPM limitsLimit tokens and requests per minute so one developer or script cannot exhaust shared capacity.Confirm limit values per user and per team against your provider quotas, and test them with a representative Claude Code session.

Hardening the Okta-backed gateway

Once developers sign in with Okta, the gateway becomes the single point that decides who reaches which model and what it costs. The cards below cover the secrets, scripts, token lifetimes, network exposure, Enterprise controls and access reviews that keep that point under control.

Protect the master key

LITELLM_MASTER_KEY administers the whole proxy, so it should never reach a developer laptop or a shared config file. It must start with sk- and should live in a secret manager that the proxy reads at startup. Check who can read that secret, rotate it on a schedule you define, and confirm that admin actions are performed with named identities rather than this key.

LiteLLM production guide

Lock down the helper and settings

The apiKeyHelper script and the managed settings file decide which token Claude Code sends and where it sends it. If a developer can edit either one, they can point traffic at another endpoint or swap in a token they do not own. Deploy both through your device management tooling, set them read-only for standard users, and record who changes them through version control.

Keep token lifetimes short

The helper should request fresh Okta tokens rather than caching one for long periods, and the Okta authorization server should issue access tokens with a lifetime your security policy approves. Test what happens when a session ends mid-task, when a developer is removed from a group, and when the laptop sleeps. Confirm that revoked access stops working at the gateway within the window you accept.

Restrict proxy network exposure

Claude Code sends prompts and tokens to the proxy, so the connection must use TLS end to end. Decide whether the proxy is reachable from corporate networks only or from the internet, and place it behind a load balancer or ingress that you control. Confirm that the admin UI is not exposed on the same path as developer traffic, and that the JWKS endpoint the proxy calls is reachable from the proxy itself.

Enterprise controls for access

IP allowlisting and audit logs are Enterprise features, and JWT authentication itself requires an Enterprise license. Before you rely on them, confirm with LiteLLM which controls your license includes and test that an allowlist blocks requests from outside your approved ranges. Audit logs should show which Okta identity made each admin change, so review them as part of routine access reviews.

LiteLLM Enterprise docs

Review model access by team

Okta group membership can map developers to LiteLLM teams, and each team can reach a set of models. Groups tend to grow over time, so a developer added to an engineering group may gain access to expensive or sensitive models they never needed. Review the mapping on a schedule, compare each team's allowed models with the approved list, and remove access that no longer has a business owner.

Why Claude Code gets 401s or no user record

This table lists the failures most often seen when Claude Code authenticates to LiteLLM with an Okta access token, with the cause, the fix and the logs to collect for each. Work down the rows in order, since the first rows are the cheapest to rule out and several later symptoms can look identical from the developer's terminal.

FailureLikely causeFixLogs to collect
401 on every requestThe gateway cannot reach the Okta JWKS URL, so it cannot verify token signaturesConfirm the gateway's network path and egress rules to the Okta JWKS endpoint, then retry from the gateway host itselfProxy startup and auth error lines, outbound connection errors, timestamps of the failed fetch
401 with a valid-looking tokenAudience or issuer in the token does not match the values LiteLLM expectsCompare the aud and iss claims in a decoded token with the JWT settings in the proxy configuration and correct the mismatch on whichever side is wrongDecoded claim values from a test token, the configured audience and issuer, the 401 response body
401 after a working sessionAccess token expired and the apiKeyHelper script did not refresh itCheck the helper's refresh logic and token cache location, run the helper by hand, and confirm Claude Code calls it again after expiryHelper script output and exit status, token expiry time, timestamps of first failed request
Proxy rejects JWT auth entirelyJWT authentication is an Enterprise feature and the deployment runs without a valid Enterprise licenseConfirm the license status with LiteLLM before rollout and check startup logs for license messagesStartup log license lines, proxy version, configuration file in use
Request authenticates but no user record appearsuser_id_upsert is disabled, so the gateway does not create users on first requestEnable user_id_upsert in the proxy configuration and send a new test request to confirm the user is createdDatabase user table query results, proxy request log entries for the test user
403 or budget error for a valid developerPer-user or team budget is exhausted, or the key or user is restricted to models Claude Code does not requestReview spend against the budget, raise or reset the limit if approved, and align the allowed model list with the model names Claude Code sendsBudget and spend records for the user, model restriction settings, the exact model name in the failing request
Works for some developers onlyDifferent identity groups, token issuers or Okta app assignments across usersConfirm each affected user is assigned to the Okta application and that their tokens come from the same issuerToken issuer claim per user, Okta assignment status, authentication log lines per user ID

Adapting the setup for Entra ID or Keycloak

The Okta pattern carries over to any OIDC provider that issues JWT access tokens. According to the LiteLLM tutorial, Azure AD, Keycloak and Auth0 work the same way, so moving to Entra ID or Keycloak is mostly a matter of changing the provider-specific values: the issuer, the JWKS URL, the expected audience and the claim names LiteLLM reads for the user ID, email and team or group membership. The apiKeyHelper script, the token flow into Claude Code and the user_id_upsert behavior stay as they are. Before changing anything, confirm each provider's token claims by decoding a real access token from your own tenant or realm, and check them against the LiteLLM Claude Code Okta tutorial. Entra ID access tokens and Keycloak tokens do not always place identity and group data in the same claims as Okta, and a wrong claim name usually surfaces as users who authenticate but land without the intended team or budget.

Keycloak is open source under the Apache 2.0 license and supports OpenID Connect, OAuth 2.0 and SAML 2.0. Choosing it makes the identity provider part of your platform, so its operations must be planned alongside the gateway. Keycloak's supported production databases include PostgreSQL 14 to 18, and the development file database is not suitable for production. Its documented high availability designs both depend on a synchronously replicated database, so confirm the database topology, backup and recovery approach, and upgrade cadence with your team before the gateway depends on it. Note that the LiteLLM tutorial presents JWT authentication as an Enterprise feature, so confirm licensing with LiteLLM alongside the identity provider choice.

Ask the people who run your identity platform to own the claim mapping and the token lifetime decisions for whichever provider you choose. Test at least one developer login, one revoked or disabled user and one user outside the intended group before rollout. Record the issuer, JWKS URL, audience and claim names in version-controlled configuration so a provider change or upgrade can be reviewed like any other change. Where Keycloak is the provider, plan its upgrades against the release and migration guidance on the Keycloak upgrading guide rather than treating the identity server as a fixed component.

Questions buyers ask before configuring Okta JWT on LiteLLM

Does Okta JWT authentication on LiteLLM require an Enterprise license?

Yes. JWT authentication with identity provider tokens requires a LiteLLM Enterprise license, according to LiteLLM's Claude Code Okta tutorial. The open source proxy supports SSO sign-in to the admin UI with Okta, but per-developer token validation for Claude Code is an Enterprise feature. Confirm the current license terms and quote with the LiteLLM vendor before you plan the rollout, because the free SSO allowance for the admin UI (up to 5 users from v1.76.0) does not cover developer token validation for a full engineering team.

What drives the effort and cost of this setup?

The main drivers are the number of teams and the claims you need to map, the state of your Okta configuration, and how many developer devices must receive the apiKeyHelper script. Each team that needs its own budget or model access adds mapping work. Okta tenant changes such as custom authorization servers, access token claims and group membership affect the build. Device rollout scales with headcount and the device management tools you already run. Ask any partner for a written scope that lists each of these items separately, because the Enterprise license is a recurring software cost while configuration work is typically one-time.

How long does the implementation take?

Duration depends on scope, so no fixed figure applies. The timeline is driven by how many identity configurations you need, whether Okta access token claims are already defined, how many teams and budgets must be mapped, and how many developer machines need the helper script and managed settings. A fixed-scope engagement should give you a timeline in writing, tied to the deliverables and the client inputs it depends on. Ask for the assumptions behind the schedule, especially who approves Okta changes and how long your change process takes.

What must our team provide before the work starts?

Plan for three inputs. First, Okta admin access to create or review the authorization server, the application or API, and the access token claims that LiteLLM will read. Second, claim decisions: which claim identifies the user, which group or attribute maps to a team, and how user IDs will be created with user_id_upsert. Third, device management: how the apiKeyHelper script and Claude Code settings reach developer laptops, and who supports them. Name an owner for each input in the written scope, since delays on any one of them move the whole schedule.

Can our engineers do this themselves using the LiteLLM tutorial?

Often yes, if you have engineers comfortable with Okta, JWKS validation and the LiteLLM proxy configuration. LiteLLM publishes a Claude Code with Okta SSO tutorial that walks through the apiKeyHelper script, token validation and automatic user creation. The harder parts are usually outside the tutorial: hardening the proxy, running PostgreSQL and Redis correctly for your scale, aligning claims with your access model, testing failure modes such as expired tokens, and rolling the script out to every device. Decide which of these your team owns, and whether you need outside review before production use.

Does using Entra ID or Keycloak change the work?

The pattern stays the same, but the details change. LiteLLM's tutorial notes that any OIDC provider issuing JWT access tokens, such as Azure AD, Keycloak or Auth0, works the same way. What changes is the identity provider side: the authorization server or tenant settings, the claim names, the group mapping and the JWKS endpoint you point LiteLLM at. Keycloak is open source under Apache 2.0 and is a self-managed option if you need to keep identity in your own infrastructure. Confirm the exact token claims each provider issues before you estimate work, because claim mapping is where most of the adaptation effort sits.

What breaks most often, and what should we check first?

Most failures trace to token issues rather than the proxy itself. Check that the access token audience matches what LiteLLM expects, that the JWKS URL is reachable from the proxy, and that the token lifetime and the apiKeyHelper refresh logic work together, so developers are not interrupted mid-session. Next, verify that user_id_upsert creates users with the right team and budget, since wrong claim mapping gives people the wrong access. Test with a revoked or expired token and confirm the request is rejected. Keep logs of these tests as part of your change record.

How to test the Okta login path before rollout

Before any developer depends on the Okta login path, run a scripted set of test cases that prove LiteLLM accepts only valid Okta tokens and attributes every request to the right person. Start with a pilot user in a group you control. Confirm that a fresh token issued through the apiKeyHelper script is accepted, that LiteLLM creates the user record on first request through user_id_upsert, and that a second request reuses the same record rather than creating a duplicate. Then send an expired token and a tampered token (change one character in the payload or signature). Both should be rejected with an authentication error. Record the exact error text and the LiteLLM log line for each, because your on-call team will see the same signals in production.

Next, test the identity lifecycle and the controls that sit on top of it. Remove the pilot user from the Okta group or deactivate the account, wait for the access token to expire, and confirm that new requests fail. Be aware that an already-issued token stays valid until it expires, so the timing of your token lifetime in Okta is part of the test result, not a detail to skip. Then, with a pilot user, verify model restrictions by requesting a model the user should not reach, and verify budget enforcement by setting a deliberately low per-user budget in a non-production environment and confirming the request is blocked once the limit is reached. Confirm the budget settings against the LiteLLM virtual keys documentation for your version before you rely on them.

Finally, confirm that spend lands under the correct identity. Make a small number of requests as two different pilot users, then compare the per-user spend in the LiteLLM admin views and logs with the requests you made. Keep the LiteLLM master key for administration only: use it to create teams and set policy, never to run developer traffic, and store it in a secret manager. If the master key appears in a developer's environment during testing, rotate it and treat the test as failed until you have traced the exposure.

How DeployOpen scopes and delivers this integration

DeployOpen plans and builds the Claude Code and Okta JWT path on LiteLLM inside your own infrastructure, with the identity, gateway and developer machine settings written down before anything is rolled out. Each step is agreed in writing, tested against your Okta tenant and handed over with the runbooks your team needs to operate it.

How we scope

  • Written scope names the Okta authorization server, token audience, and the claims LiteLLM will map to users and teams.
  • We confirm the LiteLLM Enterprise license needed for JWT authentication before build work starts.
  • Scope records the developer machine rollout method, the apiKeyHelper script location and the Claude Code version to standardize on.

How we build

  • We configure the apiKeyHelper script to fetch and refresh Okta tokens without storing long-lived credentials on developer laptops.
  • We set up JWKS validation in LiteLLM against your Okta keys and test rejection of expired, wrong-audience and unsigned tokens.
  • We configure user_id_upsert so first-time developers are created in LiteLLM with the budgets and model access your policy defines.

How we hand over

  • You receive the configuration, the apiKeyHelper script and the JWT claim mapping documented for your own engineers to review.
  • Test results cover successful sign-in, token refresh, budget enforcement and per-user spend records in the logs.
  • We document the adaptation steps for Microsoft Entra ID or Keycloak so the same pattern can be reused if your identity provider changes.

How we support

  • Ongoing support, LiteLLM upgrades and continuous testing are available as retainers after handover.
  • Retainers can cover re-testing when Okta, Claude Code or LiteLLM releases change token handling or the JWT path.
  • Ask for a quote that separates the one-time build from any recurring support, so your budget reflects both.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.