Skip to main content

Model Lab — TypeScript SDK

Inference playground: list callable models, create chat sessions, and stream responses.

Overview​

The Model Lab resource is the inference playground. List callable models with a 16-field filter DTO, mint a session UUID for multi-turn conversations, and stream chat completions over Server-Sent Events as an async generator of raw payload strings.

Accessed via client.modelLab.

Available Operations​

MethodDescription
list()List callable models
createSession()Create a new chat session
stream()Stream a chat completion over SSE

list​

List callable models. pageSize / pageNum are required by the backend (code=1000 if missing) — the SDK defaults them to 20 / 1.

Example Usage​

import { WltClient } from 'wlt-platform';

const client = new WltClient({ apiKey: 'your-api-key', baseUrl: 'https://console.example.com' });

// List inference models
const models = await client.modelLab.list({ usageType: 'inference' });
for (const m of models) {
console.log(m.modelName, m.provider);
}

// Filter by provider and capability
const filtered = await client.modelLab.list({
provider: 'dashscope',
capability: 'text_to_text',
inputs: ['text'],
outputs: ['text'],
});

Parameters​

ParameterTypeRequiredDefaultDescription
modelNamestringNo—Model name (fuzzy search)
providerstringNo—Provider identifier
seriesProviderstringNo—Series provider identifier
modelTypestringNo—Model type
viewAllFlagnumberNo—View all flag (1=view all)
pageSizenumberNo20Items per page. Required by backend; SDK defaults to 20
pageNumnumberNo1Page number. Required by backend; SDK defaults to 1
usageTypestringNo—Usage type: "inference" or "train"
trainingMethodstringNo—Training method: "sft" or "dpo"
tagsstring[]No—Tag filter list
capabilitystringNo—Capability filter, e.g. "text_to_text"
modelTypeListstring[]No—Model type list (multi-select)
originProvidersstring[]No—Origin provider list (multi-select)
inputsstring[]No—Input type list, e.g. ["text"]
outputsstring[]No—Output type list (max 1 item), e.g. ["image"]

Response​

Returns ModelInfoVO[]. See Model Gallery page() for field definitions.

Errors​

CodeErrorWhen
1000System errorpageNum / pageSize missing (backend requirement)
2000 / 2002Authentication failureAPI Key invalid
2007Permission deniedToken lacks permission
3001Token expiredRefresh failed

createSession​

Create a new chat session. The returned UUID can be passed to stream() as sessionId for multi-turn conversations.

Example Usage​

const sessionId = await client.modelLab.createSession();
console.log(`Session ID: ${sessionId}`);

Parameters​

None.

Response​

Returns string — a UUID session ID.

Errors​

CodeErrorWhen
2000 / 2002Authentication failureAPI Key invalid
2007Permission deniedToken lacks permission
3001Token expiredRefresh failed

stream​

Call a model via Server-Sent Events. Returns an async generator yielding the raw payload string of each data: line. The [DONE] sentinel terminates the iterator.

Example Usage​

import { WltClient } from 'wlt-platform';

const client = new WltClient({ apiKey: 'your-api-key', baseUrl: 'https://console.example.com' });

// Create a session for multi-turn conversation
const sessionId = await client.modelLab.createSession();

// Stream inference. Use a provider + model actually served by the gateway --
// discover via `client.modelLab.list()` / `client.usage.gatewayProviders()`.
// On the daily environment, `openrouter` + `openai/gpt-5.4-nano` is a known-good pair.
for await (const chunk of client.modelLab.stream({
provider: 'openrouter',
modelName: 'openai/gpt-5.4-nano',
userPrompt: 'Explain quantum computing in one paragraph.',
sessionId,
options: {
temperature: 0.7,
maxToken: 2048,
topP: 0.9,
systemPrompt: 'You are a helpful assistant.',
},
})) {
try {
const evt = JSON.parse(chunk);
const delta = evt?.choices?.[0]?.delta?.content;
if (delta) process.stdout.write(delta);
} catch {
// Non-JSON chunk (e.g. heartbeat) — write through raw
process.stdout.write(chunk);
}
}
console.log(); // newline after streaming completes

Parameters​

ParameterTypeRequiredDefaultDescription
providerstringYes—Provider identifier
modelNamestringYes—Model name
userPromptstringYes (unless retry)—User prompt text
sessionIdstringNo—Session ID (UUID) for multi-turn conversations
taskIdstringNo—Task ID — references the failed task when retrying
taskTypestringNo"TEXT"Task type
isRetrybooleanNofalseWhether this is a retry request (requires taskId)
optionsOptionsDTONo—Model parameter configuration (see below)

OptionsDTO:

FieldTypeRequiredDefaultDescription
temperaturenumberNo—Temperature; controls output randomness
maxTokennumberNo—Maximum generated token count
topPnumberNo—Top-P sampling parameter
topKnumberNo—Top-K sampling parameter
presencePenaltynumberNo—Presence penalty
frequencyPenaltynumberNo—Frequency penalty
stopSequencesstringNo—Stop sequences
systemPromptstringNo—System prompt
enableThinkingbooleanNo—Enable deep thinking
enableProgressbooleanNo—Enable progress push
timeoutSecondsnumberNo—Task timeout (seconds)
enableCachebooleanNo—Enable result caching
enableDocumentInliningbooleanNo—Enable document inlining
budgetTokensnumberNo—Budget token count

Response​

Returns AsyncGenerator<string, void, undefined>. Each yielded value is the string after data: on one SSE event; each chunk follows the OpenAI-compatible streaming format. The generator finishes when data: [DONE] is received or the connection closes.

Errors​

CodeErrorWhen
1001Validation errorprovider / modelName missing, or isRetry=true without taskId
2000 / 2002Authentication failureAPI Key invalid
2007Permission deniedToken lacks permission
3001Token expiredRefresh failed