Hello!

BrainTech - software solutions, web design and applications.

Module 2 – First OpenAI API call Exercise

Exercise: first AI chat

Exercise: first AI chat

In this exercise you build a concrete part of FirmAssist through the 'Exercise: first AI chat' scenario so that you finish with a working artifact, not just theory.

You now bootstrap FirmAssist: API key, folder structure, and the first PHP call that returns a model response.

Task

  1. Create a `.env` file and load the API key only on the server.
  2. Add a small PHP endpoint that receives a question.
  3. Send the first prompt to the model and return JSON.
  4. Render the answer in a simple HTML interface.
  5. Handle empty input and provider failures.
  6. Store one sample request/response pair for debugging.

Practical example

Starter skeleton for the practical exercise.

$exercise = [
    'slug' => 'vezba-prvi-ai-chat',
    'target' => 'first chat endpoint',
    'project' => 'FirmAssist',
    'done' => false,
];

print_r($exercise);

Goal: The goal is to leave this exercise with a small but usable block of FirmAssist that you can extend later.

Design Wireframe
High Fidelity Design
Design development
Design development
Design development
Research development