Skip to content

Provider setup ​

Before any of the agent code can run, it needs to know where to send a request, which key authorizes it, and which model to ask for. This page gets those three values in place.

Your API key is a credential

Treat it the way you'd treat a password. Never paste it into a JavaScript file, never commit it, never post it in a Discord message asking for help. Anyone holding your key can spend your credit.

That rule is also why the course keeps every API call on a server instead of in the browser. Browser code is visible to anyone who opens their browser's developer tools, so a key used there is a key you've given away.

Check what you already have ​

If you've taken Intro to AI Engineering, these variables may still be saved in your Scrimba account.

Open Settings in the Scrimba editor, then select Edit Environment. You're looking for three entries named exactly AI_URL, AI_KEY, and AI_MODEL.

If all three are there and point at a provider you still have credit with, you're most likely ready. Jump ahead to recommended models and confirm the model in AI_MODEL supports tool calling, since that requirement is stricter in this course than it was in the last one.

If any are missing, or you want to switch providers, keep reading.

JunoCheck what you already have Before you sign up for anything, look in Settings, then Edit Environment. Intro to AI Engineering used these exact three names, so they may already be there.

Checking takes a few seconds and can save you creating an account you don't need.

JunoCheck what you already have The names carry over from Intro to AI Engineering unchanged. What to confirm rather than assume is that the model in AI_MODEL supports tool calling.

The previous course didn't need it, so a set of values that worked there can still fail here.

JunoCheck what you already have Reusing the values is fine. If you've lost track of where that key has been pasted since the last course, this is a good moment to rotate it: create a new key, save it, and revoke the old one.

Which provider ​

OpenAI is the safest default for this course. Its API is the one the Responses API comes from, and using it requires paid API credit. Costs depend on the model, request size, and how much you experiment, so check the current pricing before adding an amount you're comfortable using.

OpenRouter is the alternative if you can't or don't want to use OpenAI. It's a single API that routes to many providers, including free models, and it serves the same OpenAI-style Responses API the course calls, so the course code doesn't change.

Either way the setup follows the same pattern: create an account, generate a key, then store the provider's URL, your key, and a model ID.

JunoWhich provider Both providers work for every lesson. OpenAI is the one the lessons use, which makes it the easiest to follow along with.

Pick OpenRouter if paying OpenAI directly is awkward for you, or if you want one account that reaches many models.

JunoWhich provider The course code doesn't change between the two, because it uses the OpenAI client with AI_URL as its base URL. Pointing that URL at OpenRouter is the whole switch.
JunoWhich provider "OpenAI-compatible" holds well for the request shape and less well at the edges, where agent work lives: strict tool arguments, forcing or disabling tool use, structured output. OpenRouter passes your request to whichever upstream provider serves that model, so compatibility is per route, not per gateway.

Setting up OpenAI ​

Head to the OpenAI developer platform and sign in or create an account.

ChatGPT Plus is not API credit

The developer platform is billed separately from a ChatGPT subscription. Having ChatGPT Plus doesn't give your API account any credit.

Open Billing in the platform settings and add credit if your account needs it. You don't need an expensive model for this course: a small amount of credit with a lightweight model is enough to follow along.

Now open API keys in the platform settings and select Create new secret key. Give the key a name that helps you remember what it's for. When the key is created, copy it immediately, because the full value is shown only once.

Back in Scrimba, open Edit Environment and set:

dotenv
AI_URL=https://api.openai.com/v1
AI_KEY=your-api-key-here
AI_MODEL=gpt-5.4-nano

gpt-5.4-nano is the course's default model. See recommended models if you want something else. Save the environment variables once all three are in place.

JunoSetting up OpenAI The secret key is shown once, so copy it into Scrimba while the dialog is still open. If you close it too early, delete that key and create a new one.
JunoSetting up OpenAI Do two things in the same sitting: copy the key straight into Scrimba while it's visible, and set a spending limit in Billing before you leave.

A name you'll recognize later matters once you have several keys and need to revoke one.

JunoSetting up OpenAI A named key per use is what lets you revoke precisely. If you can't tell which key leaked, you have to revoke all of them and update everything that used them.

Setting up OpenRouter ​

Create an OpenRouter account, open the API Keys page, and create a key for Scrimba.

OpenRouter has free models, but they won't always be available or behave the same way from one run to the next, which makes it hard to tell whether an odd result came from your code or from the model. So the safer choice is the same as with OpenAI: load a small amount of credit and pick a lightweight paid model if you want consistent results.

If you do plan to use free endpoints, open the Privacy settings and review the data-policy options before enabling them. Free endpoints may route your requests to providers with different data policies, so make a deliberate decision before you send them anything real.

In Scrimba, set:

dotenv
AI_URL=https://openrouter.ai/api/v1
AI_KEY=your-api-key-here
AI_MODEL=mistralai/ministral-3b-2512

mistralai/ministral-3b-2512 is one of the recommended models for OpenRouter. Save the environment variables.

JunoSetting up OpenRouter Watch the model ID format. On OpenRouter it starts with the provider, so it's mistralai/ministral-3b-2512, not the short name on its own.
JunoSetting up OpenRouter The provider prefix is part of the ID, which is the thing to watch when you copy a model name from anywhere else.

If you enable free models, open Privacy first. It controls which upstream providers your requests may reach.

JunoSetting up OpenRouter The Privacy settings decide whether your prompts may go to endpoints that retain them or train on them, and the terms vary by upstream provider.

For course exercises that's low stakes, but the setting stays on the account for whatever you send later.

The three values move together ​

The most common setup failure is a mismatched set rather than a single wrong value. A valid key with the wrong provider's URL fails, and a valid provider setup with a model ID that provider doesn't offer fails too. Both produce authentication or model-not-found errors that read like something is broken in the course code.

So whenever you change providers, change AI_URL, AI_KEY, and AI_MODEL as one set, and save them together.

Running the code on your own machine?

Scrimba stores these as account-level environment variables, which is why there's no .env file in the browser project. On your own machine you'll put the same three values into a .env file instead. Running the code locally covers that.

JunoThe three values move together If you see an authentication or model-not-found error, check these three values before anything you wrote. Usually one of them is left over from a previous setup.
JunoThe three values move together Read all three values top to bottom before opening any code. If they match and the error says authentication, the key itself may be invalid or revoked, so create a new one.
JunoThe three values move together Both failures describe what went wrong at the provider, not why. A key sent to another provider's URL reads as a bad key, and a model outside the provider's catalog reads as a typo.

Where this goes next ​

Recommended models covers what makes a model suitable for agent work and which ones have been tested against this course. If you'd rather see how the request itself is put together, Chat Completions and Responses compares the two API shapes.

JunoWhere this goes next Pick a model next and put its ID in AI_MODEL.
JunoWhere this goes next Every model in its table has been tested for tool calling, so start there.
JunoWhere this goes next The API page shows the request these three values configure.