Direct API
Call SoCLaaS with curl or an SDK
SoCLaaS exposes an OpenAI-compatible API. Any client that accepts a custom base URL and API key can use it: curl, the OpenAI SDKs, or your own HTTP code.
Using a coding agent? The portal's Client Setup page generates ready-made configs for Codex, OpenCode, and Qwen Code. This guide covers direct API calls and custom integrations.
The API key portal is available from the NUS network, while the API gateway itself is reachable from the Internet. Responses may vary by model, so check /v1/models before choosing one.
Connection values
| Setting | Value |
|---|---|
| Base URL | https://soclaas-api.comp.nus.edu.sg/v1 |
| API key | From the SoCLaaS portal, stored in SOCLAAS_API_KEY |
| Model | A chat-capable ID from GET /v1/models |
Steps
-
Get an API key
Sign in to the SoCLaaS portal from the NUS network and create a personal key, then export it.
export SOCLAAS_API_KEY="YOUR_API_KEY" -
List models
curl https://soclaas-api.comp.nus.edu.sg/v1/models \ -H "Authorization: Bearer $SOCLAAS_API_KEY" -
Send a chat request with curl
Replace
YOUR_MODEL_IDwith an ID from the previous step.curl https://soclaas-api.comp.nus.edu.sg/v1/chat/completions \ -H "Authorization: Bearer $SOCLAAS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "YOUR_MODEL_ID", "messages": [{ "role": "user", "content": "Suggest three AI project ideas for a weekend." }] }' -
Use the OpenAI Python SDK
pip install openaiimport os from openai import OpenAI client = OpenAI( base_url="https://soclaas-api.comp.nus.edu.sg/v1", api_key=os.environ["SOCLAAS_API_KEY"], ) response = client.chat.completions.create( model="YOUR_MODEL_ID", messages=[ {"role": "user", "content": "Suggest three AI project ideas for a weekend."} ], ) print(response.choices[0].message.content) -
Use the OpenAI Node SDK
npm install openaiimport OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://soclaas-api.comp.nus.edu.sg/v1", apiKey: process.env.SOCLAAS_API_KEY, }); const response = await client.chat.completions.create({ model: "YOUR_MODEL_ID", messages: [ { role: "user", content: "Suggest three AI project ideas for a weekend." }, ], }); console.log(response.choices[0].message.content);
Supported endpoints
| Endpoint | Use |
|---|---|
POST /v1/chat/completions | Chat and tool calling |
POST /v1/responses | Responses API subset |
POST /v1/embeddings | Embeddings |
POST /v1/audio/transcriptions | Audio transcription |
GET /v1/models | Model discovery |
Capability depends on the model. Chat, reasoning, coding, vision, embeddings, and transcription are not available on every model ID.
Troubleshooting
- 401 Unauthorized: the
Authorizationheader must beBearer <key>with no extra quotes. - 404 on a request: the base URL already includes
/v1; do not add it twice. - Timeout: check your network connection and the gateway status.
- Unsupported feature: try a different model ID that supports the endpoint you need.