The L&S AI Inference API is fully OpenAI-compatible. If you've used the openai Python library before, almost nothing changes — just point it at the L&S endpoint and use your L&S API key.
Before you start: You'll need an API key. Email [contact] to request one.
from openai import OpenAI
client = OpenAI(
api_key="your-lsit-api-key",
base_url="https://api.ai.college.ucsb.edu/v1"
)
It's good practice to load your API key from an environment variable rather than hardcoding it:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["LSIT_API_KEY"],
base_url="https://api.ai.college.ucsb.edu/v1"
)
Set it in your shell:
export LSIT_API_KEY="your-lsit-api-key"
response = client.chat.completions.create(
model="Qwen3-Coder-Next",
messages=[
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function that parses a CIDR block and returns all host addresses."}
]
)
print(response.choices[0].message.content)
messages = [
{"role": "system", "content": "You are a helpful research assistant."}
]
while True:
user_input = input("You: ")
if user_input.lower() in ("exit", "quit"):
break
messages.append({"role": "user", "content": user_input})
response = client.chat.completions.create(
model="gemma-4-31b",
messages=messages
)
reply = response.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
print(f"Assistant: {reply}\n")
models = client.models.list()
for model in models.data:
print(model.id)