← All Plugins
AI Security

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

What it 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.

The enterprise problem

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.

Where it fits in Agent Router

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.

How It Works

The request and response flow

  1. 1
    Request

    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.

  2. 2
    Request

    Authentication at Agent Router

    Agent Router validates the JWT signature, issuer, audience, and expiry against the provider's JWKS, or verifies the API key.

  3. 3
    Control

    Authorization

    Claims such as roles, groups, team, and application are evaluated against RBAC and model-level policies for the requested route and model.

  4. 4
    Control

    Allow or deny

    Unauthenticated requests get HTTP 401 and unauthorized ones get HTTP 403, before any tokens are spent.

  5. 5
    Response

    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.

Architecture

AuthN/Z in Agent Router

AuthN/Z architecture: Employees, Internal services, AI agents, Partner apps send requests to Agent Router, which applies Authentication, then Authorization, then Policy enforcement, and connects to Identity provider, Approved models, Denied, Audit log.Identity providerOkta · Entra ID · KeycloakUser / appSSO or API key1. Sign in, get JWT2. Request + JWTAgent RouterAuthN/ZJWKS keysAuthenticateVerify JWT / keyAuthorizeRBAC · claimsPolicyModel permissionsGPT-4oEngineering: allowed✓Claude SonnetEngineering: allowed✓Finance FT modelFinance analysts only✕401 / 403Denied before model call
Callers
EmployeesInternal servicesAI agentsPartner apps
Agent Router
AuthN/Z plugin
Authentication
Authorization
Policy enforcement
Access
Identity providerJWKS · OIDC · API keys
Approved modelsAuthorized → forward
Denied401 / 403 before model call
Audit logWho · what model · when

Identity is verified and authorized at the gateway, so only permitted callers reach approved models.

Key Features

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.

Benefits

Engineering and business outcomes

Security

No shared provider keys

Applications authenticate to Agent Router, and provider credentials never leave the gateway.

Governance

Least-privilege model access

Teams can use only the models they are approved for, enforced on every request.

Operational efficiency

Instant revocation

Disable a key, a role, or a team centrally and access stops everywhere at once.

Compliance

Attributable usage

Every model call is tied to a verified identity, supporting audit and incident response.

Access-Control Scenarios

Who can use what

Illustrative policies an enterprise might enforce with AuthN/Z in Agent Router.

CallerIdentityAllowedDeniedResult
Support assistant serviceAPI key, app=support-botGPT-4o mini, Claude HaikuPremium reasoning models403 on premium models
Engineering employeesJWT, group=engineeringClaude Sonnet, GPT-4o, code modelsFine-tuned finance modelsAllowed within engineering routes
Finance analystsJWT, role=finance-analystPrivate fine-tuned finance modelPublic external providersRouted to private model only
Partner integrationAPI key, tenant=partner-xPartner route, one modelAll internal routes403 outside partner route
Expired or unsigned tokenInvalid JWTNothingEverything401 before any model call
Use Cases

Where enterprises use AuthN/Z

01

Replacing shared provider keys

Move from one OpenAI key in every service to per-application identities with centralized provider credentials.

02

SSO for internal AI tools

Employees access copilots with corporate SSO, and access follows their identity-provider group membership.

03

Partner and customer API access

Give external partners scoped API keys limited to specific routes and models.

04

Protecting sensitive models

Restrict fine-tuned models trained on confidential data to the roles that are cleared to use them.

Configuration

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.

Enterprise Workflow

How it fits your AI platform

  1. 01

    Identity team

    Manages users, groups, and service identities in the enterprise identity provider.

  2. 02

    Platform & security teams

    Define which roles, teams, and applications may use which routes and models.

  3. 03

    Developers & applications

    Authenticate with SSO tokens or scoped API keys and call Agent Router.

  4. 04

    Agent Router

    Validates identity, enforces authorization, and injects provider credentials.

  5. 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).