Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 12. Configuring API key authentication


Configure API key for authentication with Red Hat AI Inference.

Expand
Table 12.1. API endpoint authentication
EndpointAuthentication required

/v1/chat/completions

Yes

/v1/completions

Yes

/v1/embeddings

Yes

/health

No

/ping

No

Prerequisites

  • You have installed Podman or Docker.
  • You have installed the NVIDIA Container Toolkit to enable Podman access to GPUs.
  • You are logged in as a user with sudo access.
  • You have access to registry.redhat.io and have logged in.
  • You have a Hugging Face account and have generated a Hugging Face access token.

Procedure

  1. Start the inference server with API key authentication:

    $ podman run --rm -it \
      --device nvidia.com/gpu=all \
      --security-opt=label=disable \
      --shm-size=4GB -p 8000:8000 \
      -v ./rhaii-cache:/opt/app-root/src/.cache \
      registry.redhat.io/rhaii/vllm-cuda-rhel9:3.4.0 \
      --model RedHatAI/Llama-3.2-1B-Instruct-FP8 \
      --api-key "<your_api_key>"
  2. Send a request with the API key in the Authorization header:

    $ curl http://localhost:8000/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer <your_api_key>" \
      -d '{
        "model": "RedHatAI/Llama-3.2-1B-Instruct-FP8",
        "messages": [{"role": "user", "content": "Hello!"}]
      }'

Verification

  • A successful request returns a 200 OK response with the model output.
  • A request without the API key returns 401 Unauthorized.
  • A request with an invalid API key returns 403 Forbidden.
Important

API key authentication provides basic protection for your API endpoints. It is not a comprehensive security solution. For production deployments, consider enabling SSL/TLS encryption using the --ssl-keyfile, --ssl-certfile, and --ssl-ca-certs server arguments. Do not hard code API keys in source code. Use environment variables or a secrets management solution.

Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat Dokumentation

Legal Notice

Theme

© 2026 Red Hat
Nach oben