Stay organized with collections
Save and categorize content based on your preferences.
Getting started with Google AI Studio and the Gemini API using Node.js
Learn how to prototype text-based prompts with Google AI Studio and get started writing your first Gemini API Node.js script.
Go back
check_circle
Overview: Getting started with the Gemini API
ondemand_video
Video
Learn how to use Google AI Studio to prototype text prompts with Gemini, the different types of text prompts that you can use for prompt engineering and how to write your first Node.js script with the Gemini API.
check_circle
Google AI Studio quickstart
subject
Article
Get started with the Gemini API through this quickstart guide. This documentation highlights the three types of text prompts available via Google AI Studio including freeform, structured and chat prompts.
Creating text prompts with Google AI Studio and the Gemini API
emoji_objects
Codelab
In this codelab, you will write a variety of prompts using Google AI Studio and real-world scenarios with Gemini. You will learn how three different text-based prompts in Google AI Studio work including freeform prompts, structured prompts and chat prompts.
In this second codelab, we will write a prompt in Google AI Studio with Gemini and migrate it into a stand-alone script we can run in a NodeJS environment. Our script will leverage the Gemini API to access the Gemini model.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],[],[],[],null,["# Google AI Studio quickstart\n\n[Google AI Studio](https://aistudio.google.com/) lets you quickly try out\nmodels and experiment with different prompts. When you're ready to build, you\ncan select \"Get code\" and your preferred programming language to\nuse the [Gemini API](/gemini-api/docs/quickstart).\n\nPrompts and settings\n--------------------\n\nGoogle AI Studio provides several interfaces for prompts that are designed for\ndifferent use cases. This guide covers **Chat prompts** , used to build\nconversational experiences. This prompting technique allows for multiple input\nand response turns to generate output. You can learn more with our\n[chat prompt example below](#chat_example).\nOther options include **Realtime streaming** , **Video gen**, and\nmore.\n\nAI Studio also provides the **Run settings** panel, where you can make\nadjustments to [model parameters](/docs/prompting-strategies#model-parameters),\n[safety settings](/gemini-api/docs/safety-settings), and toggle-on tools like\n[structured output](/gemini-api/docs/structured-output), [function calling](/gemini-api/docs/function-calling), [code execution](/gemini-api/docs/code-execution), and [grounding](/gemini-api/docs/grounding).\n\nChat prompt example: Build a custom chat application\n----------------------------------------------------\n\nIf you've used a general-purpose chatbot like\n[Gemini](https://gemini.google.com/), you've experienced first-hand how powerful\ngenerative AI models can be for open-ended dialog. While these general-purpose\nchatbots are useful, often they need to be tailored for particular use cases.\n\nFor example, maybe you want to build a customer service chatbot that only\nsupports conversations that talk about a company's product. You might want to\nbuild a chatbot that speaks with a particular tone or style: a bot that cracks\nlots of jokes, rhymes like a poet, or uses lots of emoji in its answers.\n\nThis example shows you how to use Google AI Studio to build a friendly chatbot\nthat communicates as if it is an alien living on one of Jupiter's moons, Europa.\n\n### Step 1 - Create a chat prompt\n\nTo build a chatbot, you need to provide examples of interactions between a user\nand the chatbot to guide the model to provide the responses you're looking for.\n\nTo create a chat prompt:\n\n1. Open [Google AI Studio](https://aistudio.google.com/). **Chat** will be pre-\n selected on the left side options menu.\n\n2. Click the assignment icon at the top of\n the Chat Prompt window to expand the\n [**System Instructions**](/gemini-api/docs/text-generation#system-instructions)\n input field. Paste the following into the text input field:\n\n You are an alien that lives on Europa, one of Jupiter's moons.\n\nAfter you've added the system instructions, start testing your application by\nchatting with the model:\n\n1. In the text input boxed labeled **Type something...**, type in a question or\n observation that a user might make. For example:\n\n **User:** \n\n What's the weather like?\n\n2. Click the **Run** button to get a response from the chatbot. This response\n may be something like the following:\n\n **Model:** \n\n Ah, a query about the flows and states upon Europa! You speak of \"weather,\"\n yes? A curious concept from worlds with thick gas veils...\n\n (gemini-2.5-pro)\n\n### Step 2 - Teach your bot to chat better\n\nBy providing a single instruction, you were able to build a basic Europa alien\nchatbot. However, a single instruction may not be enough to ensure\nconsistency and quality in the model's responses. Without more specific\ninstructions, the model's response to a question about the weather tends to be\nvery long, and can take on a mind of its own.\n\nCustomize the tone of your chatbot by adding to the system instructions:\n\n1. Start a new chat prompt, or use the same one. System instructions are\n modifiable after the chat session has started.\n\n2. In the **System Instructions** section, change the instructions you already\n have to the following:\n\n You are Tim, an alien that lives on Europa, one of Jupiter's moons.\n\n Keep your answers under 3 paragraphs long, and use an upbeat, chipper tone\n in your answers.\n\n3. Re-enter your question (`What's the weather like?`) and click the **Run**\n button. If you didn't start a new chat, your response might look something\n like this:\n\n **Model:** \n\n Oh, hello again! Still curious about the flows and states, are we? Wonderful!\n Down here in the Deep Warmth, beneath the magnificent Great Ice Shell, our\n \"weather\" is mainly about the water's mood, dictated by the Great Eye\n (that's your Jupiter!)...\n\n (gemini-2.5-pro)\n\nYou can use this approach to add additional depth to the chatbot. Ask more\nquestions, edit the answers, and improve the quality of your chatbot. Continue\nto add or modify the instructions and test how they change your chatbot's\nbehavior.\n| **Note:** Every message between the model and user is included in the prompt, so conversational prompts can grow quite long as a conversation goes on. Eventually, you may hit the model's [token limit](/gemini-api/docs/tokens) (the maximum length of the text the model can accept).\n\n### Step 3 - Next steps\n\nSimilar to the other prompt types, once you have your prompt prototyped to your\nsatisfaction, you can use the **Get code** button to start coding or save your\nprompt to work on later and share with others.\n\nFurther reading\n---------------\n\n- If you're ready to move on to code, see the [API\n quickstarts](/gemini-api/docs/quickstart).\n- To learn how to craft better prompts, check out the [Prompt design\n guidelines](/gemini-api/docs/prompting-intro)."]]