Registry / gcp / google-cloud-functions

google-cloud-functions

JSON →
library1.24.0pypypi✓ verified 21d ago

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]

pip install google-cloud-functions
INSTALL
IMPORT
SIG · GOOGLE-CLOUD-FUNCT
G
google-cloud-functions
gcppythonv1.24.0
Install
4.5s avg
Import
1545ms
Disk
75MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.24.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 1.804s · 82.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.5s · import 1.286s · 69MB
75MB installed
● package 75MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CloudFunctionsServiceClient
from google.cloud.functions import CloudFunctionsServiceClient
from google.cloud.functions_v2 import CloudFunctionsServiceClient

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]

import functions_framework import os @functions_framework.http def hello_http(request): """HTTP Cloud Function that responds to HTTP requests. Args: request (flask.Request): The request object. Returns: The response text, or any set of values that can be turned into a Response object using `make_response`. """ request_json = request.get_json(silent=True) request_args = request.args # Example of accessing an environment variable set during deployment target_name = os.environ.get('FUNCTION_TARGET_NAME', 'World') name = target_name if request_json and 'name' in request_json: name = request_json['name'] elif request_args and 'name' in request_args: name = request_args['name'] return f'Hello {name}!' # To deploy this function (save as main.py): # gcloud functions deploy hello-http --gen2 --runtime=python312 \ # --region=us-central1 --source=. --entry-point=hello_http --trigger-http \ # --set-env-vars=FUNCTION_TARGET_NAME=Pythonista # To test locally after `pip install functions-framework`: # functions-framework --target hello_http --debug # Then send a request to http://localhost:8080/
Debug
Known issues
breakingMigration 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]
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]
affects: All versions when migrating between generations
breakingPython versions older than 3.9 are no longer supported. Deploying functions with unsupported Python runtimes will fail. [3, 19]
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]
affects: < 1.0.0
gotchaAuthentication 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]
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]
affects: All versions
gotchaPython 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]
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]
affects: All versions
gotchaCloud 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]
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]
affects: All versions (conceptual shift)
Upgrade
Version history
1.24.0latest on PyPI · released Jun 22, 2026
Audit
Dependencies
functions-frameworkrequiredEssential for writing and locally testing Python Google Cloud Functions, and should be included in your function's `requirements.txt`. [4, 6, 8, 11]
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
google-cloud-functions — pip install google-cloud-functions · libregistry