Skip to content

Gemini 4 Argon API Crash Course

Read the Portuguese translation →

Author: freeCodeCamp.org · Watch on YouTube

Video authored by the channel shown, not by IANIA; all rights belong to the creator. Transcript and summary generated automatically; the original-language content is preserved.

Original language: English

Original video: Gemini 4 Argon API Crash Course · Channel: freeCodeCamp.org · 10:22 · Watch on YouTube

Topics: AI agents, Software engineering with AI, AI developer tools, AI content generation

This tutorial walks through using Gemini 4 Argon with Google’s JavaScript SDK, from setting up an API key to making requests. It demonstrates thinking levels, continuing a conversation with a previous interaction ID, and using background mode to generate a Breakout game. A Google DeepMind engineer also discusses the model’s strengths in reasoning, creative projects, and writing.

  • Gemini 4 Argon is presented as Google’s latest and most capable model, suited to complex coding, math, and science tasks.
  • Its thinking level can be set to low, medium, or high; the tutorial recommends choosing the lowest level that still gives good answers.
  • Thinking tokens are billed as output, so higher thinking levels can take longer and cost more.
  • The API key should be kept secret, stored in an environment file, and excluded from GitHub.
  • The JavaScript setup uses Google’s official @google/genai SDK and the client.interactions.create method.
  • A previous interaction ID lets a follow-up request continue a conversation using context retained by Google.
  • Background mode can handle longer tasks; the tutorial polls for completion and combines output steps into an HTML file.
  • The tutorial uses background mode to generate a Breakout game in a single HTML file.
  • The guest describes the model as useful for reasoning through ideas, building creative projects, and writing.
Start Chapter Summary
00:00 Introduction and what Argon is The video introduces Gemini 4 Argon and explains its thinking levels, context window, and ability to run tasks in the background.
02:04 Set up the API and make a first request The tutorial covers creating an API key, configuring a JavaScript project, and sending a basic prompt through the SDK.
04:10 Thinking levels and conversations The presenters compare low and high thinking levels on a debugging task, then show how to continue a conversation with a previous interaction ID.
06:13 Background mode and building a game The tutorial uses background mode to generate a Breakout game and explains how to check on the job and save its output.
07:47 Guest interview and wrap-up A Google DeepMind engineer shares examples of the model’s creative capabilities, and the video closes by encouraging viewers to try it.

it thinks before it answers — 01:02

Copy that key and treat it like a password. — 02:04

try your task at all three levels and pick the lowest one that still gives good answers. — 05:10

Google keeps the conversation on their side for us. — 06:13

the work is happening on Google servers and not my laptop. — 07:16

Gemini 4 Argon, @google/genai, Google, Google DeepMind, Jack Witherspoon, Genevieve, thinking level, context window, background mode, previous interaction ID, Blender, Blender MCP

00:00 Hey everyone, welcome to freecodecamp. Google just released Gemini 4 Argon, which is its most capable model yet. And in the next 10 minutes or so, we’re going to learn how to actually use it. >> By the end of this video, you will know how to use Gemini 4 Argon, control how hard it thinks, have a proper back and forth conversation with it, and even get it to build this game that you can see on screen, all in a few small JavaScript files. >> And we even have a Google engineer here with us today. >> And if you are fairly new to coding,

00:31 don’t worry. If you can write a few JavaScript functions, you could definitely follow along with this. I’ll be saying everything super slow, step by step. >> So, before we get going, let’s have a look at what we will actually cover. First off, we will look at what Gemini 4 Argon actually is. After that, we will get set up with an API key, and then we will send our first request. We’ll play with the thinking levels, have a conversation with the model, and finish by letting it build a game for us in the background. >> What is Gemini 4 Argon? So, Gemini 4

01:02 Argon is Google’s latest and most capable model, specifically built for all the hard stuff. So, complex coding, math, science, you name it. When you call it from your code, you refer to it by its model ID, which is just this string right here, Gemini 4 Argon. Now, there really are three things about it worth knowing as a beginner. First, it thinks before it answers, and you get to decide how much it thinks using a setting called the thinking level, which can be low, medium, or high. Medium is

01:33 the default, and we will play all three in a moment. Second, it has a huge context window, which is essentially the model’s working memory. For Argon, that is just over 4 million tokens, shared between what you send in, what it thinks, and what it writes back. And a token is roughly a small chunk of a word. And third, it can run in the background, so you can hand it a big job and come back for the results later on. >> Set up API key, billing, and project.

02:04 All right, let’s get set up. Head over to Google API Studio, sign in with your Google account, and click get API key. Create a key and make sure the project it belongs to has billing enabled. Otherwise, Argon will turn your request down. Copy that key and treat it like a password. Don’t paste it into your code and do not push it to GitHub. And make sure the project it belongs to has billing enabled. Okay, so now let’s make our project. I’m just going to make a new folder and run npm init and install

02:36 Google’s official SDK, which is the package @google/genai. Next, in package.json, I’m adding type module, which lets us use import and top-level await. And finally, a .env file with our key in it called gemini_api_key. The SDK looks for that variable all by itself, so we never touch the key in our code. And .env goes straight into .gitignore. >> Your fast request. Right, let’s talk to

03:08 Argon. First, let’s make a file called hello.js. So, at the top, we import Google gen AI and create client. The empty object is because it finds our key from the environment for us, so definitely put that in. Then, we call client interactions.create. An interaction is essentially one round trip with the model, so we send something in and we get something back. We give it the model, which in this case is Gemini for Argon, and then the input, which is our prompt. I’m asking it to

03:39 explain what an API is to a complete beginner. Then, we log out interaction_text, which is the answer as plain text. Now, let’s run it using Node’s .env file flag to load our key. And there we go, our fast response from Gemini 4 Argon. And that is really the whole pattern. And everything else in this course is the same core with a few extra options. Now, if you’re just taking a little bit longer than expected, remember, by

04:10 default, it’s thinking at medium before it says anything. So, let’s look at that next. >> Thinking levels low versus high. And to see what thinking levels do, we need to give Argon something to think about. Here’s a tiny function that should average some exam scores. We pass an 80, 90, and 100. So, we should get 90, right? But we get NaN, or not a number. See if you can spot the bug yourself. Okay, let’s see if Argon can find it and how long it takes at different thinking

04:40 levels. So, in think.js, I have wrapped our call in a function called hunt, which takes a thinking level. The only new thing is this generation config object, where we set thinking level. I’m also timing each call and logging the thinking tokens from interaction.usage. Then we call hunt twice, once with low and once with high. And both of them found it. The loop uses less than or equal to, so it runs once

05:10 too many. Scores I is undefined, and adding undefined to a number gives NaN, not a number. But look at the difference between the thinking levels in terms of seconds and tokens. So, should we always use high just to be safe? Well, not really. Google’s advice is to try your task at all three levels and pick the lowest one that still gives good answers. Because thinking tokens are billed as output. So, more thinking is slower and more expensive. For simple

05:40 bug like ours, low is plenty. >> Conversations with previous interaction ID. Now, so far every conversation has been a one-off, and Argon has no idea what we asked before. But, what if we want a conversation? So, in chat.js, we first ask it to fix the bug, and then we follow up with what should happen if the array is empty. That only makes sense if Argon remembers our function, right? So, we pass in previous interaction ID set to the ID of our first interaction, and Google keeps the conversation on their

06:13 side for us. And it picks up exactly where we left off, adding a check so we don’t divide by zero. So, if you ever build a chatbot, this one line is essentially how you give it a memory. >> Background mode. Argon builds a game. Okay, now for the fun one. We’re going to ask Argon to build an entire Breakout game in a single HTML file. Now, a big job like this can take a few minutes, and a normal request could time out. So, we use background mode, which is the

06:45 same create call with three changes. Background is true, thinking level is high, and max output tokens goes up to 131,072. It’s worth noting that without max output tokens, background mode stops at about 64,000 tokens. This time, create hands us an interaction with a status queued or in progress, so we check back every 5 seconds with client.interactions.get. Once it finishes, Argon’s answers split

07:16 across steps. So, we join the text from all the model output steps and write it to game.html. So, what’s cool is the work is happening on Google servers and not my laptop. You can close your laptop and come back for it later. Okay, it’s done. Let’s open game.html in our browser. And there we go, a working Breakout game with a score, lives, and a restart button, all from one prompt. This is truly incredible. >> So, here we are with our Google experts.

07:47 If you could please introduce yourselves for the crowd. >> Yeah, for sure. My name is Jack Witherspoon and I am on the developer experience team here at Google DeepMind. >> And what is your favorite thing about the latest Gemini model? >> Yeah, so we just launched Gemini for Argon. I think the thing I like the most is that you can really kind of just throw ideas at it and it can do a lot of strong, you know, really reasoning and going out and actually finding an elegant solution to something that you might not even have fully thought through yourself. You just kind of give it an idea of, “Hey,

08:18 here’s what I want to try to do. Can you go ahead and try to build this?” And then you come back and kind of has gone through all the reasoning. It’s gone and researched, searched the web and like built out a really nice kind of solution. >> And my favorite question, what is the most incredible, amazing thing that you’ve built with this model so far? >> Yeah, I think my teammate Genevieve did an awesome demo for the actual launch that was included in the blog where she took a picture of her desk in her apartment and sent it to Gemini for Argon and asked it to turn it into a kind of 3D racetrack. And it’s really

08:50 good at 3D, so it went out and used Blender with the Blender MCP and built out all the components and even pulled in things like nano banana to actually get good textures on like the car and on the background. And it also then even went out and searched the web for kind of motor sounds and actually added its own audio to the game as well. It was really cool to see it come together. >> Wow, I love that. >> So, here’s my question. What’s a cool use case for Argon or maybe something that other people may not know about, something that’s not as obvious that it

09:20 would be good for people to know about? >> Yeah, for sure. I think Argon, for me personally, what I’ve really enjoyed and found about it is that for like creative writing or just writing in general, it’s my favorite model to use out of all the models out there. I think it’s really, really strong at actually kind of creative writing and actually being able to weave a narrative together that doesn’t sound like AI or doesn’t have certain quirks that a lot of models can do. Like you know, sometimes you can read something and be like, “Okay, I think I know what model that is based

09:50 off of certain words they say.” And our team’s really like took the time to do into the research phase and training the model in writing and I think it showed. It’s one that’s really really strong. >> Well, thank you so much for coming in and and ask answering our questions. >> Yes, thanks for having me. >> Okay, there we go. We learned how to use Gemini for Argon. We used we learned how to use the the API to create some programs, create a game, and there’s so much more you can do with it. So, I encourage you to check out the links in the description. We have the the code

10:22 links and other links to be able to use it yourself and just start trying to figure out what you can use this for in your own projects.