Source:aoai-app.py · GitHub · microsoft/generative-ai-for-beginners
Authors: Microsoft (microsoft)
Licence: MIT — https://spdx.org/licenses/MIT.html
fromopenaiimportAzureOpenAI,BadRequestErrorimportosfromPILimportImageimportdotenvimportjsonimportbase64# import dotenvdotenv.load_dotenv()# Assign the API version (check the Microsoft Foundry docs for the current API version required by your model)client=AzureOpenAI(api_key=os.environ['AZURE_OPENAI_API_KEY'],# this is also the default, it can be omittedapi_version="2025-04-01-preview",azure_endpoint=os.environ['AZURE_OPENAI_ENDPOINT'])model=os.environ['AZURE_OPENAI_DEPLOYMENT']try:# Create an image by using the image generation APIresult=client.images.generate(model=model,prompt='Bunny on horse, holding a lollipop, on a foggy meadow where it grows daffodils. It says "hello"',# Enter your prompt text heresize='1024x1024',n=1)generation_response=json.loads(result.model_dump_json())# Set the directory for the stored imageimage_dir=os.path.join(os.curdir,'images')# If the directory doesn't exist, create itifnotos.path.isdir(image_dir):os.mkdir(image_dir)# Initialize the image path (note the filetype should be png)image_path=os.path.join(image_dir,'generated-image.png')# Retrieve the generated image# gpt-image models return the image as base64 (b64_json), not a URLimage_b64=generation_response["data"][0]["b64_json"]generated_image=base64.b64decode(image_b64)withopen(image_path,"wb")asimage_file:image_file.write(generated_image)# Display the image in the default image viewerimage=Image.open(image_path)image.show()# catch exceptions#except BadRequestError as err:# print(err)finally:print("completed!")
Metadata record
One description, two standard projections
Built from what the sources declared and what the gates observed.
Nothing absent has been filled in here.
6 links to or from other resources — a lab's files, the pages it links, the works it cites stand under their elements, marked inferred, and are kept apart in the exports.
DCMI Metadata Terms. Dublin Core has no element that separates the original file from the text extracted out of it, and none for LOM's educational characterisation. Both survive here as provenance statements and in the record itself, not in the projection.
the standard ↗
The groups below are this library's, for reading. DCMI Terms itself has no categories; each term keeps its standard name.
Works this one cites, when the source declares them as relations. What its text links to and its reference list cites is inferred, and stands under it apart.
What needs this resource, when a source declares it. The lab a component belongs to is inferred, and stands under it apart.
Provenancedcterms:provenance
this engine
source
conversion
code
Retrieved from GitHub on 2026-10-09 in response to the search string “AI "AI concepts" in:name,description,readme fork:false archived:false”. GitHub served the resource and is not asserted to be its publisher or author.
Text extracted from code to Markdown by material; the original is retained unchanged beside it.
Found inside repository microsoft/generative-ai-for-beginners, whose own description is recorded separately and is not a description of this resource.
Where it was collected from, what was converted, and what container it came out of — the custody statements that would otherwise be mistaken for authorship.
IEEE 1484.12.1 Learning Object Metadata. LOM has no element for an SPDX identifier or a licence URI, so both are written into 6.3 Rights.Description. Flattening this record into simple Dublin Core would lose more again, which is why the two projections exist side by side rather than one being generated from the other.
the standard ↗
Microsoft (microsoft) [https://github.com/microsoft] — content provider (contribution recorded against the container this resource was found in, not against the resource)
Role, entity and date per declared contribution. A role outside LOM's vocabulary is reported in the entry's description instead.
3 Meta-metadata
4/4
Identifier3.1
this engine
resource_id
URI: tag:aim-pro.eu,2026:oer/ad4220251d63/record
The identifier of this metadata record — the resource's own, with /record after it, because the record is a description of the resource and not the resource.
Contribute3.2
this engine
source
AIM-PRO WP3 OER harvester (GitHub) — creator
Who generated this record and when — a statement about the record, not about the resource.
Metadata schema3.3
LOMv1.0
aimpro-oer-profile/1
LOMv1.0, and the profile this was built against.
Language3.4
en
4 Technical
3/7
Format4.1
conversion
code
text/markdown
One value per form held: the original as the source published it, and the Markdown this engine extracted.
Size4.2
conversion
code
2067
Bytes. The original's, because the resource is the file and not our conversion of it.
Yes unless the licence reserves nothing — attribution is a restriction. The conditions after the dash are the licence gate's reading; the export carries LOM's bare term.
The container a file was found inside, and the Markdown extracted from the original. What a lab requires, and the lab a component belongs to, are inferred and stand apart.
8 Annotation
0/3
Entity8.1
not collected — this library does not fill it
Comments on the resource's educational use, by whoever made them. The platform's review grades competencies, which are classification (9), and writes no comment here.
Date8.2
not collected — this library does not fill it
Description8.3
not collected — this library does not fill it
9 Classification
0/4
Purpose9.1
not collected — this library does not fill it
Empty in the record: no source declares a competency. The alignment reads the resource for them and stands beside the record, never in it, and a taxon path derived from the search string that found it would be a claim about the query.
Taxon path9.2
not collected — this library does not fill it
Where the competency framework goes. Empty in the record for the reason above.
Description9.3
not collected — this library does not fill it
Keyword9.4
not collected — this library does not fill it
What could not be established8
Where the source's metadata could not be carried
over as it was — missing, contradictory, with no matching term in the
standard, restructured, or taken from the repository — and what was done
instead. Without these notes, an empty element would look like something
the harvester missed.
Status
Field
Why
Not available
description
the only description available is the repository's own, which describes microsoft/generative-ai-for-beginners and not this resource. It is kept against the container and the resource's description is left empty
Not available
creators
nobody is named as an author of this resource — the contributions recorded are about the container or carry a non-authorial role
Not available
dates
no publication date was declared; a collection date is not one and is kept separately
Not available
declared_language
the source declared no language; the recorded content language is this engine's reading of the text
Not available
rights_holder
no rights holder is named at source; the licence is recorded without one rather than attributed to the platform that served it
Not available
publisher
the source named no publisher of the work; where it was collected from is recorded as collection provenance instead, which is a different claim
Not available
educational
the source declared no educational metadata — no resource type, audience, context, difficulty or learning time. Nothing here estimates them
Declared, not mapped
structure_role
this file sits in the container as 'material' by directory convention. That is a fact about the repository's layout, not a declaration that the resource is of that educational type, so no educational element is filled from it