Skip to content

Setting up for Learn 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 Learn 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. The last two are for when you want the code on your own machine, and then online.

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 model answers.

They only work as a matched set, so change all three together whenever you switch. One provider's key with another provider's URL is the mistake to watch for.

JunoWhat you'll set up The failure you're most likely to hit is not a typo in one value. It's 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 authentication or model-not-found error, re-read all three before you read any of your own code.

JunoWhat you'll set up A mismatch is worth this attention because the errors point away from it. A provider that receives a key it never issued answers as if the key were bad, and a provider asked for a model outside its catalog answers as if you mistyped the name.

Both are the same fault, an inconsistent set, and neither message says so.

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.

Deploying your agent app is the step after the course: putting the finished OpenSwap app, or your Charta solo project, online with a production build and a host.

JunoThe pages in order In the browser, the first three pages are all you need: set up a provider, pick a model, then see the request the course sends.

The last two can wait until you want the project on your own computer or online.

JunoThe pages in order Each page depends on the one before it. The variables come first, the model goes into one of them, and the API page shows the request those values feed.

The same three values follow you off Scrimba: into a .env file when you run locally, and into the host's settings when you deploy.

JunoThe pages in order The last two pages rest on one design choice: the Express server holds your key and makes every model request.

That is why the same code runs in Scrimba, on your machine and on a host, with only the environment changing.

One thing to decide up front ​

The course code uses the OpenAI client pointed at whatever AI_URL you set, and it calls the Responses API. So a provider has to do more than accept OpenAI-shaped requests. It has to serve Responses, and the model behind it has to call tools reliably through it. The routes on the recommended models page have been tested that way.

Tool calling is the requirement that doesn't bend. This course builds its agent on the model's native tool calling: the model returns a structured request to run one of your functions, and your code runs it. Agents can be built in other ways, but this course's code can't run without it, however the rest 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.

The agent in this course works by asking your code to run something, so a model that can't make that request can't run it. The shortlist on the models page has this checked already.

JunoOne thing to decide up front Off the recommended list, check two things: the model card lists tool calling, usually as "function calling" or "tools", and the provider serves the Responses API, not only Chat Completions.

When a lesson misbehaves and your code matches the solution, swap in a known-good model before you reread your own work. It's a quick test that rules out the cause people check last.

JunoOne thing to decide up front Tool support belongs to the served endpoint, not only to the model. On OpenRouter one model can be served by several upstream providers, and a catalog listing doesn't prove every route handles tools through Responses.

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

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.

JunoOther Scrimba AI courses Here for a different course? Pick it in the index and follow that guide instead.
JunoOther Scrimba AI courses Each guide follows its own project, so don't mix steps between them.
JunoOther Scrimba AI courses Some projects call their provider with their own variable names, so take the names from each guide.
Take Learn AI Agents on ScrimbaLearn AI Agents takes you from a single model call to an agent that calls tools and acts on the results.