Aan de slagGa gratis aan de slag

Your first OpenAI API request!

To preview what’s ahead, the Python code for sending a request to the OpenAI API is ready for you.

Pass any question or instruction to the content argument and see how OpenAI's model responds!


Here are a few prompts to try if you're struggling for ideas:

  • Why is learning the OpenAI API valuable for developers?
  • Suggest three tasks I could automate with the OpenAI API in my job.
  • In two sentences, how can the OpenAI API be used to upskill myself?

Deze oefening maakt deel uit van de cursus

Working with the OpenAI API

Cursus bekijken

Oefeninstructies

  • Enter your prompt replacing INSERT YOUR PROMPT HERE, experiment, and submit your answer when ready!

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

response = client.chat.completions.create(
    model="gpt-4o-mini",
    max_completion_tokens=100,
  
    # Enter your prompt
    messages=[{"role": "user", "content": "INSERT YOUR PROMPT HERE"}]
)

print(response.choices[0].message.content)
Code bewerken en uitvoeren