Skip to main content

Overview

Hugging Face exposes two deployment targets that Cognisafe can intercept:
  • Text Generation Inference (TGI) — self-hosted inference server, OpenAI-compatible API on /v1/
  • Inference Endpoints — managed hosting on HF infrastructure, also OpenAI-compatible
Both speak the same protocol as the Cognisafe proxy, so the setup is identical — point UPSTREAM_URL at your TGI instance or Inference Endpoint URL.

Text Generation Inference (self-hosted)

TGI exposes an OpenAI-compatible endpoint at http://<host>:8080/v1 by default.

Docker deployment

Proxy configuration

SDK setup

TGI serves one model at a time. The model field in the request is ignored — TGI always responds with the model it was started with.

Hugging Face Inference Endpoints (managed)

Inference Endpoints expose a URL like https://xyz.us-east-1.aws.endpoints.huggingface.cloud.

Proxy configuration

SDK setup

The Cognisafe proxy forwards the Authorization: Bearer hf_... header to the Inference Endpoint unchanged.

Air-gapped scoring

In air-gapped environments, point the safety worker’s scoring model at a local TGI instance:
For scoring, run a separate TGI instance with a dedicated safety-focused model (e.g. meta-llama/Llama-Guard-3-8B) rather than your production model. Llama Guard is specifically trained for safety classification and is significantly more accurate than general-purpose models for OWASP LLM scoring.

Kubernetes deployment

Set UPSTREAM_URL=http://tgi.default.svc.cluster.local:8080 on the Cognisafe proxy deployment.