0% found this document useful (0 votes)
5 views1 page

Prompt Engineering - OpenAI API

The document discusses prompt engineering with the OpenAI API, highlighting how to generate text responses using a large language model. It provides a simple example of generating a one-sentence bedtime story about a unicorn using JavaScript code. The output from the model is structured in an array format, showcasing the generated content.

Uploaded by

hdfermin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Prompt Engineering - OpenAI API

The document discusses prompt engineering with the OpenAI API, highlighting how to generate text responses using a large language model. It provides a simple example of generating a one-sentence bedtime story about a unicorn using JavaScript code. The output from the model is structured in an array format, showcasing the generated content.

Uploaded by

hdfermin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

12/5/26, 7:40 p.m.

Prompt engineering | OpenAI API


Responses

Prompt engineering
Enhance results with prompt engineering strategies.
Copy Page

With the OpenAI API, you can use a large language model to generate text from a
prompt, as you might using ChatGPT. Models can generate almost any kind of text
response—like code, mathematical equations, structured JSON data, or human-like
prose.

Here’s a simple example using the Responses API.

Generate text from a simple prompt javascript

1 import OpenAI from "openai";


2 const client = new OpenAI();
3
4 const response = await [Link]({
5 model: "gpt-5.5",
6 input: "Write a one-sentence bedtime story about a unicorn."
7 });
8
9 [Link](response.output_text);

An array of content generated by the model is in the output property of the response. In
this simple example, we have just one output which looks like this:

1 [
2 {
3 "id": "msg_67b73f697ba4819183a15cc17d011509",
4 "type": "message",
5 "role": "assistant", 

[Link] 1/1

You might also like