code: def api_server(api_services, **kwargs):
    if 'protocols' in kwargs:
      raise TypeError("__init__() got an unexpected keyword argument 'protocols'")
    from . import _logger as endpoints_logger
    from . import __version__ as endpoints_version
    endpoints_logger.info('Initializing Endpoints Framework version %s', endpoints_version)
    apis_app = _ApiServer(api_services, **kwargs)
    dispatcher = endpoints_dispatcher.EndpointsDispatcherMiddleware(apis_app)
    service_name = os.environ.get('ENDPOINTS_SERVICE_NAME')
    if not service_name:
      _logger.warn('Did not specify the ENDPOINTS_SERVICE_NAME environment'
                   ' variable so service control is disabled.  Please specify'
                   ' the name of service in ENDPOINTS_SERVICE_NAME to enable'
                   ' it.')
      return dispatcher
    if control_wsgi.running_on_devserver():
      _logger.warn('Running on local devserver, so service control is disabled.')
      return dispatcher
    from endpoints_management import _logger as management_logger
    from endpoints_management import __version__ as management_version
    management_logger.info('Initializing Endpoints Management Framework version %s', management_version)
    controller = control_client.Loaders.DEFAULT.load(service_name)
    control_client.use_gae_thread()
    controller.start()
    return control_wsgi.add_all(
        dispatcher,
        app_identity.get_application_id(),
        controller)