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
| Method | Description |
|---|---|
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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
modelName | string | No | — | Model name (fuzzy search) |
provider | string | No | — | Provider identifier |
seriesProvider | string | No | — | Series provider identifier |
modelType | string | No | — | Model type |
viewAllFlag | number | No | — | View all flag (1=view all) |
pageSize | number | No | 20 | Items per page. Required by backend; SDK defaults to 20 |
pageNum | number | No | 1 | Page number. Required by backend; SDK defaults to 1 |
usageType | string | No | — | Usage type: "inference" or "train" |
trainingMethod | string | No | — | Training method: "sft" or "dpo" |
tags | string[] | No | — | Tag filter list |
capability | string | No | — | Capability filter, e.g. "text_to_text" |
modelTypeList | string[] | No | — | Model type list (multi-select) |
originProviders | string[] | No | — | Origin provider list (multi-select) |
inputs | string[] | No | — | Input type list, e.g. ["text"] |
outputs | string[] | No | — | Output type list (max 1 item), e.g. ["image"] |
Response
Returns ModelInfoVO[]. See Model Gallery page() for field definitions.
Errors
| Code | Error | When |
|---|---|---|
1000 | System error | pageNum / pageSize missing (backend requirement) |
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh 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
| Code | Error | When |
|---|---|---|
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh 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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
provider | string | Yes | — | Provider identifier |
modelName | string | Yes | — | Model name |
userPrompt | string | Yes (unless retry) | — | User prompt text |
sessionId | string | No | — | Session ID (UUID) for multi-turn conversations |
taskId | string | No | — | Task ID — references the failed task when retrying |
taskType | string | No | "TEXT" | Task type |
isRetry | boolean | No | false | Whether this is a retry request (requires taskId) |
options | OptionsDTO | No | — | Model parameter configuration (see below) |
OptionsDTO:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
temperature | number | No | — | Temperature; controls output randomness |
maxToken | number | No | — | Maximum generated token count |
topP | number | No | — | Top-P sampling parameter |
topK | number | No | — | Top-K sampling parameter |
presencePenalty | number | No | — | Presence penalty |
frequencyPenalty | number | No | — | Frequency penalty |
stopSequences | string | No | — | Stop sequences |
systemPrompt | string | No | — | System prompt |
enableThinking | boolean | No | — | Enable deep thinking |
enableProgress | boolean | No | — | Enable progress push |
timeoutSeconds | number | No | — | Task timeout (seconds) |
enableCache | boolean | No | — | Enable result caching |
enableDocumentInlining | boolean | No | — | Enable document inlining |
budgetTokens | number | No | — | 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
| Code | Error | When |
|---|---|---|
1001 | Validation error | provider / modelName missing, or isRetry=true without taskId |
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh failed |