Adding a provider
Before adding a provider, read a few existing adapters so the new one follows the same conventions. Good examples are openai, anthropic, openrouter, and aihubmix.
Steps
- Create
src/providers/<provider>.tsexporting aProviderDefinitionwithname,outputDirectory, andfetchModels. - Use
fetchJsonfromsrc/lib/http.tsfor HTTP calls. - Use helpers from
src/providers/helpers.tsandsrc/lib/pricing.tsfor normalized fields and price math. - Add the provider to
src/providers/index.ts. - Create
data/providers/<provider>/index.tomlwith provider metadata. - If the provider needs a credential, add it to
.env.exampleand the update workflow. - Run
bun src/index.ts -p <provider>and inspect the generated model TOML. - Run
bun src/build-all.tssodata/all.jsonanddata/all.min.jsonare updated. - Run
bunx --bun tsc -bandbunx prettier . -w.
Metadata fixes
Generated index.toml files are rewritten by the updater. To override or preserve model data, add metadata.toml next to the generated model file.
metadata.toml supports manual_data, extends, priorities, and preserve. Use it for provider API gaps, friendly names, inherited metadata, or models that should stay even if they disappear upstream.