Obiguard ensures that all responses strictly adhere to the OpenAI specification by default.
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.
from obiguard import Obiguardclient = 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)
Copy
from obiguard import Obiguardclient = 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)
Copy
from openai import OpenAIfrom obiguard import createHeadersclient = 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!"}])