Congratulations!

Working with the OpenAI API

James Chapman

Curriculum Manager, DataCamp

Chapter 1

 

  • What the OpenAI API is used for
  • How to create requests to the Chat Completions endpoint

A computer connecting to the OpenAI via one of several access points, which are in-turn connected to different servers.

client = OpenAI(api_key="<OPENAI_API_TOKEN>")

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "..."}]
)
print(response.choices[0].message.content)
Working with the OpenAI API

Chapter 2

response = client.chat.completions.create(
  model="gpt-4o-mini",
  messages=[{"role": "user", "content": "..."}],
  max_completion_tokens=20,
  temperature=0.5
)
  • Q&A
  • Text transformation
  • Content generation
  • Sentiment analysis
  • Categorization
  • max_completion_tokens and temperature

Different OpenAI model applications.

Working with the OpenAI API

Chapter 3

 

  • "system"

    • Steer model outputs
    • Add guardrails
  • "assistant"

    • Structured few-shot prompting
    • Build a conversation history

The three roles in a chat interaction: the system, the user, and the assistant.

Working with the OpenAI API

What next?

Working with the OpenAI API

Let's practice!

Working with the OpenAI API

Preparing Video For Download...