The L&S AI Inference API is OpenAI-compatible. If you've used the openai Python library before, almost nothing changes — point it at the L&S endpoint and use your L&S API key.
Before you start: You'll need an API key. Request one under Other Requests at https://cloud.college.ucsb.edu/contact.
| Model ID | Best for | Context |
|---|---|---|
gemma-4-26b-a4b-it |
General chat, writing, and image input | 256k |
qwen3.8-27b |
STEM, long documents, and code | 256k |
gpt-oss-120b |
Complex reasoning and research synthesis | 128k |
Install the client:
pip install openai
Load your API key from an environment variable rather than hardcoding it:
export LSIT_API_KEY="your-lsit-api-key"
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["LSIT_API_KEY"],
base_url="https://api.ai.college.ucsb.edu/v1"
)
response = client.chat.completions.create(
model="qwen3.8-27b",
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-26b-a4b-it",
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)