LearnAI
Module 9 · AI integration via API (Pro) · Lesson 1/5
← Back to catalog
Task

Call AI via API

What is important to understand when calling an API? Return JSON {"essentials": [list of 2+ things], "why": "brief"}.

Unlock access to submit solutions for instant AI review.Start for free
ABC of integration
💡 A bit of theory

Calling a model from code is a regular HTTP request to the provider's API: you send messages and parameters, and receive a response. What is important to understand: separation of roles - the system message sets the behavior, user - the user request; generation parameters: temperature (0 - stable and deterministic, higher - more creative), max_tokens (length and cost limit); the answer must be parsed and validated, and not blindly trusted; API key is a secret, only on the server. Rule: from the code you control the model through messages plus parameters and always validate the response; Chat amenities (memory, formatting) will not appear on their own - you set them up.

How it's graded · passing score 70

  • 1Valid JSON without text around it30%
  • 2There is an array essentials and why35%
  • 32+ things: roles system/user, temperature/max_tokens, response validation, key on the server35%
Your promptClaude ⌄