Skip to content

feat(provider): add zdr to ProviderPreferences - #53

Merged
ProJedi1234 merged 1 commit into
mainfrom
feat/provider-zdr
Sep 10, 2026
Merged

ProJedi1234 merged 1 commit into
mainfrom
feat/provider-zdr

Conversation

@ProJedi1234

@ProJedi1234 ProJedi1234 commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

Adds an optional zdr: Bool? to ProviderPreferences, mapping to OpenRouter's per-request zdr flag on the provider-routing object. It is the last init parameter and defaults to nil, it encodes only when set, and EmbeddingsRequest picks it up for free because it reuses the same struct. Nothing else was reordered or renamed, and Equatable still holds.

data_collection: deny was the closest thing available and it is not the same guarantee. It stops a provider from collecting prompts for training, but a provider that retains request data for logging or abuse monitoring still passes that filter. zdr: true is what excludes retention-only providers, so callers who needed zero-data-retention routing previously had to hand-build the provider payload instead of using this type.

Tests: 188 tests in 21 suites pass (swift build && swift test), up from 184 — four new cases covering zdr encoding, key omission when unset, a zdr: false decode round-trip, and a ChatRequest encoding "provider":{"zdr":true}. README's provider-preferences table and the embeddings field list mention zdr.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a zero data retention preference for routing requests to providers with zero data retention policies.
    • Added support for configuring and preserving this preference in chat and embedding requests.
  • Documentation

    • Updated provider preference documentation to describe the zero data retention setting.

OpenRouter's provider-routing object takes a per-request `zdr`
boolean that restricts routing to providers with a zero data
retention policy. `ProviderPreferences` covered `order`, `only`,
`sort`, `allow_fallbacks`, and `data_collection` but had no way to
set it, so callers who needed ZDR routing had to hand-build the
provider payload.

`data_collection: deny` is not a substitute. It only stops a
provider from collecting prompts for training, and providers that
retain request data for logging or abuse monitoring still pass that
filter. `zdr: true` is the flag that excludes them.

The field is optional and encodes only when set, so existing
requests serialize byte-for-byte as before. `EmbeddingsRequest`
reuses the same struct and picks the field up for free.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions github-actions Bot added the enhancement New feature or request label Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 395f9c06-9ca3-4915-9100-9c34488907bd

📥 Commits

Reviewing files that changed from the base of the PR and between 360b8b0 and 123f85a.

📒 Files selected for processing (3)
  • README.md
  • Sources/OpenRouterKit/Models/Chat/ChatRequest.swift
  • Tests/OpenRouterKitTests/ProviderPreferencesTests.swift

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

ProviderPreferences now supports an optional zdr flag. The flag is encoded and decoded as zdr, tested in provider and chat request payloads, and documented as zero data retention routing.

Changes

Zero Data Retention Provider Preference

Layer / File(s) Summary
ProviderPreferences zdr contract
Sources/OpenRouterKit/Models/Chat/ChatRequest.swift
Adds the optional zdr property, initializer parameter, decoding, and conditional encoding.
zdr validation and documentation
Tests/OpenRouterKitTests/ProviderPreferencesTests.swift, README.md
Tests direct and nested serialization. README documents zdr for embeddings and provider preferences.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 123f8

This adds optional zero-data-retention routing to provider preferences without changing payloads when unset. The new value is serialized through chat requests and covered for enabled, disabled, and omitted cases, with no current merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding zdr support to ProviderPreferences.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/provider-zdr

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

A rabbit packed a flag so neat
zdr hopped into the JSON street
True or false, it keeps its place
Tests guard every nesting space
Zero-retention routing leaves no trace

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

@ProJedi1234
ProJedi1234 merged commit 946bd8e into main Sep 10, 2026
7 checks passed
@ProJedi1234
ProJedi1234 deleted the feat/provider-zdr branch September 10, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant