Skip to main content
Extensions can register custom model providers via pi.registerProvider(). This enables proxies, self-hosted deployments, OAuth/SSO authentication, and custom API implementations.

Quick Start

Create an extension that registers a provider:

Use Cases

Redirect an existing provider through a corporate proxy:

Override Existing Provider

When only baseUrl and/or headers are provided (no models), all existing models for that provider are preserved with the new endpoint.

Register New Provider

When models is provided, it replaces all existing models for that provider.

OAuth Support

Add authentication that integrates with /login:

Custom Streaming API

For providers with non-standard APIs, implement streamSimple:
Study the existing provider implementations in packages/ai/src/providers/ before writing your own.

Complete Example

Here’s a complete custom provider with OAuth:
custom-provider-anthropic/index.ts
See packages/coding-agent/examples/extensions/custom-provider-anthropic/ for the complete working example.

Unregister Provider

Remove a provider:
Built-in models that were overridden are restored.

Reference

Config Options

Model Definition

Next Steps

  • See Building Extensions for extension basics
  • See Creating Skills for specialized workflows
  • Check packages/coding-agent/examples/extensions/custom-provider-* for examples