You are on page 1of 3

import openai

# Set your OpenAI API key here

api_key = 'YOUR_API_KEY'

# Initialize the OpenAI API client

openai.api_key = api_key

# Prompt for the AI model

prompt = "Once upon a time in a land far, far away"

# Generate text using the AI model

response = openai.Completion.create(

engine="text-davinci-003", # You can choose other engines like 'davinci-codex' as well

prompt=prompt,

max_tokens=100 # Adjust the length of the generated text

# Extract and print the generated text

generated_text = response.choices[0].text

print(generated_text) import openai

# Set your OpenAI API key here

api_key = 'YOUR_API_KEY'

# Initialize the OpenAI API client

openai.api_key = api_key

# Prompt for the AI model


prompt = "Once upon a time in a land far, far away"

# Generate text using the AI model

response = openai.Completion.create(

engine="text-davinci-003", # You can choose other engines like 'davinci-codex' as well

prompt=prompt,

max_tokens=100 # Adjust the length of the generated text

# Extract and print the generated text

generated_text = response.choices[0].text

print(generated_text) import openai

# Set your OpenAI API key here

api_key = 'YOUR_API_KEY'

# Initialize the OpenAI API client

openai.api_key = api_key

# Prompt for the AI model

prompt = "Once upon a time in a land far, far away"

# Generate text using the AI model

response = openai.Completion.create(

engine="text-davinci-003", # You can choose other engines like 'davinci-codex' as well

prompt=prompt,

max_tokens=100 # Adjust the length of the generated text

)
# Extract and print the generated text

generated_text = response.choices[0].text

print(generated_text)

You might also like