9951 explained code solutions for 126 technologies


python-openaiOpenAI API example in Python


OpenAI API is a Python library that allows developers to access OpenAI's services and use them in their applications.

Example code

import openai
openai.api_key = "YOUR_API_KEY"
response = openai.Completion.create(
    engine="davinci",
    prompt="The quick brown fox",
    max_tokens=50
)

Edit this code on GitHub