Principle:869413421 Ai moive studio Provider Registry
| Knowledge Sources | |
|---|---|
| Domains | Architecture, Configuration |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
Technique for validating and normalizing provider connection configurations, including URL scheme validation, hostname migration, and base URL derivation from provider names and custom endpoints.
Description
Provider Registry manages the connection configuration for AI providers. Given a provider name (e.g., openai, deepseek, volcengine, custom) and an optional base URL, the registry produces a normalized connection dict containing the provider name, source identifier, base URL (with /v1 suffix), and root URL (without /v1).
Key responsibilities:
- URL validation: Rejects URLs with credentials, query parameters, or fragments; requires HTTP(S) scheme and hostname
- Hostname migration: Migrates the old AICON hostname (api.aiconapi.me) to the new one (api.aicon-studio.com)
- Base URL derivation: Appends /v1 to the root URL if no path is specified
- Source resolution: Determines whether the source is aicon (managed), compatible, or the provider name itself
- Config validation: Validates the model catalog configuration (models.json) for structural integrity, model uniqueness, and capability constraints
Usage
Use this principle when systems need to connect to multiple AI providers with different base URLs and configurations. Apply when URL normalization and validation are needed before establishing provider connections. Use when a model catalog configuration file must be validated at load time.
Theoretical Basis
# Abstract registry connection
def connection(provider, base_url=None):
provider = provider.lower()
value = (base_url or PROVIDERS[provider][1]).strip().rstrip('/')
parts = urlsplit(value)
validate_scheme(parts) # must be http/https
reject_credentials(parts) # no username/password/query/fragment
# Hostname migration
if parts.hostname == 'api.aiconapi.me':
parts = parts._replace(netloc='api.aicon-studio.com')
root = build_root_url(parts)
base = root + '/v1' if no_path else parts
source = 'aicon' if is_aicon_host else ('compatible' if custom else provider)
return {'provider': provider, 'source': source, 'base_url': base, 'root_url': root}
Practical Guide
- Always validate URL scheme and reject credentials in URLs
- Support hostname migration for legacy endpoints
- Derive base_url with /v1 suffix; root_url without it
- Cache configuration by file content to avoid re-parsing on every load
- Validate model config: version, models array, unique (source, name) pairs, capability constraints