Docs Home | API | Configuration | Examples | Basic | Caching | Events | Architecture | Agent-Native | Benchmarks | Ecosystem
Qirrel supports pluggable LLM adapters:
geminiopenaigeneric(OpenAI-compatible style HTTP endpoint)
bun add qirrel
bun add @google/generative-ai # needed only for gemini providerllm:
enabled: true
provider: openai
apiKey: ${QIRREL_LLM_API_KEY}
model: gpt-4o-mini
baseUrl: https://api.openai.com/v1
temperature: 0.7
maxTokens: 1024
timeout: 30000
cacheTtl: 300000Environment placeholders are supported:
${QIRREL_LLM_API_KEY}${QIRREL_LLM_API_KEY:-fallback-value}
import { Pipeline } from 'qirrel';
const pipeline = new Pipeline('./config-with-llm.yaml');
await pipeline.init();
const adapter = pipeline.getLLMAdapter();
if (!adapter) {
throw new Error('LLM adapter not available');
}Pipeline.init() waits for asynchronous adapter setup and should be called during service startup.
const response = await adapter.generate('Classify sentiment: I love this.');
console.log(response.content);import { createLLMProcessor } from 'qirrel';
pipeline.addLLMProcessor(
createLLMProcessor({
adapter,
promptTemplate: 'Extract themes from: {text}',
}),
);Current adapter behavior differs by provider:
openai: validates base URL and throws explicit errors for HTTP/timeout/response issues.gemini: loads SDK dynamically; when SDK/API fails, default fallback handler returns fallback content.generic: uses HTTPS endpoint/completions; failures are routed through fallback handler.
Plan your error handling based on provider semantics.
cacheTtlcontrols adapter response caching duration.timeoutcontrols request timeout behavior.
If deterministic behavior is critical, combine LLM output with deterministic processors rather than replacing them.
- Keep prompts explicit and short.
- Guard any LLM-generated entities before consuming them downstream.
- Record model name and latency in your app telemetry.
- Decide whether fallback content should be surfaced to end users or treated as degraded mode.