Skip to content

Conversation

@dannote
Copy link
Contributor

@dannote dannote commented Jan 21, 2026

Problem

Extensions cannot dynamically configure model providers. The only way to add providers is through models.json, which doesn't support:

  • Fetching config from external servers at runtime
  • Conditional registration based on environment (e.g., local Ollama)
  • Team/corporate provider distribution via extensions

Solution

Add pi.registerProvider(name, config) to ExtensionAPI for runtime provider registration.

Use cases

  • Fetch provider config from corporate/team server dynamically
  • Conditionally register local models (e.g., Ollama if running)
  • Override baseUrl for existing providers (proxies, private endpoints)
  • Project-specific model configurations

Example

// Fetch config from server
const config = await fetch('https://internal.company.com/ai-config').then(r => r.json());
pi.registerProvider('company-ai', config);

// Override existing provider's baseUrl  
pi.registerProvider('anthropic', {
  baseUrl: 'https://private-ai.company.com'
});

Changes

  • model-registry.ts: Add registerProvider() method
  • types.ts: Add ProviderConfig, ProviderModelConfig types, extend ExtensionAPI
  • loader.ts: Pass ModelRegistry to extensions, implement API method
  • sdk.ts: Thread modelRegistry through extension loading
  • extensions.md: Document new API
  • Tests for new functionality

…gistration

Allows extensions to register or override model providers at runtime.

Use cases:
- Fetch provider config from corporate/team server dynamically
- Conditionally register local models (e.g., Ollama if running)
- Override baseUrl for existing providers (proxies, private endpoints)
- Project-specific model configurations via extensions

Example usage:
```typescript
// Fetch config from server
const config = await fetch('https://internal.company.com/ai-config').then(r => r.json());
pi.registerProvider('company-ai', config);

// Override existing provider's baseUrl
pi.registerProvider('anthropic', {
  baseUrl: 'https://private-ai.company.com'
});
```
@badlogic
Copy link
Owner

I like this! I'm in the middle of a big refactor, so it will take a while for me to get to this. Just a few initial thoughts:

  • I think it would be nice, if registerProvider() could also optionally take an interface that would allow inclusion in the list of oauth providers. That way, people could implement their own /login. Needs a bit of plumbing and some thinking wrt API design of registerProvider() but should be totally possible.
  • Shouldn't be part of this PR, but a possible future change: also allow registration of a provider API implementation, basically what's found in anthropic.ts and consorts. This is likely more complex, but would open up a lot of things wrt custom endpoints, support for providers not yet in core, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants