NOETIC
Framework
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;
}
PropertyTypeRequiredDescription
provider'noetic' | 'openrouter'NoInference backend. 'noetic' (default) uses the Noetic platform; 'openrouter' calls OpenRouter directly with your own key.
apiKeystringNoAPI key. Defaults to NOETIC_API_KEY for 'noetic' and OPENROUTER_API_KEY for 'openrouter'. Only the selected provider's variable is read.
baseUrlstringNoOverride the API base URL. For 'noetic' it defaults to NOETIC_BASE_URL, then https://platform.noetic.tools/v1; for 'openrouter', the SDK default.
cachebooleanNoSend 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);
ParameterTypeRequiredDescription
apiKeystringYesOpenRouter API key
embeddingModelstringNoEmbedding 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,
  }),
});

On this page