feat: Ollama cloud model support (keyless auth)#316
Conversation
Add `api_key_required: bool` to `ProviderSpec` and set it to `false` for ollama and vllm. When `api_key_required` is false and the provider section is present in config but has no key, `resolve_credential` now returns an empty-string credential instead of skipping the provider. All other providers retain `api_key_required: true` (no behavior change). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Allows keyless providers (Ollama, vLLM) to make requests without sending a spurious auth header.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces keyless provider support by adding an Changes
Sequence DiagramsequenceDiagram
participant Client
participant Registry as Provider Registry
participant CredResolver as Credential Resolver
participant OpenAI as OpenAI Provider
participant Request as HTTP Request
alt Keyless Provider (Ollama/vLLM)
Client->>Registry: Select provider (api_key_required=false)
Registry->>CredResolver: resolve_credential(spec)
CredResolver->>CredResolver: Check api_key_required=false
CredResolver-->>Client: Return ApiKey("")
Client->>OpenAI: Build request with empty key
OpenAI->>OpenAI: auth_header_pair("") → ("", "")
OpenAI->>Request: Skip Authorization header
else Key-Required Provider
Client->>Registry: Select provider (api_key_required=true)
Registry->>CredResolver: resolve_credential(spec)
CredResolver->>CredResolver: Resolve API key from config
CredResolver-->>Client: Return ApiKey("sk-...")
Client->>OpenAI: Build request with key
OpenAI->>OpenAI: auth_header_pair("sk-...") → ("Authorization", "Bearer sk-...")
OpenAI->>Request: Attach Authorization header
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## Summary - Allow Ollama and vLLM providers to resolve without requiring a dummy API key - Skip `Authorization` header when no API key is configured (local instances don't need auth) - When `api_key` IS set, auth works normally (cloud Ollama with auth) - Update `configured_provider_names` and `configured_provider_models` to include keyless providers Closes qhkm#284 ## Changes - `src/providers/registry.rs`: Add `api_key_required` field to `ProviderSpec`, keyless fallback in `resolve_credential` - `src/providers/openai.rs`: Conditional auth header in `chat()`, `chat_stream()`, `embed()` - `src/channels/model_switch.rs`: Update Ollama comment label - `CLAUDE.md`: Document keyless provider configuration ## Config examples ```json {"providers": {"ollama": {}}} {"providers": {"ollama": {"api_base": "https://my-cloud-ollama.example.com/v1"}}} {"providers": {"ollama": {"api_key": "secret", "api_base": "https://my-cloud-ollama.example.com/v1"}}} ``` ## Test plan - [x] 6 new registry tests (keyless resolution, bare config, backward compat, configured_provider_names/models) - [x] 2 new OpenAI provider tests (auth header skip/send) - [x] Full lib suite: 3100 passed, 0 failed - [x] Doc tests: 127 passed - [x] clippy clean, fmt clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Support for keyless provider configuration—Ollama and vLLM can now be used without requiring an API key. * **Documentation** * Added comprehensive guide for configuring providers without API keys. * Clarified that Ollama supports both local and cloud deployments. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Authorizationheader when no API key is configured (local instances don't need auth)api_keyIS set, auth works normally (cloud Ollama with auth)configured_provider_namesandconfigured_provider_modelsto include keyless providersCloses #284
Changes
src/providers/registry.rs: Addapi_key_requiredfield toProviderSpec, keyless fallback inresolve_credentialsrc/providers/openai.rs: Conditional auth header inchat(),chat_stream(),embed()src/channels/model_switch.rs: Update Ollama comment labelCLAUDE.md: Document keyless provider configurationConfig examples
{"providers": {"ollama": {}}} {"providers": {"ollama": {"api_base": "https://my-cloud-ollama.example.com/v1"}}} {"providers": {"ollama": {"api_key": "secret", "api_base": "https://my-cloud-ollama.example.com/v1"}}}Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation