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

# Using the Paradigm API via a Proxy in Python

> Learn how to configure your requests to work with the Paradigm API when your company uses a proxy.

If your company uses a proxy to access external APIs, you need to specify its configuration in your requests to allow connection to our API's Python client.

Three methods are available to configure proxy usage:

* At the request level
* At the session level
* At the environment level

## Configuration Examples

Here is a configuration example for each method mentioned above.

<AccordionGroup>
  <Accordion title="Request Configuration" icon="code" iconType="regular">
    ```python theme={null}
    import requests
    import ssl
    import os

    api_key = os.getenv("PARADIGM_API_KEY")
    base_url = os.getenv("PARADIGM_BASE_URL", "https://paradigm.lighton.ai/api/v2")

    # Proxy configuration
    proxies = {
        'http': 'http://proxy.example.com:port',
        'https': 'https://proxy.example.com:port'
    }

    # Request example
    response = requests.post(
        f"{base_url}/chat/completions",
        headers={"Authorization": f"Bearer {api_key}"},
        json={"model": "alfred-ft5", "messages": [{"role": "user", "content": "Hello"}]},
        proxies=proxies,
        verify=False
    )

    print(response.json())
    ```
  </Accordion>

  <Accordion title="Session Configuration" icon="code" iconType="regular">
    ```python theme={null}
    import requests
    import os

    api_key = os.getenv("PARADIGM_API_KEY")
    base_url = os.getenv("PARADIGM_BASE_URL", "https://paradigm.lighton.ai/api/v2")

    # Proxy configuration
    proxies = {
        'http': 'http://proxy.example.com:port',
        'https': 'https://proxy.example.com:port'
    }
    session = requests.Session()
    session.proxies.update(proxies)
    session.verify = False

    # Request example
    response = session.post(
        f"{base_url}/chat/completions",
        headers={"Authorization": f"Bearer {api_key}"},
        json={"model": "alfred-ft5", "messages": [{"role": "user", "content": "Hello"}]},
    )

    print(response.json())
    ```
  </Accordion>

  <Accordion title="Environment Configuration" icon="code" iconType="regular">
    |           Parameter          | Description                                                 |
    | :--------------------------: | ----------------------------------------------------------- |
    | `"HTTP_PROXY" "HTTPS_PROXY"` | Address and port of the proxy used for HTTP(S) connections. |
    |          `NO_PROXY`          | List of addresses that should bypass the proxy.             |

    ```python theme={null}
    import requests
    import os

    api_key = os.getenv("PARADIGM_API_KEY")
    base_url = os.getenv("PARADIGM_BASE_URL", "https://paradigm.lighton.ai/api/v2")

    # Proxy configuration
    os.environ["HTTP_PROXY"] = "http://proxy.example.com:port"
    os.environ["HTTPS_PROXY"] = "https://proxy.example.com:port"
    os.environ["NO_PROXY"] = "localhost,127.0.0.1"

    # Request example
    response = requests.post(
        f"{base_url}/chat/completions",
        headers={"Authorization": f"Bearer {api_key}"},
        json={"model": "alfred-ft5", "messages": [{"role": "user", "content": "Hello"}]},
    	verify=False
    )

    print(response.json())
    ```
  </Accordion>
</AccordionGroup>

## TLS Certificate

<Warning>
  The examples above have TLS certificate verification disabled, which should only be used for testing purposes.
</Warning>

When the `verify` parameter is set to `False`, requests will accept any TLS certificate presented by the server and ignore hostname mismatches and/or expired certificates, which makes your application vulnerable to man-in-the-middle (MitM) attacks. Setting `verify` to `False` may be useful during development or local testing.

The `verify` parameter can also be a string, in which case it must be a path to a CA bundle to use. The default value is `True`.
