Gemini 4 Argon API Crash Course

#Programming
💬 Chat with this Video
Ask anything about this video…
Hello everyone, welcome to the free code camp. Google just released the Gemini 4 Argon, its most powerful model to date. And in the next 10 minutes we'll learn how to use it. By the end of this video, you'll know how to use Gemini 4 Argon, control the depth of its thoughts, have full dialogue, and even have it create the game you see on the screen, all with just a few small JavaScript files. We even have a Google engineer with us today. If you are new to programming, don't worry. If you can write a few functions in JavaScript, you'll definitely be fine. I will explain everything very slowly, step by step. So, before we get started, let's see what exactly we're going to cover . First, we'll learn what Gemini 4 Argon is. After that, we will set up an API key and send our first request. We will experiment with levels of thinking, chat with the model, and finally let it create a game for us in the background . What is Gemini 4 Argon? So, Gemini 4 Argon is Google's newest and most powerful model, specially designed for the most complex tasks. That is, for complex programming, mathematics, science, and anything else. When you call it from your code, you access it by the model ID, which looks like this: Gemini 4 Argon. There are three things you should know about it at the initial stage. First, she thinks before she answers, and you decide how deeply, using the " thinking level" option: low, medium, or high. The medium level is set by default, and we will try all three soon. Second, it has a huge context window, which is essentially the working memory of the model. For Argon, that's over 4 million tokens, which are distributed between what you send, what she ponders, and what she writes in response. A token is roughly a small part of a word. And thirdly, it can run in the background. So , you can give her a big task and come back for the result later. API key , billing, and project settings. Okay, let's start the setup. Go to Google API Studio, sign in with your Google account, and click " Get API Key". Create a key and make sure that billing is enabled for the project it belongs to . Otherwise, Argon will reject your request. Copy this key and treat it like a password. Do not embed it in your code or upload it to GitHub. And make sure billing is enabled for the project it belongs to. Okay, now let's create our project. I'll just create a new folder, run npm init , and install the official SDK from Google—package@google/ genai. Next, in package.json, I add a type module, which allows the use of import and top-level await. And finally , the .env file with our key called gemini_api_key. The SDK finds this variable itself, so we never touch the key in our code. And we immediately add the .env file to .gitignore. Your quick request. Well , let's talk to Argon. First, let's create a file called hello.js. So, first we import Google Gen AI and create a client. The empty object is needed because it finds our key from the environment itself, so be sure to specify it. Then we call client.interactions.create. An interaction is essentially a single cycle of exchange with a model: we send something and receive a response. We pass in the model, in this case Gemini for Argon, and then the input—our prompt. I ask him to explain what an API is to a complete beginner. Then we output interaction.output_text, which is the response in plain text. Now let's run this using the Node .env flag to load our key. And so, we got a quick response from Gemini 4 Argon. This, in fact, is the whole pattern. And everything else in this course is based on the same foundation with a few additional options. If the process takes a little longer than expected , remember: by default, it " thinks" at an average level before saying anything. So let's look at this further. Levels of thinking: low versus high. To see how levels of thinking work, we need to give Argon something to think about. Here is a small function that should calculate the average score of exams. We pass 80, 90 and 100 . So we should get 90, right? But we get NaN, meaning "not a number". Try to find the error yourself. Okay, let's see if Argon can find her and how long it takes on different levels of thinking. So, in the think.js file, I wrapped our call into a function called hunt that takes a level of thinking. The only new thing is the generation config object, where we set the level of thinking. I also time each call and log the thinking tokens with interaction.usage. Then we call hunt twice: once with the level low, and once with the level high. And both times he found a mistake. The loop uses "less than or equal to", so it executes one more time than necessary. Scores I is undefined, and adding an undefined value to a number gives NaN, meaning "not a number." But look at the difference between the levels of thinking in seconds and tokens. So should we always choose high just in case? Actually, it's not worth it. Google recommends trying to complete the task at all three levels and choosing the lowest one that gives good answers. After all, tokens of thinking are billed as output data. So, more thinking takes longer and is more expensive. For a simple error like ours, the low level is quite sufficient. Conversations with previous interaction ID. So far, each of our conversations has been one-off, and Argon doesn't know what we asked about before. But what if we want to have a dialogue? So in chat.js we first ask for an error to be fixed, and then we specify what to do if the array is empty. This only makes sense if Argon remembers our function, right? So we pass the previous interaction ID set to the ID of our first interaction, and Google stores the conversation for us. It picks up right where we left off, adding a check to make sure we don't divide by zero. So, if you're building a chatbot, this line of code is essentially a way to give it memory. Background mode. Argon creates a game. Okay, now for the fun part. We will ask Argon to create a complete Breakout game in a single HTML file. Such a large-scale task can take several minutes, and a normal query may time out . So we use background mode—it's the same create call, but with three changes. Background is set to true , thinking level is high , and the maximum number of output tokens is increased to 131,072. It is worth noting that without setting the maximum output tokens, the background stops at approximately 64,000 tokens. This time, create gives us an interaction with a status of "queued" or "in progress", so we check the status every 5 seconds using client.interactions.get. Once completed, Argon's answers are broken down into steps. So we combine the text from all the model output steps and write it to game.html. The cool thing is that the work is done on Google servers, not on my laptop. You can close your laptop and come back to this later. Okay, done. Let's open game.html in our browser. And here we have a working Breakout game with a score, lives, and a restart button —all with a single request. This is truly incredible. So, we're here with our Google experts. Please introduce yourself to our audience. Yes, of course. My name is Jack Witherspoon, and I work on the Development Experience team at Google DeepMind. And what do you like most about the latest Gemini model? Yes, we just launched Gemini for Argon. What I like most is that you can just " throw" ideas at him, and he is able to conduct a deep analysis and find an elegant solution to something you yourself may not have even had time to think about well. You just give him the idea, "Hey, this is what I want to try to do." "Can you take on this and try to build it?" And then you come back and he's already gone through all the considerations. He did his own research online and created a truly great solution. And my favorite question: What's the most incredible thing you've created with this model? So, I think my colleague Genevieve did an awesome demo for the launch that was on the blog: she took a picture of her desktop in her apartment, sent Gemini to Argon, and asked them to turn it into a 3D track. He's very good with 3D, so he used Blender through Blender MCP, built all the components, and even tweaked things like nano banana to get quality textures for the cars and backgrounds. In addition, he independently found the sounds of the engine on the Internet and added his own audio to the game. It was really cool to watch the result. Wow, I like that. So, here's my question. What is an interesting use case for Argon that others may not know about, something less obvious but useful for people? Yes, of course. I think Argon, for me personally, is the best model for creative writing or for writing texts in general out of all those that currently exist. He is indeed very strong in creative writing, able to build a narrative that does not sound like artificial intelligence and does not have the specific flaws inherent in many other models. You know , sometimes you read something and you're like, " Okay, I think I understand what this model is, given some of the words they use." Our team really put in the time to research and train the model in writing, and I think it shows. This is a very, very powerful model. Well, thank you very much for coming and answering our questions. Yes, thank you for inviting me. Okay, that's it. We learned how to use Gemini for Argon. We learned how to use APIs to create apps and games, and there's so much more you can do with them . So I encourage you to check out the link in the description. We've added links to code and other resources so you can try it out for yourself and start figuring out how to use it in your own projects.

Generated algorithmically for Search Engine Indexing.

Summarize Another Video