Save provider config to disk.
(config: ProvidersConfig, path: Path | None = None)
| 118 | |
| 119 | |
| 120 | def save_providers(config: ProvidersConfig, path: Path | None = None) -> None: |
| 121 | """Save provider config to disk.""" |
| 122 | filepath = path or _PROVIDERS_FILE |
| 123 | filepath.parent.mkdir(parents=True, exist_ok=True, mode=0o700) |
| 124 | data = { |
| 125 | "providers": { |
| 126 | name: { |
| 127 | "api_key": entry.api_key, |
| 128 | "base_url": entry.base_url, |
| 129 | "models": entry.models, |
| 130 | **({"plan": entry.plan} if entry.plan else {}), |
| 131 | } |
| 132 | for name, entry in config.providers.items() |
| 133 | } |
| 134 | } |
| 135 | filepath.write_text(json.dumps(data, indent=2)) |
| 136 | filepath.chmod(0o600) |
| 137 | |
| 138 | |
| 139 | def add_provider( |
no outgoing calls
no test coverage detected