讓第一版跑起來
本課次尚無繁體中文譯文,以下內容為英文原文。
Draft: this lesson is an outline and will be expanded.
Now your app gets its first working AI feature. An API is a way for one program to ask another program for something. Your app will use the model service’s API: it sends your prompt and receives the model’s answer. You finish with the feature working on your own computer.
What you will do
- Choose a model service that you can reach and are allowed to use. Create an account and an API key, which is a long secret code that identifies you to the service. Do not paste the key into a chat, a file in your project or a website. The next lessons explain where it goes.
- Give your assistant your feature brief and say: “Add this feature to my app. Call the model service through its API. Read the key from a place outside the project files. Keep the first version as small as possible.”
- Tell the assistant which service you chose. Do not ask it for a price or a model name from memory. Look at the service’s own pages for the current choices and costs, and pick the cheapest option that suits a first test.
- Let the assistant make the change. Run the app as you did in the earlier courses.
- Try your first test input from the brief. Compare the answer with what you wrote down.
- If you see an error, copy the exact message and give it to the assistant. If three tries do not fix it, go back to your last checkpoint and describe the goal again in different words.
- When it works, save a checkpoint with a short message such as “First AI feature works”.
Check yourself
- Your app shows an answer from the model for your first test input.
- The key is not written in any project file you can see.
- A failure, such as turning off your internet, shows the plain message from your brief.
- You saved a checkpoint after it worked.