> ## Documentation Index
> Fetch the complete documentation index at: https://docs.obiguard.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Strict OpenAI Compliance

> Obiguard ensures that all responses strictly adhere to the [OpenAI specification](https://platform.openai.com/docs/api-reference/chat/create) 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.

<Note>By default, Obiguard Python and Node SDKs have `strict_open_ai_compliance` set to `false`.</Note>

## Examples

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    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
    )
    ```
  </Tab>

  <Tab title="OpenAI Python">
    ```python theme={null}
    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!"}]
    )
    ```
  </Tab>

  <Tab title="cURL">
    ```curl theme={null}
    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!"
        }]
      }'
    ```
  </Tab>
</Tabs>
