Safety best practices

Developing AI Systems with the OpenAI API

Francesca Donadoni

Curriculum Manager, DataCamp

Safety with the OpenAI API

A circle with the OpenAI API

Developing AI Systems with the OpenAI API

Safety with the OpenAI API

A circle with the OpenAI API that intersects with another labeled 'ethics and fairness'

Developing AI Systems with the OpenAI API

Safety with the OpenAI API

A circle with the OpenAI API that intersects with other two labeled 'ethics and fairness' and 'alignment'

Developing AI Systems with the OpenAI API

Safety with the OpenAI API

A circle with the OpenAI API that intersects with other three labeled 'ethics and fairness', 'alignment' and 'privacy of data'

Developing AI Systems with the OpenAI API

Safety with the OpenAI API

A circle with the OpenAI API that intersects with other four labeled 'ethics and fairness', 'alignment', 'privacy of data', and 'security of the system'

Developing AI Systems with the OpenAI API

Best practices

 

  • Moderation API
  • Adversarial testing
  • Limit user input and output tokens
  • Prompt engineering
1 https://platform.openai.com/docs/guides/safety-best-practices
Developing AI Systems with the OpenAI API

Best practices

 

  • Human in the loop
  • "Know your customer"
  • Allow users to report issues

An illustration of customer and developer working together to improve the product based on feedback

Developing AI Systems with the OpenAI API

Best practices

 

  • Keep your API keys safe
  • Communicate limitations

A shield representing safety

Speech bubbles representing communication

Developing AI Systems with the OpenAI API

Using end-user IDs

import uuid

unique_id = str(uuid.uuid4())
response = client.chat.completions.create(  
  model="gpt-4o-mini", 
  messages=messages,
  user=unique_id)
print(unique_id)
ad58af43-19b1-4fd8-9905-5ed3bce7e008
Developing AI Systems with the OpenAI API

Keeping your API key safe

 

  • Unique API key

  • Server-side security

  • Avoid repository exposure

  • Environment variables

  • Key management services

  • Monitor and rotate keys

Developing AI Systems with the OpenAI API

Let's practice!

Developing AI Systems with the OpenAI API

Preparing Video For Download...