Skip to content

Setting up for Intro to AI Agents ​

Building an agent takes surprisingly little setup. You need somewhere to send a request, permission to send it, and a model on the other end that can call tools.

That's three values. The rest of this guide is about getting them right the first time, so that nothing in the course fails for a reason that has nothing to do with agents.

These pages accompany Scrimba's Intro to AI Agents course, and they stand on their own. If you're working through the course in the browser, you only need the first three pages. If you'd rather have the code on your own machine, the last page covers that too.

The course code is JavaScript, and the JavaScript handbook is there if you want to shore that up first.

What you'll set up ​

Three environment variables carry everything the course code needs to reach a model:

VariableWhat it holds
AI_URLThe provider's API base URL, which is where requests get sent
AI_KEYYour API key, which is what authorizes those requests
AI_MODELThe ID of the specific model you want to talk to

They have to agree with each other. A valid key pointed at the wrong provider's URL fails, and a correct provider with a model ID that provider doesn't serve fails too. Whenever you switch providers, change all three together.

Coming from Intro to AI Engineering?

These are the same three variables that course used. If you already have them saved in Scrimba, you may be able to skip straight to recommended models and confirm your model supports tool calling.

JunoWhat you'll set upAI_URL, AI_KEY and AI_MODEL are one setting in three parts. The URL says which company you're talking to, the key proves you're allowed to, and the model says which brain answers.

They only work as a matched set, so change all three together whenever you switch. Mixing one provider's key with another's URL is the mistake nearly everyone makes once!

JunoWhat you'll set up These three are a matched set, and the failure you will actually hit is not a typo in one of them. It is a leftover: a key from the provider you used last month sent to the URL you configured today.

So treat switching providers as one edit with three parts. If you get an auth error or a model-not-found error, re-read all three before you read any of your own code.

JunoWhat you'll set up The reason a mismatch is worth this much attention is that the error messages lie about where the problem is. A key sent to the wrong base URL comes back as a 401, which reads as "your key is bad" when the key is fine. A model your provider doesn't serve comes back as a 404 on the model name, which reads as a typo.

Both are the same underlying fault, and neither message points at it. Keeping the three values together in your head as one unit is what saves you the half hour.

The pages in order ​

Provider setup walks through creating an account with OpenAI or OpenRouter, generating an API key, and storing all three values.

Recommended models covers the one hard requirement, tool calling, and gives a tested shortlist so you don't have to guess.

Chat Completions and Responses explains the two OpenAI APIs you'll see in the wild, how their request and reply shapes differ, and why this course uses Responses.

Running the code locally is for when you want the project off Scrimba and onto your own machine, covering the download, the .env file, installing dependencies, and the port collisions that catch people out.

One thing to decide up front ​

Almost everything in this course works with any provider that speaks the OpenAI API shape. What doesn't vary is the requirement that your model can call tools.

An agent is a model that decides to use a tool, so a model without tool calling can't be made into one however the rest of the code is written. Keep that in mind if you go exploring beyond the recommended list, because a model limitation and a bug in your code look identical from the console.

JunoOne thing to decide up front Tool calling is the one thing a model has to be able to do here. Everything else is preference: how fast it is, what it costs, how chatty it gets.

An agent is a model that asks your code to run something, so a model that can't make that request can't be an agent at all. The shortlist on the models page has this checked already, so you don't have to work it out yourself.

JunoOne thing to decide up front Tool calling is the hard requirement, and it is the first thing to check when you go off the recommended list. Model cards state it, usually as "function calling" or "tools".

Build the habit now: when a lesson misbehaves and your code matches the solution, swap in a known-good model before you reread your own work. It is a thirty-second test that rules out the cause people check last.

JunoOne thing to decide up front Tool calling is a capability of the served endpoint, not only of the model, which is the part that catches people. The same weights behind a different route can come back without tool support, and a free tier may serve a quantized or otherwise trimmed variant with the feature missing.

That is why the shortlist names routes and not only model families. When a model that should support tools appears not to, check which route you're actually hitting before you conclude the model is at fault.

Other Scrimba AI courses ​

Every other AI course and project has its own local setup guide. Run an AI course project locally is the index for those, covering the AI Engineer Path, Chef Claude, and Intro to Mistral AI.

Take the AI Engineer Path on ScrimbaScrimba's AI Engineer Path takes you from your first LLM call to agents, RAG and MCP across nine interactive modules.