Skip to content

OpenRouter: Migrate python-open-router to official openrouter#168011

Open
ab3lson wants to merge 3 commits intohome-assistant:devfrom
ab3lson:feature/open-router-convert-to-official-pkg
Open

OpenRouter: Migrate python-open-router to official openrouter#168011
ab3lson wants to merge 3 commits intohome-assistant:devfrom
ab3lson:feature/open-router-convert-to-official-pkg

Conversation

@ab3lson
Copy link
Copy Markdown
Contributor

@ab3lson ab3lson commented Apr 12, 2026

Proposed change

This MR migrates python-open-router to the official openrouter package. This should alleviate the need to maintain a custom SDK and allows the integration to easily stay up-to-date with OpenRouter capabilities.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings April 12, 2026 02:37
@ab3lson ab3lson requested a review from joostlek as a code owner April 12, 2026 02:38
@home-assistant home-assistant bot added cla-signed dependency Pull requests marked as a dependency upgrade has-tests integration: open_router labels Apr 12, 2026
@home-assistant
Copy link
Copy Markdown

Hey there @joostlek, mind taking a look at this pull request as it has been labeled with an integration (open_router) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of open_router can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign open_router Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Migrates the OpenRouter integration from the third-party python-open-router SDK to the official openrouter Python SDK, updating the config flow and tests accordingly.

Changes:

  • Replaced python-open-router usage with openrouter in the integration config flow.
  • Updated OpenRouter test fixtures and config flow tests to mock the official SDK APIs and error types.
  • Swapped dependency pins from python-open-router==0.3.3 to openrouter==0.8.0 across manifests and requirement sets.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/components/open_router/test_config_flow.py Updates mocks/error construction and adapts tests to the official SDK method surface.
tests/components/open_router/conftest.py Reworks OpenRouter client fixture to patch OpenRouter and return official Model objects.
requirements_test_all.txt Replaces python-open-router with openrouter for tests.
requirements_all.txt Replaces python-open-router with openrouter for runtime.
homeassistant/components/open_router/manifest.json Updates integration requirements to the official SDK.
homeassistant/components/open_router/config_flow.py Refactors API key validation and model fetching to use openrouter via executor jobs.

@ab3lson ab3lson force-pushed the feature/open-router-convert-to-official-pkg branch from e8f5d52 to d1c9835 Compare April 12, 2026 03:48
Comment on lines +53 to +54
label: str = result.data.label
return label
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
label: str = result.data.label
return label
return result.data.label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants