Copy this folder when adding a provider that should use the README wording:
Existing OpenCode auth, global config, or env
This template is intentionally outside src/ and is not published to npm. package.json only publishes dist, README.md, and LICENSE.
Use this template for API-key/token providers that support all three trusted sources:
- existing OpenCode API-key/token auth (
auth.json) - trusted user/global OpenCode config
- environment variables
Do not use it for OAuth-only providers such as OpenAI.
| Template file | Copy to | Purpose |
|---|---|---|
config.ts |
src/lib/<provider>-config.ts |
Resolve auth from OpenCode auth, global config, and env. |
provider.ts |
src/providers/<provider>.ts |
Register availability, model matching, and quota fetch mapping. |
config.test.ts |
tests/lib.<provider>-config.test.ts |
Prove auth source precedence/fallbacks. |
provider.test.ts |
tests/providers.<provider>.test.ts |
Prove provider wrapper behavior. |
Also update:
src/lib/provider-metadata.tssrc/providers/registry.tsREADME.md/quota_statusdiagnostics when the provider exposes auth-source details
Before coding, replace these placeholders everywhere:
example-providerExample ProviderEXAMPLE_PROVIDER_API_KEYexampleProviderexampleProviderProviderqueryExampleProviderQuota
Use Existing OpenCode auth, global config, or env only after tests prove all three paths work. Do not leave copied template tests skipped, todo-only, or unresolved. If one path is missing, use provider-specific wording instead.