Servoy TI/NG Client Web-Service for calling Groq through the OpenAI-compatible API.
This package exposes a typed, documented API under plugins.svyGroq.* (SPM installable).
In Servoy Developer:
- Open SPM.
- Click Add...
- Enter this URL:
https://hv-office.de/changelog/wpm.json
After that, svyGroq will appear in the list and you can download/install it from there.
Important: The TI/NG Client runs in the browser.
- If you set
plugins.svyGroq.apiKey/ callsetApiKey()in the client, that key is not secret. - Recommended production architecture is Servoy Server (or your backend) → Groq, and the client calls your server.
For that architecture:
- Set
plugins.svyGroq.baseUrlto your proxy endpoint. - Call
plugins.svyGroq.setProxyMode(true)(so no Authorization header is sent from the client).
// Direct mode (dev/testing only)
plugins.svyGroq.setApiKey(scopes.globals.GROQ_API_KEY);
var text = plugins.svyGroq.chatCompletionText(
plugins.svyGroq.models.DEFAULT,
[ plugins.svyGroq.user('Hello from Servoy') ],
{ temperature: 0.2 }
);If your scripting context treats calls as Promises, use .then(...):
plugins.svyGroq.chatCompletionText(plugins.svyGroq.models.DEFAULT, [plugins.svyGroq.user('Hi')])
.then(function(text) {
application.output(text);
})
.catch(function(e) {
application.output('Groq error: ' + e);
});apiKey: string | null- Only used if
sendAuthHeader=true.
- Only used if
baseUrl: string- Default:
https://api.groq.com/openai/v1 - For proxy mode point to your server.
- Default:
defaultModel: string- Used when model parameter is empty.
models: groqModels- Predefined aliases for convenience:
DEFAULTLLAMA_3_3_70B_VERSATILELLAMA_3_1_8B_INSTANTLLAMA3_70B_8192LLAMA3_8B_8192MIXTRAL_8X7B_32768GEMMA2_9B_IT
- Predefined aliases for convenience:
sendAuthHeader: boolean- Default
true. In proxy mode setfalse.
- Default
timeoutMs: number- Default
60000. Applies to non-streaming calls.
- Default
retry: groqRetryConfig- Default retries on:
408, 429, 500, 502, 503, 504.
- Default retries on:
debug: boolean- When true, writes debug logs to console and fills
lastRequest.
- When true, writes debug logs to console and fills
lastRequest: groqLastRequestInfo | null- Contains request telemetry (status, duration, requestId, ...).
setApiKey(apiKey)setProxyMode(enabled)true: client does not send Authorization header.
chatCompletion(model, messages, options)→ full JSON responsechatCompletionText(model, messages, options)→ convenience text response
chatCompletionEx(model, messages, options, requestOptions)requestOptions.timeoutMs,requestOptions.retry,requestOptions.headers
chatCompletionTextEx(model, messages, options, requestOptions)
system(text)/user(text)/assistant(text)registerModel(alias, modelId)/getModels()extractText(resp)extractToolCalls(resp)createFunctionTool(name, description?, parameters?)
chatCompletionJson(model, messages, options?, requestOptions?) returns parsed JSON.
plugins.svyGroq.setApiKey(scopes.globals.GROQ_API_KEY);
var obj = plugins.svyGroq.chatCompletionJson(plugins.svyGroq.models.DEFAULT, [
plugins.svyGroq.system('Return JSON only.'),
plugins.svyGroq.user('Give me {"ok":true,"n":1}')
]);
application.output(obj.ok);You can send tools and tool_choice through the regular options object.
var tool = plugins.svyGroq.createFunctionTool(
'sum',
'Sums two integers',
{
type: 'object',
properties: {
a: { type: 'integer' },
b: { type: 'integer' }
},
required: ['a', 'b']
}
);
var resp = plugins.svyGroq.chatCompletion(
plugins.svyGroq.models.DEFAULT,
[ plugins.svyGroq.user('Use the tool to sum 4 and 5') ],
{ tools: [tool], tool_choice: 'auto' }
);
var toolCalls = plugins.svyGroq.extractToolCalls(resp);
application.output(JSON.stringify(toolCalls));chatCompletionStreamText(model, messages, options?, onDelta?, streamOptions?)
plugins.svyGroq.setApiKey(scopes.globals.GROQ_API_KEY);
var full = plugins.svyGroq.chatCompletionStreamText(
plugins.svyGroq.models.DEFAULT,
[ plugins.svyGroq.user('Write 5 short sentences.') ],
{ temperature: 0.2 },
function(deltaText) {
application.output(deltaText); // live chunks
}
);
application.output('DONE: ' + full);Note: Streaming depends on browser networking behavior. If your environment buffers the response, you may not see incremental deltas.
modelsis null / missing IntelliSense- Ensure you installed the latest zip and reloaded solution. The package includes
.spectypes and a definition stub to avoid null.
- Ensure you installed the latest zip and reloaded solution. The package includes
GroqService: apiKey not set- Call
setApiKey()or setsendAuthHeader=false(proxy mode).
- Call
- 429 / rate limits
- Tune
retryand/or reducemax_tokens, lower concurrency.
- Tune
npm installnpm run build
Output is written to dist/servoy/svy-groq.
npm run make_release
This generates:
svyGroq.zip(latest)svyGroq-<version>.zip(versioned)
Licensed under the Apache License 2.0. See LICENSE and the attribution notes in NOTICE.