✨ Generative AI
Calling an AI API with fetch()
AI models are accessed over the internet using APIs. You send a POST request with your prompt as JSON, the server runs the AI model, and sends back the response. Let's see the structure — even if you don't have an API key, you'll understand exactly how it works!
3 min 10 XP Lesson 3 of 7

AI models are accessed over the internet using APIs. You send a POST request with your prompt as JSON, the server runs the AI model, and sends back the response. Let's see the structure — even if you don't have an API key, you'll understand exactly how it works!
Quick Quiz
What does the 'Authorization' header contain?