API Reference
Adapter Types
OpenRouter adapter and EmbedFn type for semantic routing and convergence.
EmbedFn
Batch embedding function that maps N texts to N vectors. Used by semanticSwitch, embeddingMatch, and until.converged.
type EmbedFn = (texts: readonly string[]) => Promise<readonly number[][]>;LlmProviderConfig
Configuration for the LLM provider, passed to AgentHarness via the callModelDefaults option.
interface LlmProviderConfig {
provider?: 'noetic' | 'openrouter'; // default 'noetic'
apiKey?: string;
baseUrl?: string;
cache?: boolean;
}| Property | Type | Required | Description |
|---|---|---|---|
provider | 'noetic' | 'openrouter' | No | Inference backend. 'noetic' (default) uses the Noetic platform; 'openrouter' calls OpenRouter directly with your own key. |
apiKey | string | No | API key. Defaults to NOETIC_API_KEY for 'noetic' and OPENROUTER_API_KEY for 'openrouter'. Only the selected provider's variable is read. |
baseUrl | string | No | Override the API base URL. For 'noetic' it defaults to NOETIC_BASE_URL, then https://platform.noetic.tools/v1; for 'openrouter', the SDK default. |
cache | boolean | No | Send X-OpenRouter-Cache: true on every model call so identical requests come from cache without being billed again. Useful for evals and regression runs. Default false. |
OpenRouter Adapter
Factory function that creates an EmbedFn implementation backed by the @openrouter/sdk.
createOpenRouterEmbed(apiKey, embeddingModel?)
Creates an EmbedFn that calls the OpenRouter embeddings endpoint.
import { createOpenRouterEmbed } from '@noetic-tools/core';
const embed = createOpenRouterEmbed(process.env.OPENROUTER_API_KEY);| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | OpenRouter API key |
embeddingModel | string | No | Embedding model ID. Defaults to openai/text-embedding-3-small. |
Usage with Semantic Routing
import { callModel, conditional, createOpenRouterEmbed, semanticSwitch } from '@noetic-tools/core';
const embed = createOpenRouterEmbed(process.env.OPENROUTER_API_KEY);
const router = conditional({
id: 'semantic-router',
route: semanticSwitch({
embed,
cases: {
'greeting or salutation': callModel({ id: 'greet', model: 'openai/gpt-4o-mini' }),
'technical question': callModel({ id: 'tech', model: 'openai/gpt-4o' }),
},
threshold: 0.7,
}),
});