The Gemini API allows developers to build generative AI applications using Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can generalize and seamlessly understand, operate across, and combine different types of information including language, images, audio, video, and code. You can use the Gemini API for use cases like reasoning across text and images, content generation, dialogue agents, summarization and classification systems, and more.
While this library isGA, please note that the Google Cloud C++ client libraries donotfollowSemantic Versioning.
Quickstart
The following shows the code that you'll run in thegoogle/cloud/generativelanguage/quickstart/directory, which should give you a taste of the Generative Language API C++ client library API.
This library offers multiple*Clientclasses, which are listed below. Each one of these classes exposes all the RPCs for a service as member functions of the class. This library groups multiple services because they are part of the same product or are often used together. A typical example may be the administrative and data plane operations for a single product.
The library also has other classes that provide helpers, configuration parameters, and infrastructure to mock the*Clientclasses when testing your application.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis is an idiomatic C++ client library for the Generative Language API, which allows developers to use Gemini models for building generative AI applications.\u003c/p\u003e\n"],["\u003cp\u003eThe Gemini API supports various use cases, including reasoning across different data types, content generation, dialogue agents, summarization, and classification systems.\u003c/p\u003e\n"],["\u003cp\u003eThe library is currently in GA status, but it does not follow Semantic Versioning guidelines, meaning version changes may not follow a predictable pattern.\u003c/p\u003e\n"],["\u003cp\u003eThe library offers \u003ccode\u003e*Client\u003c/code\u003e classes, such as \u003ccode\u003eGenerativeServiceClient\u003c/code\u003e and \u003ccode\u003eModelServiceClient\u003c/code\u003e, that expose RPCs for different services within the same product.\u003c/p\u003e\n"],["\u003cp\u003eAdditional resources are available for error handling, overriding default endpoints and authentication credentials, modifying retry policies, and configuring behavior using environment variables.\u003c/p\u003e\n"]]],[],null,["Generative Language API C++ Client Library\n==========================================\n\nAn idiomatic C++ client library for the [Generative Language API](https://ai.google.dev/docs).\n\nThe Gemini API allows developers to build generative AI applications using Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can generalize and seamlessly understand, operate across, and combine different types of information including language, images, audio, video, and code. You can use the Gemini API for use cases like reasoning across text and images, content generation, dialogue agents, summarization and classification systems, and more.\n\nWhile this library is **GA** , please note that the Google Cloud C++ client libraries do **not** follow [Semantic Versioning](https://semver.org/).\n\n### Quickstart\n\nThe following shows the code that you'll run in the `google/cloud/generativelanguage/quickstart/` directory, which should give you a taste of the Generative Language API C++ client library API. \n\n #include \"google/cloud/generativelanguage/v1/model_client.h\"\n #include \"google/cloud/location.h\"\n #include \u003ciostream\u003e\n\n int main(int argc, char* argv[]) try {\n if (argc != 1) {\n std::cerr \u003c\u003c \"Usage: \" \u003c\u003c argv[0] \u003c\u003c \"\\n\";\n return 1;\n }\n\n namespace generativelanguage = ::google::cloud::generativelanguage_v1;\n auto client = generativelanguage::ModelServiceClient(\n generativelanguage::MakeModelServiceConnection());\n\n for (auto r : client.ListModels({})) {\n if (!r) throw std::move(r).status();\n std::cout \u003c\u003c r-\u003eDebugString() \u003c\u003c \"\\n\";\n }\n\n return 0;\n } catch (google::cloud::Status const& status) {\n std::cerr \u003c\u003c \"google::cloud::Status thrown: \" \u003c\u003c status \u003c\u003c \"\\n\";\n return 1;\n }\n\n### Main classes\n\nThis library offers multiple `*Client` classes, which are listed below. Each one of these classes exposes all the RPCs for a service as member functions of the class. This library groups multiple services because they are part of the same product or are often used together. A typical example may be the administrative and data plane operations for a single product.\n\nThe library also has other classes that provide helpers, configuration parameters, and infrastructure to mock the `*Client` classes when testing your application.\n\n- [`generativelanguage_v1::GenerativeServiceClient`](/cpp/docs/reference/generativelanguage/latest/classgoogle_1_1cloud_1_1generativelanguage__v1_1_1GenerativeServiceClient)\n- [`generativelanguage_v1::ModelServiceClient`](/cpp/docs/reference/generativelanguage/latest/classgoogle_1_1cloud_1_1generativelanguage__v1_1_1ModelServiceClient)\n\n### More Information\n\n- [Error Handling](https://cloud.google.com/cpp/docs/reference/common/latest/common-error-handling.html) - describes how the library reports errors.\n- [How to Override the Default Endpoint](/cpp/docs/reference/generativelanguage/latest/generativelanguage-override-endpoint) - describes how to override the default endpoint.\n- [How to Override the Authentication Credentials](/cpp/docs/reference/generativelanguage/latest/generativelanguage-override-authentication) - describes how to change the authentication credentials used by the library.\n- [Override Retry, Backoff, and Idempotency Policies](/cpp/docs/reference/generativelanguage/latest/generativelanguage-override-retry) - describes how to change the default retry policies.\n- [Environment Variables](/cpp/docs/reference/generativelanguage/latest/generativelanguage-env) - describes environment variables that can configure the behavior of the library."]]