Skip to main content
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.
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-4.2", "messages": [{"role": "user", "content": "Hello"}]},
    proxies=proxies,
    verify=False
)

print(response.json())
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-4.2", "messages": [{"role": "user", "content": "Hello"}]},
)

print(response.json())
ParameterDescription
"HTTP_PROXY" "HTTPS_PROXY"Address and port of the proxy used for HTTP(S) connections.
NO_PROXYList of addresses that should bypass the proxy.
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-4.2", "messages": [{"role": "user", "content": "Hello"}]},
	verify=False
)

print(response.json())

TLS Certificate

The examples above have TLS certificate verification disabled, which should only be used for testing purposes.
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.
I