Skip to main content
The hiddenlayer-apim CLI deploys HiddenLayer policy fragments to Azure API Management (APIM) and applies those fragments to APIs that proxy LLM traffic. Use the CLI when you want a repeatable way to add Runtime Security guardrails without hand-editing large APIM policy XML blocks. The CLI can protect requests before they reach the model, responses before they return to users, or both. It supports package-based deployment so you can choose the evaluation flow that matches your architecture. Deploy v2-request-evals for inbound-only protection, v2-response-evals for outbound-only protection, or both packages for full request and response guardrails.

How It Works

  1. hiddenlayer-apim deploy creates HiddenLayer named values and policy fragments in your APIM instance.
  2. hiddenlayer-apim apply <api-id> reads the target API policy and injects <include-fragment> references.
  3. APIM calls HiddenLayer evaluation endpoints during inbound and/or outbound processing.
  4. HiddenLayer returns a provider-shaped payload. APIM forwards the payload, redacted payload, or block response based on the policy decision.

Fragment Packages

Recommended pathUse the v2 packages for new APIM guardrails deployments. The v2 endpoints accept provider-native payloads and return provider-shaped payloads, which keeps the APIM policy simpler.

Provider Compatibility

Provider support depends on which package you deploy:
  • v2-request-evals and v2-response-evals forward the original provider request and response bodies to HiddenLayer’s v2 evaluation APIs and use whatever HiddenLayer returns. The APIM fragments do not parse provider-specific fields. Provider support is therefore whatever HiddenLayer’s /detection/v2/request-evaluations and /detection/v2/response-evaluations endpoints accept (OpenAI, Azure OpenAI, Anthropic Messages, and additional providers as they are added). Use the HL-Provider-Id request header to override auto-detection and HL-Runtime-Edge-Provider to label the edge integration.
  • v1-interactions is OpenAI chat-completions shaped. It reads OpenAI request fields (model, messages) and OpenAI response fields (choices[].message), and its block response is an OpenAI chat-completion payload. Use it for Azure OpenAI / OpenAI chat-completions APIs.
See Fragment packages for the full per-package breakdown.