AuthN/Z
Know who is calling your models, and control what they can use.
AuthN/Z secures AI APIs with centralized authentication and authorization in Agent Router (EAIG). Every request is authenticated with API keys or JWTs from your identity provider, then authorized against role, team, application, and model-level policies.
What AuthN/Z does
The plugin authenticates each caller using API keys or JWTs issued by your identity provider, extracts identity claims such as user, team, and application, and evaluates authorization policies that decide which routes, models, and providers that identity may use.
Shared provider API keys copied into many services make it impossible to know who is using which model, to revoke access for one team, or to stop an internal tool from calling an expensive or unapproved model. Access control ends up scattered across application code.
AuthN/Z is the first policy Agent Router applies to a request. The identity it establishes is then used by every other plugin, including quotas, guardrails, and routing, so access and governance share one source of truth.
The request and response flow
- 1Request
Caller obtains credentials
A user or service signs in with your identity provider (such as Okta, Microsoft Entra ID, or Keycloak) and receives a JWT, or uses an issued API key.
- 2Request
Authentication at Agent Router
Agent Router validates the JWT signature, issuer, audience, and expiry against the provider's JWKS, or verifies the API key.
- 3Control
Authorization
Claims such as roles, groups, team, and application are evaluated against RBAC and model-level policies for the requested route and model.
- 4Control
Allow or deny
Unauthenticated requests get HTTP 401 and unauthorized ones get HTTP 403, before any tokens are spent.
- 5Response
Forward with identity context
Authorized requests are routed to the model with provider credentials injected by the gateway, and identity is attached to logs and metrics.
AuthN/Z in Agent Router
Identity is verified and authorized at the gateway, so only permitted callers reach approved models.
Built for production AI traffic
JWT validation
Verify signature, issuer, audience, and expiry against your identity provider's JWKS endpoint.
API key management
Issue scoped keys per application or partner, rotate them, and revoke one without affecting others.
Role-based access control
Map identity-provider roles and groups to permissions on routes, models, and providers.
Model-level permissions
Allow a team to use approved models only, and reserve premium or fine-tuned models for specific roles.
Credential isolation
Provider API keys stay in the gateway. Applications never see or store them.
Identity-aware audit
Every request is logged with user, team, application, and model for security investigations.
Engineering and business outcomes
No shared provider keys
Applications authenticate to Agent Router, and provider credentials never leave the gateway.
Least-privilege model access
Teams can use only the models they are approved for, enforced on every request.
Instant revocation
Disable a key, a role, or a team centrally and access stops everywhere at once.
Attributable usage
Every model call is tied to a verified identity, supporting audit and incident response.
Who can use what
Illustrative policies an enterprise might enforce with AuthN/Z in Agent Router.
| Caller | Identity | Allowed | Denied | Result |
|---|---|---|---|---|
| Support assistant service | API key, app=support-bot | GPT-4o mini, Claude Haiku | Premium reasoning models | 403 on premium models |
| Engineering employees | JWT, group=engineering | Claude Sonnet, GPT-4o, code models | Fine-tuned finance models | Allowed within engineering routes |
| Finance analysts | JWT, role=finance-analyst | Private fine-tuned finance model | Public external providers | Routed to private model only |
| Partner integration | API key, tenant=partner-x | Partner route, one model | All internal routes | 403 outside partner route |
| Expired or unsigned token | Invalid JWT | Nothing | Everything | 401 before any model call |
Where enterprises use AuthN/Z
Replacing shared provider keys
Move from one OpenAI key in every service to per-application identities with centralized provider credentials.
SSO for internal AI tools
Employees access copilots with corporate SSO, and access follows their identity-provider group membership.
Partner and customer API access
Give external partners scoped API keys limited to specific routes and models.
Protecting sensitive models
Restrict fine-tuned models trained on confidential data to the roles that are cleared to use them.
JWT authentication with model-level RBAC
- JWT issuerIdentity provider whose tokens Agent Router accepts.
- https://login.acme.com (Okta)
- AudienceTokens must be issued for Agent Router to be accepted.
- agent-router
- Signing keysWhere Agent Router fetches keys to verify token signatures.
- Identity provider JWKS endpoint
- API keysAlternative credentials for services and partners without SSO.
- Scoped keys per partner or service
- Default actionRequests that match no rule are rejected.
- Deny
- Access rulesWhich roles, groups, or keys may use which routes and models.
- engineering → Claude Sonnet, GPT-4o
- Claims forwardedIdentity details passed on for quotas, routing, and logs.
- groups → x-user-groups
Illustrative example. Settings and values show what can be configured and are not exact configuration syntax.
How it fits your AI platform
- 01
Identity team
Manages users, groups, and service identities in the enterprise identity provider.
- 02
Platform & security teams
Define which roles, teams, and applications may use which routes and models.
- 03
Developers & applications
Authenticate with SSO tokens or scoped API keys and call Agent Router.
- 04
Agent Router
Validates identity, enforces authorization, and injects provider credentials.
- 05
Models & providers
Receive only authenticated, authorized traffic from a single trusted gateway.
Secure every AI API with one identity layer
IMESH can help you connect your identity provider, design RBAC and model permissions, and roll out AuthN/Z on Agent Router (EAIG).
