In certain scenarios, responses from providers like Perplexity may include additional fields
that do not directly correspond to OpenAI fields. To retrieve these fields, use one of the following methods:
- Python SDK: Set the parameter
strict_open_ai_compliance=false when initializing the Obiguard client.
- Node SDK: Set the parameter
strictOpenAiCompliance: false when initializing the Obiguard client.
- HTTP Requests: Include the header
x-obiguard-strict-open-ai-compliance: false in your request.
By default, Obiguard Python and Node SDKs have strict_open_ai_compliance set to false.
Examples
Python SDK
OpenAI Python
cURL
from obiguard import Obiguard
client = Obiguard(
provider='openai',
base_url='https://gateway.obiguard.ai/v1',
obiguard_api_key='vk-obg***', # Your Obiguard virtual key here
strict_open_ai_compliance=False,
)
response = client.chat.completions.create(
messages = [{ "role": 'user', "content": 'Say this is a test' }],
model = "Qwen/Qwen2.5-32B-Instruct" # The LLM model tied to the virtual key
)
from openai import OpenAI
from obiguard import createHeaders
client = OpenAI(
base_url='https://gateway.obiguard.ai/v1',
api_key='sk-***', # Your OpenAI API key here
default_headers=createHeaders(
provider="openai",
api_key="sk-obg***", # Your Obiguard API key here
strict_open_ai_compliance=False,
)
)
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello!"}]
)
curl https://gateway.obiguard.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
-H "x-obiguard-provider: openai" \
-H "x-obiguard-strict-open-ai-compliance: false" \
-d '{
"model": "gpt-4o-mini",
"messages": [{
"role": "user",
"content": "Hello!"
}]
}'