{"id":9786,"library":"google-gax","title":"Google API Extensions (GAX)","description":"Google API Extensions (GAX) was an early Python library for generating client libraries for Google APIs. It provided common features like retries, authentication, and request handling. This project is now deprecated (since version 0.16.0) and has been wholly replaced by `google-api-core`. New development should use `google-api-core` and its associated client libraries.","status":"deprecated","version":"0.16.0","language":"en","source_language":"en","source_url":"https://github.com/googleapis/gax-python","tags":["google","api","deprecated","client-libraries","retry"],"install":[{"cmd":"pip install google-gax","lang":"bash","label":"Install google-gax (Deprecated)"},{"cmd":"pip install google-api-core","lang":"bash","label":"Install its replacement: google-api-core"}],"dependencies":[{"reason":"This library is the official replacement for google-gax and provides the same, improved functionality.","package":"google-api-core","optional":false}],"imports":[{"note":"Replaced by api_callable in google-api-core for GAX configuration.","wrong":"from google.gax import api_callable","symbol":"api_callable","correct":"from google.api_core.gapic_v1 import api_callable"},{"note":"Replaced by config in google-api-core for GAX configuration.","wrong":"from google.gax import config","symbol":"config","correct":"from google.api_core.gapic_v1 import config"},{"note":"Retry logic moved directly into google-api-core.","wrong":"from google.gax import retry","symbol":"retry","correct":"from google.api_core import retry"}],"quickstart":{"code":"from google.api_core.retry import Retry\nfrom google.api_core.exceptions import ServiceUnavailable\nimport time\n\n# --- This example demonstrates google-api-core, the replacement for google-gax ---\n\n_failure_count = 0\ndef might_fail_api_call():\n    \"\"\"A dummy function simulating an API call that fails intermittently.\"\"\"\n    global _failure_count\n    _failure_count += 1\n    if _failure_count < 3:\n        print(f\"Attempt {_failure_count}: API call failing with ServiceUnavailable...\")\n        raise ServiceUnavailable(\"Backend service is temporarily unavailable.\")\n    print(f\"Attempt {_failure_count}: API call succeeded!\")\n    return \"Data Retrieved!\"\n\n# Define a retry policy for ServiceUnavailable errors\n# This replaces similar functionality found in google-gax.retry\nretry_policy = Retry(\n    predicate=Retry.if_exception_type(ServiceUnavailable),\n    initial=1.0,  # Initial delay of 1 second\n    multiplier=2.0, # Double delay each time\n    maximum=10.0, # Max delay of 10 seconds\n    deadline=30.0 # Total operation timeout of 30 seconds\n)\n\ntry:\n    print(\"\\n--- Calling the API with google-api-core retry policy ---\")\n    result = retry_policy(might_fail_api_call)\n    print(f\"Final Result: {result}\")\nexcept Exception as e:\n    print(f\"Operation failed after retries: {e}\")\n\n# For actual Google Cloud client libraries, this retry mechanism\n# is often automatically configured and used internally.","lang":"python","description":"This quickstart demonstrates how to use `google-api-core`'s `Retry` mechanism, which directly replaces core functionality previously found in `google-gax`. It shows a simple example of retrying an intermittently failing function, illustrating the correct modern approach for handling transient errors in Google Cloud client libraries. **Note:** Direct usage of `google-gax` is deprecated and not recommended for new projects."},"warnings":[{"fix":"Migrate all existing code to use `google-api-core`. Update imports and adjust configuration settings as documented in `google-api-core`'s official documentation. See problem section for specific import changes.","message":"The `google-gax` library is officially deprecated as of version 0.16.0 and will no longer receive updates or support. All functionality has been migrated to `google-api-core`.","severity":"breaking","affected_versions":"0.16.0 and later"},{"fix":"Always use `google-api-core` and the latest versions of Google Cloud client libraries. Review your project dependencies to ensure `google-gax` is not implicitly pulled in by older transitive dependencies.","message":"Using `google-gax` in new projects or alongside modern Google Cloud client libraries can lead to dependency conflicts, outdated behavior, and lack of support for new features or security patches.","severity":"gotcha","affected_versions":"All versions, especially when mixed with newer libraries."}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"If you intend to use the deprecated `google-gax`, install it via `pip install google-gax`. However, the recommended fix is to migrate your code to use `google-api-core` and its relevant modules instead (e.g., `from google.api_core import retry`).","cause":"The `google-gax` library is not installed, or you are trying to import it in an environment where it's not present or shadowed.","error":"ModuleNotFoundError: No module named 'google.gax'"},{"fix":"This is an informative warning indicating you should migrate. Update your code to use `google-api-core` for equivalent functionalities. For instance, `from google.gax import retry` should become `from google.api_core import retry`.","cause":"Your code is still using `google-gax` imports or functionality, triggering the official deprecation warning.","error":"DeprecationWarning: google-gax is deprecated and will no longer be developed. It has been wholly replaced by google-api-core."},{"fix":"Ensure you are importing from the correct, modern library. Replace `from google.gax import config` with `from google.api_core.gapic_v1 import config` and similarly for other GAX-specific components. Refer to the `google-api-core` documentation for updated import paths.","cause":"You are attempting to access a module or attribute from `google.gax` that either never existed, was moved, or you are running an environment where `google-gax` is not correctly installed/imported, potentially conflicting with parts of `google-api-core`.","error":"AttributeError: module 'google.gax' has no attribute 'config' (or 'api_callable', 'operations_client', etc.)"}]}