{"id":26611117,"url":"https://github.com/codenze/bard-api-node","last_synced_at":"2025-04-10T00:43:43.084Z","repository":{"id":167388391,"uuid":"643010452","full_name":"codenze/bard-api-node","owner":"codenze","description":"bard-api-node is a Node.js library for interacting with Bard, an AI Chatbot developed by Google. Bard is based on Google's Large language model (LLM), LaMDA, which is designed to generate human-like text and images in response to prompts.","archived":false,"fork":false,"pushed_at":"2024-04-29T14:12:34.000Z","size":36,"stargazers_count":24,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T00:43:39.574Z","etag":null,"topics":["ai","api","bard","bard-ai","bard-api","chatbot","codenze","gemini","gemini-ai","google","javascript","lamda","llm","nodejs","npm","npm-package","prompt"],"latest_commit_sha":null,"homepage":"https://bard.google.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codenze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-19T21:36:52.000Z","updated_at":"2024-12-25T05:53:59.000Z","dependencies_parsed_at":"2023-05-23T01:45:35.160Z","dependency_job_id":"c2b4c82b-ef2f-408c-a130-f7074cd60371","html_url":"https://github.com/codenze/bard-api-node","commit_stats":null,"previous_names":["codenze/bard-api-node"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenze%2Fbard-api-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenze%2Fbard-api-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenze%2Fbard-api-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenze%2Fbard-api-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codenze","download_url":"https://codeload.github.com/codenze/bard-api-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137998,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","api","bard","bard-ai","bard-api","chatbot","codenze","gemini","gemini-ai","google","javascript","lamda","llm","nodejs","npm","npm-package","prompt"],"created_at":"2025-03-24T02:25:37.675Z","updated_at":"2025-04-10T00:43:43.063Z","avatar_url":"https://github.com/codenze.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bard-API-Node (Updated for Gemini API)\n\n![Bard-API-Node](https://techviral.net/wp-content/uploads/2024/02/Google-Rebrands-Its-AI-Chatbot-Bard-As-_Gemini_.png)\n\n## Description\n\n**bard-api-node** is a Node.js library for interacting with Bard, an AI Chatbot developed by Google. Bard is based on Google's Large language model (LLM), LaMDA, which is designed to generate human-like text and images in response to prompts. This updated version of the library is aligned with the launch of Gemini API, the successor to Bard, and integrates with the official Google API services.\n\n## What is Bard (Gemini)?\n\nBard, now known as Gemini, is an AI Chatbot developed by Google, based on Google’s Large language model (LLM), LaMDA. Similar to how ChatGPT is based on GPT, Gemini utilizes neural networks to mimic the underlying architecture of the brain in the form of a computer. Gemini is conversational and allows users to write a prompt and receive human-like text and images generated by artificial intelligence.\n\n## Getting Started with BardAPI\n\nTo begin using BardAPI in your project, follow these steps:\n\n### Installation\n\nTo use the Bard-API-Node library in your project, you can install it via npm directly:\n```\nnpm install bard-api-node\n```\nor can install it via npm from Github:\n```\nnpm install git+https://github.com/codenze/bard-api-node.git\n```\n\n\n### Obtaining API Key\n\nTo get started with the Bard API, you need to obtain an API key from the Google AI Studio. Follow the steps below to acquire your API key:\n\n1. **Sign in to Google Account**:\n   - Make sure you are signed in to your Google account.\n\n2. **Create a New Project**:\n   - Visit [Google Cloud Console](https://console.cloud.google.com/projectcreate).\n   - Enter a project name of your choice.\n   - Click on \"Create\" to create the project.\n   -    \u003cimg width=\"854\" alt=\"Screenshot 2024-03-01 at 10 15 19 PM\" src=\"https://github.com/codenze/bard-api-node/assets/125561714/e35f763b-0447-4c82-aacd-1cc38518890c\"\u003e\n\n3. **Visit Google Ai Studio for API Key**:\n   - After creating the project, navigate to [API Key creation page](https://aistudio.google.com/app/apikey).\n   -    \u003cimg width=\"854\" alt=\"Screenshot 2024-03-01 at 10 16 25 PM\" src=\"https://github.com/codenze/bard-api-node/assets/125561714/311e3c4e-c1a7-4b47-9a27-0ac85cc6fda9\"\u003e\n   - Click on \"Create API key\".\n   - Choose the project you just created from the dropdown menu labeled \"Search Google Cloud projects\".\n   - \u003cimg width=\"854\" alt=\"Screenshot 2024-03-01 at 10 17 05 PM\" src=\"https://github.com/codenze/bard-api-node/assets/125561714/272ab018-80f8-4e40-9dac-e7417360e780\"\u003e\n   - Click on \"Create API key in exsisting project\".\n   - Copy the API key.\n   - \u003cimg width=\"854\" alt=\"Screenshot 2024-03-01 at 10 17 27 PM\" src=\"https://github.com/codenze/bard-api-node/assets/125561714/70549631-ecbb-46f1-8546-76d51cba0dab\"\u003e\n\n5. **Paste API Key into Code**:\n   - Paste the API key into your code to initialize the BardAPI object.\n\n### Usage\n\n```javascript\njavascript const { BardAPI } = require('bard-api-node');\n\nasync function testAssistant() {\n  try { // Initialize BardAPI object const bard = new BardAPI();\n\n  // Set API key\n  const apiKey = 'YOUR_API_KEY'; // Replace 'YOUR_API_KEY' with the obtained API key\n  // Initialize chat with API key\n  await bard.initilizeChat(apiKey);\n  // Send a query to Bard\n  const response = await bard.getBardResponse(\"Greetings! What can you do for me?\");\n  console.log(response);\n  } catch (error) {\n    console.error('Error:', error);\n  }\n}\n\ntestAssistant();\n```\nMake sure to replace `YOUR_API_KEY` with the actual API key obtained from Google AI Studio.\n\n## Advanced Settings\n\n### Content Generation Settings\n\nThe `setResponseGenerationConfig()` method allows you to customize the generation configuration for generating responses. This method enables you to fine-tune parameters related to the content generation process.\n\n#### Usage\n\n```javascript\nconst bard = new BardAPI();\n\nconst generationConfig = {\n  temperature: 0.7,\n  topK: 5,\n  topP: 0.9,\n  maxOutputTokens: 1024,\n};\n\nbard.setResponseGenerationConfig(generationConfig);\n```\n\nIn the above example, we set a custom generation configuration with specific values for temperature, top-K sampling, top-p sampling, and maximum output tokens.\n\n### Safety Settings\n\nThe `setSafetySettings()` method allows you to configure safety settings to filter out sensitive or harmful content from the generated responses. This method enables you to specify thresholds for different categories of harmful content.\n\n#### Usage\n\n```javascript\nconst bard = new BardAPI();\n\nconst safetySettings = [\n  {\n    category: HarmCategory.HARM_CATEGORY_HARASSMENT,\n    threshold: HarmBlockThreshold.BLOCK_STRICT,\n  },\n  {\n    category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,\n    threshold: HarmBlockThreshold.BLOCK_LOW,\n  },\n  // Add more security settings as needed\n];\n\nbard.setSafetySettings(safetySettings);\n```\n\nIn the above example, we set custom safety settings to filter out harassment with a strict threshold and hate speech with a low threshold. You can customize these settings based on your application's requirements.\n\n## Acknowledgements\n\nThis Node.js library for interacting with the Bard chat assistant is powered by the official Google AI Studio API and utilizes the `@google/generative-ai` npm library. The integration with Google's Gemini AI and the use of the `@google/generative-ai` library serve as the foundation for this implementation.\n\nI extend my gratitude to the Google AI team for providing access to their advanced AI capabilities and for the comprehensive documentation that facilitated the development of this library.\n\n## Feedback\n\nI welcome any feedback, bug reports, or problems you may encounter while using this library. If you have any issues or suggestions, please don't hesitate to reach out. You can send your reports to [de.inzimam@gmail.com](mailto:de.inzimam@gmail.com).\n\nThank you for your support and feedback!\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\nIf you find this project helpful in your own work, I would appreciate a star or acknowledgment in your projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenze%2Fbard-api-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodenze%2Fbard-api-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenze%2Fbard-api-node/lists"}