Using the OpenAI Library

Install the following required dependencies:

pip install openai httpx

Copy the token you obtained and replace it in the token variable:

from pathlib import Path
from openai import OpenAI
import httpx

# 1. Load DSID
dsid = Path("~/.ivanti_dsid").expanduser().read_text().strip()

# 2. Put the obtained token here
token = "YOUR_OPENWEBUI_TOKEN"

# 3. Create client
client = OpenAI(
    api_key=token,
    base_url="https://extranet.scayle.es:11010/api",
    default_headers={
        "Cookie": f"DSID={dsid}; token={token}"
    },
    http_client=httpx.Client(
        verify=False,
        timeout=30.0
    )
)

# 4. Make a request
response = client.chat.completions.create(
    model="qwen3",
    messages=[
        {"role": "user", "content": "Hello, how are you?"}
    ]
)

# 5. Show response
print(response.choices[0].message.content)