MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/optillm / check_api_key

Function check_api_key

optillm/server.py:684–695  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

682# Optional API key configuration to secure the proxy
683@app.before_request
684def check_api_key():
685 if server_config['optillm_api_key']:
686 if request.path == "/health":
687 return
688
689 auth_header = request.headers.get('Authorization')
690 if not auth_header or not auth_header.startswith('Bearer '):
691 return jsonify({"error": "Invalid Authorization header. Expected format: 'Authorization: Bearer YOUR_API_KEY'"}), 401
692
693 client_key = auth_header.split('Bearer ', 1)[1].strip()
694 if not secrets.compare_digest(client_key, server_config['optillm_api_key']):
695 return jsonify({"error": "Invalid API key"}), 401
696
697@app.route('/v1/chat/completions', methods=['POST'])
698def proxy():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected