{"id":4555,"library":"google-cloud-functions","title":"Google Cloud Functions Client Library","description":"The `google-cloud-functions` Python client library provides a programmatic interface for managing Google Cloud Functions. Cloud Functions is a scalable, pay-as-you-go Functions-as-a-Service (FaaS) offering that allows you to run event-driven code without managing servers. This library is part of the larger `google-cloud-python` monorepo, with its latest version being 1.23.0, and it requires Python 3.9 or higher. While the monorepo sees frequent updates, this specific client library updates less frequently. [3, 19, 25]","status":"active","version":"1.23.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-functions","tags":["google-cloud","gcp","serverless","functions-as-a-service","faas","cloud-run"],"install":[{"cmd":"pip install google-cloud-functions","lang":"bash","label":"Install the client library"},{"cmd":"pip install functions-framework","lang":"bash","label":"Install Functions Framework (for writing/testing functions)"}],"dependencies":[{"reason":"Essential for writing and locally testing Python Google Cloud Functions, and should be included in your function's `requirements.txt`. [4, 6, 8, 11]","package":"functions-framework","optional":false}],"imports":[{"wrong":"from google.cloud.functions_v2 import CloudFunctionsServiceClient","symbol":"CloudFunctionsServiceClient","correct":"from google.cloud.functions import CloudFunctionsServiceClient"}],"quickstart":{"code":"import functions_framework\nimport os\n\n@functions_framework.http\ndef hello_http(request):\n    \"\"\"HTTP Cloud Function that responds to HTTP requests.\n    Args:\n        request (flask.Request): The request object.\n    Returns:\n        The response text, or any set of values that can be turned into a\n        Response object using `make_response`.\n    \"\"\"\n    request_json = request.get_json(silent=True)\n    request_args = request.args\n\n    # Example of accessing an environment variable set during deployment\n    target_name = os.environ.get('FUNCTION_TARGET_NAME', 'World')\n\n    name = target_name\n    if request_json and 'name' in request_json:\n        name = request_json['name']\n    elif request_args and 'name' in request_args:\n        name = request_args['name']\n\n    return f'Hello {name}!'\n\n# To deploy this function (save as main.py):\n# gcloud functions deploy hello-http --gen2 --runtime=python312 \\\n# --region=us-central1 --source=. --entry-point=hello_http --trigger-http \\\n# --set-env-vars=FUNCTION_TARGET_NAME=Pythonista\n\n# To test locally after `pip install functions-framework`:\n# functions-framework --target hello_http --debug\n# Then send a request to http://localhost:8080/\n","lang":"python","description":"This quickstart demonstrates how to write a simple HTTP-triggered Google Cloud Function using the `functions-framework` library, which is the standard for defining and running Python Cloud Functions. To deploy, save the code as `main.py` and use the `gcloud functions deploy` command. For local testing, install `functions-framework` and run it against your function. [4, 8, 11]"},"warnings":[{"fix":"Review the migration guide for 1st to 2nd Gen functions. This involves updating function signatures, trigger definitions (now Eventarc), and potentially `gcloud` deployment commands. Plan for phased rollout or new deployments. [14, 21]","message":"Migration from Cloud Functions 1st generation to 2nd generation (now often referred to as 'Cloud Run functions') involves significant architectural changes. Direct redeployment of a 1st Gen function as 2nd Gen can break existing triggers due to the shift from native triggers to Eventarc. [14, 21, 29]","severity":"breaking","affected_versions":"All versions when migrating between generations"},{"fix":"Ensure your local development environment and deployed Cloud Function runtimes use Python 3.9 or higher. Update your `runtime` specification in `gcloud functions deploy` if necessary (e.g., `--runtime=python312`). [3, 19]","message":"Python versions older than 3.9 are no longer supported. Deploying functions with unsupported Python runtimes will fail. [3, 19]","severity":"breaking","affected_versions":"< 1.0.0"},{"fix":"Grant the `Cloud Functions Invoker` role to the service account or user invoking the function. For programmatic invocation, use `google.oauth2.id_token.fetch_id_token` to generate an ID token for the target function's URL and include it in the `Authorization: Bearer` header. [16, 20]","message":"Authentication for HTTP-triggered Cloud Functions, especially when invoked programmatically, requires proper IAM permissions (`roles/cloudfunctions.invoker`) for the calling identity and often the use of an Identity Token (ID Token), not just an OAuth Access Token. Unauthenticated invocations must be explicitly enabled during deployment. [15, 16, 20, 26]","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `requirements.txt` for your function's dependencies. If using private packages, refer to Google Cloud documentation for integrating with Artifact Registry or packaging local dependencies. Ensure `functions-framework` is listed. [1, 2, 8]","message":"Python dependencies for Cloud Functions are exclusively managed via a `requirements.txt` file in the root of your function's source directory. Tools like `Pipfile`/`Pipfile.lock` are not supported. For private dependencies or local packages, specific bundling or Artifact Registry configurations are required. The `functions-framework` library should be explicitly listed in `requirements.txt`. [1, 6, 8]","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with the differences between 1st and 2nd generation functions and the features inherited from Cloud Run. When deploying 2nd Gen functions, consider using the `--gen2` flag with `gcloud functions deploy` or directly leveraging Cloud Run deployment commands for finer control. [12, 14, 29]","message":"Cloud Functions (2nd gen) are now referred to as 'Cloud Run functions' due to their underlying infrastructure being Cloud Run. While the `google-cloud-functions` client library can manage both generations, understanding this naming convention and the benefits of 2nd gen (concurrency, longer timeouts, Eventarc integration) is crucial. [12, 14, 29]","severity":"gotcha","affected_versions":"All versions (conceptual shift)"}],"env_vars":null,"search_vec":"'1.23.0':69 '19':91 '25':92 '3':90 '3.9':74 'allow':41 'client':4,12,85 'cloud':2,9,21,23,61,95,105 'cloud-run':104 'code':48 'driven':47 'event':46 'event-driven':45 'faa':38,103 'frequent':81,89 'function':3,10,22,24,34,99 'functions-as-a-servic':33,98 'gcp':96 'go':32 'googl':1,8,20,60,94 'google-cloud':93 'google-cloud-funct':7 'google-cloud-python':59 'higher':76 'interfac':17 'larger':58 'latest':66 'less':88 'librari':5,13,53,86 'manag':19,50 'monorepo':63,79 'offer':39 'part':55 'pay':29 'pay-as-you-go':28 'programmat':16 'provid':14 'python':11,62,73 'requir':72 'run':44,106 'scalabl':27 'see':80 'server':51 'serverless':97 'servic':37,102 'specif':84 'updat':82,87 'version':67 'without':49","created_at":"2026-04-12T13:57:39.321128+00:00","updated_at":"2026-04-16T15:22:12.977043+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.24.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://cloud.google.com/functions","github":"https://github.com/googleapis/google-cloud-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/google-cloud-functions/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["gcp","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-08-30","next_check":"2026-07-30","install_tag":null}}