MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / authenticate

Function authenticate

llama_cpp/server/app.py:241–258  ·  view source on GitHub ↗
(
    settings: Settings = Depends(get_server_settings),
    authorization: Optional[str] = Depends(bearer_scheme),
)

Source from the content-addressed store, hash-verified

239
240
241async def authenticate(
242 settings: Settings = Depends(get_server_settings),
243 authorization: Optional[str] = Depends(bearer_scheme),
244):
245 # Skip API key check if it's not set in settings
246 if settings.api_key is None:
247 return True
248
249 # check bearer credentials against the api_key
250 if authorization and authorization.credentials == settings.api_key:
251 # api key is valid
252 return authorization.credentials
253
254 # raise http error 401
255 raise HTTPException(
256 status_code=status.HTTP_401_UNAUTHORIZED,
257 detail="Invalid API key",
258 )
259
260
261openai_v1_tag = "OpenAI V1"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…