
Dan Patiño
AI Strategy & Innovation at Coderhouse
Artificial Intelligence
AI APIs for Beginners: How to Connect GPT, Claude, and Gemini to Your Projects
Published on
Connecting an artificial intelligence API to your project is simpler than it seems, and it's the step that separates those who "use ChatGPT in the browser" from those who build their own applications with AI. In this step-by-step guide you'll learn how to connect the GPT (OpenAI), Claude (Anthropic), and Gemini (Google) APIs for the first time: what an API key is, what a token is, how much it costs, and how to make your first calls with Python or JavaScript, with no prior experience.
Interest in integrating AI into projects is growing very fast, and the main barrier to entry is not programming: it's the initial technical setup. Let's clear it up.
What an AI API is and why to use it
An API (Application Programming Interface) is the door that lets you "talk" to an AI model from your own code instead of doing it from a website. Instead of typing in a chat, your program sends a text (the prompt) and receives a response that you can use inside your app: a chatbot, a summary generator, a comment classifier, whatever you imagine.
Using the API gives you full control: you define the model, the tone, the output format, and you can automate thousands of calls. It's the base of practically all the AI products you see today.
Key concepts before starting
What is an API key?
It's a secret password that identifies your account and authorizes your calls. You generate it in the provider's panel and paste it into your code (or, better, into an environment variable). Never upload it to GitHub or share it: anyone with your key can spend your balance.
What is a token?
Models don't count words, they count tokens: fragments of text of about 4 characters on average. "Hello world" is about 3 tokens. It matters because you pay per token (both the ones you send and the ones you receive) and because each model has a maximum limit of tokens per call.
How much does it cost?
The cost is measured per million tokens and varies according to the model: the lighter models cost cents per million tokens, while the more powerful ones are quite a bit more expensive. For a small test project, the expense is usually a few dollars a month. It's always a good idea to check the official pricing of each provider, because it changes often.
Step by step: getting your API key
OpenAI (GPT): create an account on OpenAI's developer platform, go to the API keys section, and generate a new one. OpenAI's official quickstart guide walks you through it.
Anthropic (Claude): register on the Anthropic console and generate your key from the panel. The official Claude API documentation includes ready-to-copy examples.
Google (Gemini): get your free key from Google AI Studio by following the Gemini documentation for developers.
In all three cases you'll receive a long string of characters: that's your API key. Save it in a safe place.
Your first call in Python
Once you have the key, making a call is a matter of a few lines. This is the general pattern with the OpenAI API:
The pattern is almost identical for Claude and Gemini: you install the official library, create a client with your key, send a message, and read the response. The method names and models change, but the logic is the same.
And in JavaScript?
If you work with Node.js, each provider offers its official SDK (for example, the openai or @anthropic-ai/sdk package). The structure repeats: you import the SDK, initialize the client with the key from an environment variable, and make the call asynchronously with await.
Best practices from day one
Use environment variables: store the key in a
.envfile and never write it directly in the code.Control the spending: set usage limits in the provider's panel to avoid surprises.
Choose the model according to the task: for simple tasks use light and cheap models; reserve the more powerful ones for what really needs it.
Test with little: start with short prompts to understand costs and behavior before scaling.
If you're still taking your first steps with this technology, it may be useful to read first this introduction to what artificial intelligence is and how to find free tools.
Recommended Coderhouse courses
Mastering AI APIs is a highly in-demand skill. According to McKinsey's reports on the state of AI, the adoption of generative AI in companies keeps growing, and with it the need for profiles who know how to integrate it into real products. To learn in a structured way, at Coderhouse you have options for every level:
To start from scratch: the Introduction to Artificial Intelligence Course gives you the conceptual framework to understand what these models do.
To build applications with AI: the AI Engineering Course goes deeper into how to integrate models and APIs into production projects.
To create autonomous agents: the AI Agents Course takes the use of APIs one step further, toward systems that reason and execute tasks.
Do you want to go from testing to building? Start with the Coderhouse AI Engineering Course and learn to connect AI to your own projects.
Frequently asked questions
Do I need to know how to program to use an AI API?
You need basic notions of Python or JavaScript: installing a library, defining variables, and running a script. You don't need to be an expert; with the examples from the official documentation you can make your first call in minutes.
Which API is best: GPT, Claude, or Gemini?
All three are excellent and are used very similarly. Gemini offers a generous free tier to start; GPT has the broadest community and documentation; Claude stands out in long-text and reasoning tasks. The ideal is to try all three and choose according to your use case and budget.
How much will I spend on a test project?
To experiment with short prompts and few users, the expense is usually a few dollars a month or even free using the entry tiers. The cost grows with the volume of calls and the size of the model, which is why it's a good idea to set usage limits from the start.
How do I protect my API key?
Store it in an environment variable or in a .env file that isn't uploaded to the repository, never write it directly in the code, and don't share it. If you think it leaked, revoke it and generate a new one immediately from the provider's panel.

About the author
I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.