عند إنشاء تطبيقات باستخدام Gemini API، ننصحك باستخدام حزمة تطوير البرامج (SDK) من Google للذكاء الاصطناعي التوليدي.
هذه هي المكتبات الرسمية الجاهزة للاستخدام التي نطوّرها ونتولّى صيانتها
لأكثر اللغات شيوعًا. وهي متاحة لجميع المستخدمين ويتم استخدامها في جميع مستنداتنا وأمثلتنا الرسمية.
إذا كنت تستخدم Gemini API للمرة الأولى، اتّبِع دليل البدء السريع للبدء.
اللغات المتوافقة والتثبيت
تتوفّر حزمة تطوير البرامج (SDK) من Google للذكاء الاصطناعي التوليدي للغات Python وJavaScript/TypeScript وGo وJava. يمكنك تثبيت مكتبة كل لغة باستخدام أدوات إدارة الحِزم،
أو الانتقال إلى مستودعات GitHub الخاصة بها لمزيد من التفاعل:
بدأنا طرح حزمة Google GenAI SDK، وهي مجموعة جديدة من المكتبات للوصول إلى واجهة Gemini API، في أواخر عام 2024 عندما أطلقنا Gemini 2.0.
واعتبارًا من مايو 2025، أصبحت هذه المكتبات متاحة للجميع على جميع المنصات المتوافقة، وهي المكتبات المقترَحة للوصول إلى Gemini API. وهي تتسم بالثبات، وتتوافق تمامًا مع الاستخدام في بيئة الإنتاج، ويتم صيانتها بشكل نشط. تتيح هذه التطبيقات الوصول إلى أحدث الميزات، كما أنّها تقدّم أفضل أداء عند استخدامها مع Gemini.
إذا كنت تستخدم إحدى مكتباتنا القديمة، ننصحك بشدة بنقل بياناتك حتى تتمكّن من الاستفادة من أحدث الميزات وتحقيق أفضل أداء عند استخدام Gemini. راجِع قسم المكتبات القديمة للحصول على مزيد من المعلومات.
لا تتيح المكتبات القديمة الوصول إلى الميزات الحديثة (مثل Live API وVeo)، وهي في طريقها إلى الإيقاف النهائي. وسيتوقف عن تلقّي التحديثات في 30 تشرين الثاني (نوفمبر) 2025، وستزداد الفجوات في الميزات، وقد لا يتم إصلاح الأخطاء المحتملة.
تختلف حالة توفّر كل مكتبة قديمة، كما هو موضّح بالتفصيل في الجدول التالي:
ملاحظة لمطوّري Java: لم تتوفّر حزمة SDK قديمة للغة Java من Google لواجهة Gemini API، لذا لا يلزم نقل البيانات من مكتبة Google السابقة. يمكنك البدء مباشرةً باستخدام المكتبة الجديدة في قسم اللغات المتوافقة والتثبيت.
نماذج الطلبات لإنشاء الرموز البرمجية
النماذج التوليدية (مثل Gemini وClaude) وبيئات التطوير المتكاملة المستندة إلى الذكاء الاصطناعي (مثل قد ينتج عن استخدام أدوات مثل Cursor رمز لواجهة برمجة تطبيقات Gemini باستخدام مكتبات قديمة أو متوقّفة نهائيًا بسبب تاريخ انتهاء صلاحية بيانات التدريب. لكي يستخدم الرمز البرمجي الذي تم إنشاؤه أحدث المكتبات وأكثرها ملاءمة، قدِّم إرشادات حول الإصدار والاستخدام مباشرةً في الطلبات التي تقدّمها. يمكنك استخدام النماذج أدناه لتقديم السياق اللازم:
تاريخ التعديل الأخير: 2025-08-25 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-25 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Gemini API libraries\n\n\u003cbr /\u003e\n\nWhen building with the Gemini API, we recommend using the **Google GenAI SDK** .\nThese are the official, production-ready libraries that we develop and maintain\nfor the most popular languages. They are in [General Availability](/gemini-api/docs/libraries#new-libraries) and used in all our official\ndocumentation and examples.\n| **Note:** If you're using one of our legacy libraries, we strongly recommend you [migrate](/gemini-api/docs/migrate) to the Google GenAI SDK. Review the [legacy libraries](/gemini-api/docs/libraries#previous-sdks) section for more information.\n\nIf you're new to the Gemini API, follow our [quickstart guide](/gemini-api/docs/quickstart) to get started.\n\nLanguage support and installation\n---------------------------------\n\nThe Google GenAI SDK is available for the Python, JavaScript/TypeScript, Go and\nJava languages. You can install each language's library using package managers,\nor visit their GitHub repos for further engagement: \n\n### Python\n\n- Library: [`google-genai`](https://pypi.org/project/google-genai)\n\n- GitHub Repository: [googleapis/python-genai](https://github.com/googleapis/python-genai)\n\n- Installation: `pip install google-genai`\n\n### JavaScript\n\n- Library: [`@google/genai`](https://www.npmjs.com/package/@google/genai)\n\n- GitHub Repository: [googleapis/js-genai](https://github.com/googleapis/js-genai)\n\n- Installation: `npm install @google/genai`\n\n### Go\n\n- Library: [`google.golang.org/genai`](https://pkg.go.dev/google.golang.org/genai)\n\n- GitHub Repository: [googleapis/go-genai](https://github.com/googleapis/go-genai)\n\n- Installation: `go get google.golang.org/genai`\n\n### Java\n\n- Library: `google-genai`\n\n- GitHub Repository: [googleapis/java-genai](https://github.com/googleapis/java-genai)\n\n- Installation: If you're using Maven, add the following to your dependencies:\n\n \u003cdependencies\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.genai\u003c/groupId\u003e\n \u003cartifactId\u003egoogle-genai\u003c/artifactId\u003e\n \u003cversion\u003e1.0.0\u003c/version\u003e\n \u003c/dependency\u003e\n \u003c/dependencies\u003e\n\nGeneral availability\n--------------------\n\nWe started rolling out Google GenAI SDK, a new set of libraries to access Gemini\nAPI, in late 2024 when we launched Gemini 2.0.\n\nAs of May 2025, they reached General Availability (GA) across all supported\nplatforms and are the recommended libraries to access the Gemini API. They are\nstable, fully supported for production use, and are actively maintained. They\nprovide access to the latest features, and offer the best performance working\nwith Gemini.\n\nIf you're using one of our legacy libraries,\nwe strongly recommend you migrate so that you can access the latest features and\nget the best performance working with Gemini. Review the [legacy libraries](/gemini-api/docs/libraries#previous-sdks) section for more information.\n\nLegacy libraries and migration\n------------------------------\n\nIf you are using one of our legacy libraries, we recommend that you\n[migrate to the new libraries](/gemini-api/docs/migrate).\n\nThe legacy libraries don't provide access to recent features (such as\n[Live API](/gemini-api/docs/live) and [Veo](/gemini-api/docs/video)) and are on\na deprecation path. They will stop receiving updates on November 30th,\n2025, the feature gaps will grow and potential bugs may no longer get fixed.\n\nEach legacy library's support status varies, detailed in the following table:\n\n| Language | Legacy library | Support status | Recommended library |\n|---------------------------|-----------------------------------------------------------------------------------------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| **Python** | [google-generativeai](https://github.com/google-gemini/deprecated-generative-ai-python) | All support, including bug fixes, ends on November 30th, 2025. | [google-genai](https://github.com/googleapis/python-genai) |\n| **JavaScript/TypeScript** | [@google/generativeai](https://github.com/google-gemini/generative-ai-js) | All support, including bug fixes, ends on November 30th, 2025. | [@google/genai](https://github.com/googleapis/js-genai) |\n| **Go** | [google.golang.org/generative-ai](https://github.com/google/generative-ai-go) | All support, including bug fixes, ends on November 30th, 2025. | [google.golang.org/genai](https://github.com/googleapis/go-genai) |\n| **Dart and Flutter** | [google_generative_ai](https://pub.dev/packages/google_generative_ai/install) | Not actively maintained | Use trusted community or third party libraries, like [firebase_ai](https://pub.dev/packages/firebase_ai), or access using REST API |\n| **Swift** | [generative-ai-swift](https://github.com/google/generative-ai-swift) | Not actively maintained | Use [Firebase AI Logic](https://firebase.google.com/products/firebase-ai-logic) |\n| **Android** | [generative-ai-android](https://github.com/google-gemini/generative-ai-android) | Not actively maintained | Use [Firebase AI Logic](https://firebase.google.com/products/firebase-ai-logic) |\n\n**Note for Java developers:** There was no legacy Google-provided Java SDK for\nthe Gemini API, so no migration from a previous Google library is required. You\ncan start directly with the new library in the\n[Language support and installation](#install) section.\n\nPrompt templates for code generation\n------------------------------------\n\nGenerative models (e.g., Gemini, Claude) and AI-powered IDEs (e.g., Cursor) may\nproduce code for the Gemini API using outdated or deprecated libraries due to\ntheir training data cutoff. For the generated code to use the latest,\nrecommended libraries, provide version and usage guidance directly in your\nprompts. You can use the templates below to provide the necessary context:\n\n- [Python](https://github.com/googleapis/python-genai/blob/main/codegen_instructions.md)\n\n- [JavaScript/TypeScript](https://github.com/googleapis/js-genai/blob/main/codegen_instructions.md)"]]