Quickstart
Build the smallest certified provider leaf
Quickstart
This path is for a new certified model provider adapter. It assumes Node.js 22+, pnpm 10+, and repository dependencies installed with pnpm install.
Choose The Protocol Path
| Provider shape | Starting point |
|---|---|
| New native API | Create a provider-specific leaf with implementation.ts and adapter.ts |
| OpenAI Chat Completions-compatible API | Reuse self/subcortex/providers/src/protocols/openai-api/** |
| Local provider like Ollama | Use the Ollama leaf as the local-runtime comparison point |
| CLI-backed local provider | See the CLI Provider Guide for execution capability requirements |
| Shared behavior across several vendors | Put reusable behavior under src/protocols/<protocol>/ |
Add The Leaf
Create a lowercase ASCII kebab-case vendor folder:
self/subcortex/providers/src/providers/<vendor>/
├── definition.ts
├── adapter.ts
├── provider.ts
├── implementation.ts
└── index.tsimplementation.ts is needed when the leaf owns request execution. It is not required when the provider leaf wraps a shared protocol implementation, as src/providers/openai/ does.
Fill The Contracts
- In
definition.ts, exportproviderDefinition. - In
adapter.ts, exportproviderAdapter. - In
provider.ts, exportproviderFactory. - In
index.ts, re-export the leaf's public surface. The generator requires this file as part of leaf validation, but importsdefinition.ts,adapter.ts, andprovider.tsdirectly. - Keep definitions as metadata only: no environment reads, network calls, concrete provider instantiation, or bootstrap branches.
- Do not hand-author
wellKnownProviderId. Built-in provider IDs are deterministically derived from the provider-definitionvendorKey; use a semanticvendorKeyinstead. - For API-key providers, declare
auth.purpose: 'api_key',auth.required: true,auth.envVar,auth.vaultKeyNamespace, andauth.header. AddmodelListEndpointandmodelListFormatwhen the provider should support dynamic model discovery; addhealthCheckEndpointwhen key testing should use a dedicated health endpoint. See Schemas ABI Reference for the field contract. - For CLI-style providers, declare
executionCapabilityProfileon the provider definition (e.g.session_bound_commandorpersistent_process). Selection-time role compatibility filtering uses this profile to determine which model roles the provider can fill. See the CLI Provider Guide for the full CLI contributor contract, Schemas & ABI Reference for profile values, and Testing Checklist for role assignment test expectations.
The definition should use as const satisfies ProviderDefinitionLeaf. The generated provider catalog hydrates each leaf into a full ProviderDefinition by deriving the built-in wellKnownProviderId from vendorKey. The factory should use as const satisfies ProviderFactoryModule.
Declaring the API-key metadata is enough for the Settings key field. Declaring the discovery metadata opts the provider into the shared model-list path. Do not add provider-specific Settings UI, model-family allowlists, or runtime vendor branches for a normal provider leaf.
Regenerate Catalogs
pnpm --filter @nous/subcortex-providers run generate:providers
pnpm --filter @nous/subcortex-providers run check:generatedGenerated files are expected to change when a provider leaf is added or renamed:
self/subcortex/providers/src/provider-definitions.ts
self/subcortex/providers/src/provider-adapters.ts
self/subcortex/providers/src/provider-factories.tsDo not edit those files by hand.
Run Focused Checks
pnpm --filter @nous/subcortex-providers run typecheck
pnpm --filter @nous/subcortex-providers exec vitest run src/__tests__/provider-codegen.test.ts src/__tests__/public-exports.test.ts src/__tests__/provider-definitions src/__tests__/adapter-resolver.test.ts src/__tests__/provider-pipeline-integration.test.ts --config vitest.config.tsFor docs-only changes, run:
pnpm --filter docs lint
pnpm --filter docs build