The L&S AI Inference API speaks standard OpenAI-compatible REST. If your tool, script, or language can make an HTTP POST request, it can use this API.
Before you start: You'll need an API key. Email [contact] to request one.
| Model ID | Best for | Context |
|---|---|---|
Qwen3-Coder-Next |
Code generation and review | 128k |
gpt-oss-120b |
Complex reasoning, long-context tasks | 128k |
gemma-4-31b |
General chat, writing, analysis | 128k |
curl https://api.ai.college.ucsb.edu/v1/chat/completions \
-H "Authorization: Bearer $LSIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-4-31b",
"messages": [
{"role": "user", "content": "What is the capital of California?"}
]
}'
Response:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "gemma-4-31b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of California is Sacramento."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 9,
"total_tokens": 24
}
}
Extract just the reply text with jq:
curl https://api.ai.college.ucsb.edu/v1/chat/completions \
-H "Authorization: Bearer $LSIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-4-31b",
"messages": [{"role": "user", "content": "What is the capital of California?"}]
}' | jq -r '.choices[0].message.content'
Add "stream": true to receive server-sent events (SSE) as the response generates:
curl https://api.ai.college.ucsb.edu/v1/chat/completions \
-H "Authorization: Bearer $LSIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma-4-31b",
"messages": [{"role": "user", "content": "Explain Kubernetes in simple terms."}],
"stream": true
}'
Each streamed chunk looks like:
data: {"choices":[{"delta":{"content":"Kubernetes "},"index":0}]}
data: {"choices":[{"delta":{"content":"is "},"index":0}]}
...
data: [DONE]
curl https://api.ai.college.ucsb.edu/v1/models \
-H "Authorization: Bearer $LSIT_API_KEY" | jq '.data[].id'
Any HTTP client works. Here are minimal examples:
const response = await fetch("https://api.ai.college.ucsb.edu/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.LSIT_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "gemma-4-31b",
messages: [{ role: "user", content: "Hello!" }]
})
});
const data = await response.json();
console.log(data.choices[0].message.content);
library(httr2)
resp <- request("https://api.ai.college.ucsb.edu/v1/chat/completions") |>
req_auth_bearer_token(Sys.getenv("LSIT_API_KEY")) |>
req_body_json(list(
model = "gemma-4-31b",
messages = list(list(role = "user", content = "Summarize linear regression."))
)) |>
req_perform()
resp_body_json(resp)$choices[[1]]$message$content
Questions or issues? Contact [help@cit.ucsb.edu].