-
-
Notifications
You must be signed in to change notification settings - Fork 3
Adding an LLM Provider
CortexPrism edited this page Jun 17, 2026
·
1 revision
This guide walks through adding a new LLM provider to CortexPrism.
Create src/llm/your-provider.ts. Most providers extend OpenAICompatibleProvider:
import { OpenAICompatibleProvider } from "./openai-compatible.ts";
export class YourProvider extends OpenAICompatibleProvider {
readonly name = "your-provider";
readonly defaultModel = "your-default-model";
constructor(apiKey?: string, baseUrl?: string) {
super(
apiKey ?? "",
baseUrl ?? "https://api.your-provider.com/v1",
"your-provider",
"your-default-model",
);
}
}For non-OpenAI-compatible providers, implement the LLMProvider interface directly:
import type { LLMProvider, CompletionOptions, CompletionResult, CompletionChunk } from "./types.ts";
export class YourProvider implements LLMProvider {
readonly name = "your-provider";
readonly defaultModel = "your-default-model";
constructor(private apiKey: string) {}
async complete(options: CompletionOptions): Promise<CompletionResult> {
// Implement complete API call
}
async *stream(options: CompletionOptions): AsyncIterable<CompletionChunk> {
// Implement streaming API call
}
}Add to src/llm/factory.ts in the provider creation function.
Add the provider to the ProviderConfig type union in src/config/config.ts.
Add the provider option to the interactive setup in src/cli/setup.ts.
Create a yourProviderModels() function and register it in src/server/models.ts.
If the provider has unique parameters, add them to CompletionOptions in src/llm/types.ts and wire them through in the provider adapter.
- Add to the README provider list
- Add to the LLM Providers wiki page
- Add a CHANGELOG entry
interface LLMProvider {
readonly name: string;
readonly defaultModel: string;
complete(options: CompletionOptions): Promise<CompletionResult>;
stream(options: CompletionOptions): AsyncIterable<CompletionChunk>;
}interface CompletionOptions {
messages: Message[];
systemPrompt?: string;
temperature?: number;
maxTokens?: number;
topP?: number;
model?: string;
stream?: boolean;
signal?: AbortSignal;
// Provider-specific:
reasoningEffort?: "low" | "medium" | "high";
repetitionPenalty?: number;
numCtx?: number;
keepAlive?: string;
// ... and more
}- LLM Providers — All 24 supported providers
- Model Routing — Router integration
- Contributing — General contribution guidelines
CortexPrism — Open-source agentic AI harness · MIT License · Built with Deno 2.x + TypeScript