Building with AI APIs · ProLesson 1 of 6 · 10 min
Your first AI API call, and what it costs
Keys, requests, responses and tokens: everything you need to call a model from your own code, safely.
Chat apps are great for one-off work. When you want AI inside your own tools (a support inbox, a report generator, an internal app), you call a model through its API. Every major provider works the same way: you send a request with instructions and messages, and get back a response plus a count of the tokens used.
Keep your key secret
- Create an API key in your provider's console and store it as an environment variable, never in code or in git.
- Use separate keys for development and production, and set a monthly spending limit in the console.
- Call the API from your server, never from a web page where anyone can read the key.
Unlock the rest of this lesson with Pro
In this lesson
- Keep your key secret
- A complete first call
- How cost works
- Hands-on practice with personal feedback from Arvid
- A quick quiz to check what you learned
Unlock this lesson and every lesson in the Foundations, Advanced and Expert levels and all courses, plus certificates and a monthly allowance of AI practice, for $12/month.
Start free, upgrade anytime
Already have an account? Log in