Skip to main content

Posts

Showing posts with the label Gemini API tutorial

Using Gemini API in LangChain: Step-by-Step Tutorial

What is LangChain and Why Use It? LangChain  is an open-source framework that simplifies the use of  Large Language Models (LLMs)  like OpenAI, Gemini (Google), and others by adding structure, tools, and memory to help build real-world applications such as chatbots, assistants, agents, or AI-enhanced software. Why Use LangChain for LLM Projects? Chainable Components : Easily build pipelines combining prompts, LLMs, tools, and memory. Multi-Model Support : Work with Gemini, OpenAI, Anthropic, Hugging Face, etc. Built-in Templates : Manage prompts more effectively. Supports Multi-Turn Chat : Manage complex interactions with memory and roles. Tool and API Integration : Let the model interact with external APIs or functions. Let's Walk Through the Code: Gemini + LangChain I will break the code into  4 main parts , each showcasing different features of LangChain and Gemini API. Part 1: Basic Gemini API Call Using LangChain import os from dotenv import load_dotenv load_dot...

Getting Started with Google Gemini API

If you're just getting started with   Generative AI   and want to use   Google's Gemini models for free , you're in the right place. In this tutorial, I’ll walk you through everything you need to know to build your   first Gemini-powered application   using Python, including how to get a   free API key , install necessary libraries, and write code that interacts with Gemini’s generate_content() function. How to Get a Free Gemini API Key You’ll need a Google account for this. Go to the official  Google AI Studio . Sign in with your Google account. In the top-right corner, click on your profile and select  "Get API Key" . You’ll be redirected to Google Cloud's API Console. Create a  new API key  or use the existing one. Copy this key and keep it safe! You'll use it in your Python code. ** Important : Google provides  free quota  to use Gemini API. Make sure you check the  quota limits  for the free tier. Setting Up Your...