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.
Checking takes a few seconds and can save you creating an account you don't need.
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.
Pick OpenRouter if paying OpenAI directly is awkward for you, or if you want one account that reaches many models.
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:
AI_URL=https://api.openai.com/v1
AI_KEY=your-api-key-here
AI_MODEL=gpt-5.4-nanogpt-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.
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:
AI_URL=https://openrouter.ai/api/v1
AI_KEY=your-api-key-here
AI_MODEL=mistralai/ministral-3b-2512mistralai/ministral-3b-2512 is one of the recommended models for OpenRouter. Save the environment variables.
mistralai/ministral-3b-2512, not the short name on its own. 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.
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.
AI_MODEL. 
