SoCLaaS

Home / Setup Guides / Direct API and SDKs

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

SettingValue
Base URLhttps://soclaas-api.comp.nus.edu.sg/v1
API keyFrom the SoCLaaS portal, stored in SOCLAAS_API_KEY
ModelA chat-capable ID from GET /v1/models

Steps

  1. 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"
  2. List models

    curl https://soclaas-api.comp.nus.edu.sg/v1/models \
      -H "Authorization: Bearer $SOCLAAS_API_KEY"
  3. Send a chat request with curl

    Replace YOUR_MODEL_ID with 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."
        }]
      }'
  4. Use the OpenAI Python SDK

    pip install openai
    import 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)
  5. Use the OpenAI Node SDK

    npm install openai
    import 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

EndpointUse
POST /v1/chat/completionsChat and tool calling
POST /v1/responsesResponses API subset
POST /v1/embeddingsEmbeddings
POST /v1/audio/transcriptionsAudio transcription
GET /v1/modelsModel discovery

Capability depends on the model. Chat, reasoning, coding, vision, embeddings, and transcription are not available on every model ID.

Troubleshooting