To build custom applications with Large Language Models, we connect to them programmatically using developer APIs. Let's learn how to use the Google Gemini and OpenAI developer libraries.
Google provides the @google/generative-ai SDK to interact with the Gemini family of models. In Python, you initialize the client using GoogleGenerativeAI and request content from the fast, highly capable **gemini-2.5-flash** model:
from google import generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel('gemini-2.5-flash')
response = model.generate_content("Explain APIs in one sentence.")
print(response.text)
The **openai** library is another developer standard. While APIs differ slightly, they share common parameters: passing a model name, setting system instructions, and defining a **temperature** (which controls the randomness of generation).
Let's simulate a standard Gemini API model setup wrapper function in Python!
GoogleGenerativeAI.__init__(self, api_key) that saves the API key.generateContent(self, prompt) that returns a string containing the prompt and the model name "gemini-2.5-flash".Write this simulation in the code execution sandbox on the right!