Generate
This endpoint can be used as a RAG endpoint. For this endpoint to work you need to setup the different AI models as specified on the homepage of this documentation. The @generate
endpoint will use the specified LLM in your config and will be augmented by the content from your website using RAG. You can query the LLM with the following request:
POST /@generate HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json
{
"prompt": "What is the username of the nick demo site?",
"context": [ ... ],
"params": {
"Site": "enable",
}
}
Or use the client directly:
import { Client } from '@robgietema/nick';
const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({ username: 'admin', password: 'admin' });
const { data } = await cli.generate({
token: login.data.token,
data: {
prompt: 'What is the username of the nick demo site?',
context: [ ... ],
params: {
Site: "enable",
}
},
});
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"model": "llama3.2",
"created_at": "2025-01-01T00:00:00.00000Z",
"response": "The username for the demo site is \"admin\".",
"done": true,
"done_reason": "stop",
"context": [
...
]
"total_duration": 356186167,
"load_duration": 18592125,
"prompt_eval_count": 139,
"prompt_eval_duration": 220903084,
"eval_count": 11,
"eval_duration": 116195583
}