Posts

Showing posts from April, 2025

Connect open Java to open AI

 Create maven project: mvn archetype:generate -DgroupId=com.openai.test -DartifactId=openAIBanking -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false; Apps.java package com . openai . test ; public class App { public static void main ( String [] args ) { Connection connection = new Connection (); connection . connect (); } } Connection.java package com . openai . test ; import java . io . OutputStream ; import java . net . HttpURLConnection ; import java . net . URL ; import java . util . Scanner ; import org . json . JSONObject ; import org . json . JSONArray ; public class Connection { public void connect () { try { System . out . println ( "testing" ); // 1. Set the endpoint URL for ChatGPT (gpt-3.5 or gpt-4) URL url = new URL ( "https://api.openai.com/v1/chat/completions" ); // 2. Open HTTP connection ...

Connect to AI in 5 min

First programming using Google Gemini API Hello world Notes: Getting Started with Google Gemini API and pydantic-ai These notes will guide you through using the powerful Google Gemini API with the pydantic-ai Python library. We'll focus on sending a simple question and getting a concise answer. Step 1: Get Your Google Gemini API Key Think of this key as your personal password to access the Gemini API. Go to Google AI Studio . This is where Google lets developers like you experiment with their AI models. Look for an option to "Create a new API key" or similar. Follow the instructions on the website. Important! Once you have the key, copy it and store it in a safe place. Treat it like a password – don't share it with anyone! Without this key, the Python code won't be able to talk to Google's Gemini AI. Step 2: In...