OER·harvester

← Back to the library
GitHub NOTEBOOK resource

Oai Assigment Simple

Repository 21 Lessons, Get Started Building with Generative AI

Licence
OPEN MIT
Authors
Microsoft (microsoft)
Updated
2026-07-14 · GitHub
Language
en detected
Length
40 words
Open original ↗
{ }
Jupyter notebook Converted to a read-only view · code is not executed

Source: Oai Assigment Simple · GitHub · microsoft/generative-ai-for-beginners Authors: Microsoft (microsoft) Licence: MIT — https://spdx.org/licenses/MIT.html

In [1]
import os
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("OPENAI_API_KEY","").strip()
assert API_KEY, "ERROR: OpenAI Key is missing"
client = OpenAI(
    api_key=API_KEY
    )

model = "gpt-5-mini"
In [2]
# Create your first prompt
text_prompt = " My foot hurts, what can be wrong?"

response = client.responses.create(
  model=model,
  input = [
      {"role":"system", "content":"I'm a doctor, specialist on surgery"},
      {"role":"user","content":text_prompt},],
  store=False,)

response.output_text