从OpenAI的实际项目学Python_API.pdfVIP

  • 2
  • 0
  • 约5.61千字
  • 约 1页
  • 2024-08-14 发布于广西
  • 举报

PythonOpenAIAPICheatSheet

FullBlogTutorial:/openapi-cheat-sheet/

GettingStartedUsingGPT-4

Installation(CMD,Terminal,Shell,Powershell)system=Youonlyreplyinemojis!

pipinstallopenaiprompt=Whoareyou?

#or

pip3installopenaires=openai.ChatCompletion.create(

model=gpt-4,

FirstPromptmessages=[

importos{role:system,

importopenaicontent:system},

{role:user,

#Create,copy,andpasteyourAPIkeyhere:content:prompt}

openai.api_key=sk-123456789],

max_tokens=100,

response=openai.Completion.create(temperature=1.2)

model=text-davinci-003,

prompt=2+2=,print(res[choices][0][message][content])

temperature=0,max_tokens=10)#Answer:

JSONOutputFormatGeneratingImagesProgrammaticallywithDALL-E

{choices:[prompt=Anoilpaintingofadancingrobot

{

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档