Skip to content

Custom Providers (YAML-based provider configuration)#117

Merged
Sewer56 merged 4 commits into
mainfrom
custom-providers
May 16, 2026
Merged

Custom Providers (YAML-based provider configuration)#117
Sewer56 merged 4 commits into
mainfrom
custom-providers

Conversation

@Sewer56
Copy link
Copy Markdown
Member

@Sewer56 Sewer56 commented May 15, 2026

Summary

Add reloaded-code-provider-config crate for defining custom LLM providers via YAML files - no Rust code required. Also fixes OpenAI-compatible providers to work without credentials when no env vars are listed (e.g., local Ollama).

Changes

New crate: reloaded-code-provider-config

  • loader.rs - ProviderConfigLoader collects YAML files and programmatic entries, merges them (later source wins), validates, and produces catalog sources
  • config.rs - Serde shapes for ProviderConfig and ModelConfig
  • api_type.rs - Maps api_type strings to ProviderType variants
  • error.rs - Typed errors for validation and I/O failures

Conventional config paths (opt-in via with_default_paths()):

  • ~/.config/reloaded-code/providers.yaml (user-global)
  • .reloaded/providers.yaml (project-local)

Core changes

  • Modality::from_label() - Parses "text", "image", "audio", "video" into Modality bitflags
  • Provider bridge fix - OpenAI-compatible providers without credential env vars now work with empty API key

Documentation

  • New guide: docs/src/guides/custom-providers.md
  • Updated nav, index, models-catalog, and examples pages

YAML schema

my-llm:
  api_url: https://api.myllm.com/v1
  api_type: openai-compatible   # optional, defaults to "openai-compatible"
  env:                          # optional, credential env var names
    - MY_LLM_API_KEY
  models:
    my-model:
      max_input: 128000         # required
      max_output: 8192          # required
      modalities: [text, image] # optional, defaults to [text]
      default_temperature: 0.7  # optional
      default_top_p: 0.95       # optional

Supported api_type: openai, openai-compatible, openai-responses, anthropic, google, groq, mistral, ollama, bedrock, azure, openrouter, huggingface, cohere.

Test coverage

  • Config deserialization (full, minimal, multi-provider)
  • Loader (single file, empty, override semantics, programmatic entries)
  • Validation (missing fields, unrecognized api_type/modality, malformed YAML)
  • Catalog conversion (ProviderType mapping, ProviderIdx consistency)
  • Provider bridge (keyless endpoints succeed, credential-required still enforced)

Sewer56 added 2 commits May 15, 2026 23:12
- New `reloaded-code-provider-config` crate: parse provider/model
  definitions from YAML, merge multiple sources, validate fields,
  convert to catalog types
- Add `Modality::from_label()` for label-to-flag parsing
- Allow OpenAI-compatible providers without credential env vars
  (keyless endpoints like local Ollama)
- Add custom providers guide, example config, and docs updates
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Review Change Stack

Warning

Rate limit exceeded

@Sewer56 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 35 minutes and 50 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbaf430d-96b9-4d1c-a758-43fab822d7fb

📥 Commits

Reviewing files that changed from the base of the PR and between e257f44 and 0114488.

📒 Files selected for processing (3)
  • src/reloaded-code-provider-config/examples/config-loader.rs
  • src/reloaded-code-provider-config/src/error.rs
  • src/reloaded-code-provider-config/src/loader.rs

Walkthrough

This PR introduces a new reloaded-code-provider-config crate that enables users to define custom LLM providers using YAML configuration files. The implementation includes data models for provider and model configuration, an API type resolver, a configuration loader with YAML merging and validation, and conversion to catalog sources. The core library gains a Modality::from_label() parser, and the provider bridge now conditionally requires credentials based on whether the provider declares credential environment variables, supporting keyless OpenAI-compatible endpoints. Documentation is added throughout, including a comprehensive custom-providers guide, navigation updates, and references in the crate map and examples.

Possibly related PRs:

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Custom Providers (YAML-based provider configuration)' clearly and concisely summarizes the main change: adding YAML-based custom provider configuration functionality.
Description check ✅ Passed The PR description is comprehensive and well-structured with clear sections covering summary, changes, YAML schema, test coverage, and conventional paths.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch custom-providers

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/reloaded-code-provider-config/src/loader.rs`:
- Around line 156-160: The validation currently checks config.api_url before
validating config.api_type, which can surface MissingField(api_url) and hide
UnrecognizedApiType; change the order so you first validate api_type by calling
api_type_from_str(config.api_type.as_deref().unwrap_or(DEFAULT_API_TYPE)) and
handle/return UnrecognizedApiType if invalid, and only after a valid
ProviderType is known enforce that config.api_url.is_some() for
non-ProviderType::Ollama cases; apply the same reorder/fix for the other
occurrence covering the block around the api_url check at the later location
(the 194–202 block).
- Around line 274-285: The enumerate index is cast to u16 without checking, so
ProviderIdx::new(idx as u16) will silently truncate indices >65535 and corrupt
the intermediate ProviderModelSource entries; fix by validating idx before
casting (e.g., ensure idx <= u16::MAX and return an error if not) or use a
try_from/checked conversion when constructing ProviderIdx in the loop that
creates ProviderSource/ProviderIdx, and apply the same guard at the other
occurrences noted (src/reloaded-code-core/src/models/catalog/mod.rs:326 and
mod.rs:481) so no truncated ProviderIdx values are produced prior to
ModelCatalog::build().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1fcb2d37-18bc-4f27-a007-93c88dbf309a

📥 Commits

Reviewing files that changed from the base of the PR and between be2f5f6 and a554412.

⛔ Files ignored due to path filters (1)
  • src/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • PR.md
  • docs/mkdocs.yml
  • docs/src/examples.md
  • docs/src/guides/custom-providers.md
  • docs/src/index.md
  • docs/src/models-catalog.md
  • src/Cargo.toml
  • src/reloaded-code-core/src/models/catalog/public/modality.rs
  • src/reloaded-code-provider-config/Cargo.toml
  • src/reloaded-code-provider-config/examples/config-loader.rs
  • src/reloaded-code-provider-config/examples/providers.yaml
  • src/reloaded-code-provider-config/src/api_type.rs
  • src/reloaded-code-provider-config/src/config.rs
  • src/reloaded-code-provider-config/src/error.rs
  • src/reloaded-code-provider-config/src/lib.rs
  • src/reloaded-code-provider-config/src/loader.rs
  • src/reloaded-code-serdesai/src/agent_runtime/provider_bridge/mod.rs
  • src/reloaded-code-serdesai/src/agent_runtime/provider_bridge/tests.rs

Comment thread src/reloaded-code-provider-config/src/loader.rs Outdated
Comment thread src/reloaded-code-provider-config/src/loader.rs
Sewer56 added 2 commits May 16, 2026 17:07
Invalid api_type resolved to Unknown (≠ Ollama), causing the api_url
check to fire with MissingField(api_url) instead of the more helpful
UnrecognizedApiType. Reorder: validate api_type first, then gate the
api_url requirement on the resolved ProviderType.
- Add `ProviderConfigError::TooManyProviders` variant for recoverable error when provider count exceeds u16::MAX + 1 (65,536)
- Change `to_catalog_sources` return type to `Result`, replacing panic-prone `assert!` with early validation
- Fix doctest in `with_default_paths`: add missing import and wrap in Result-returning function
@Sewer56 Sewer56 force-pushed the custom-providers branch from e257f44 to 0114488 Compare May 16, 2026 16:12
@Sewer56 Sewer56 merged commit 4cac0cf into main May 16, 2026
20 checks passed
@Sewer56 Sewer56 deleted the custom-providers branch May 16, 2026 16:24
Sewer56 added a commit that referenced this pull request May 16, 2026
Custom Providers (YAML-based provider configuration)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant