OpenAI
Wrap OpenAI chat completion calls with aiguard.chat(). The wrapper is a drop-in replacement.
Install
$
pip install aiguard-safetySet OPENAI_API_KEY in your environment.
Code
app.pypython
import aiguard
response = aiguard.chat(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "What is PSD2?"},
],
metadata={"feature": "knowledge-base"},
)
print(response.choices[0].message.content)aiguard.yaml
yaml
model:
provider: openai
model_name: gpt-4o
api_key_env: OPENAI_API_KEY