Skip to content

fix(api): normalize openai_compatible provider name in models endpoint (fixes #792)#801

Merged
lfnovo merged 1 commit into
lfnovo:mainfrom
code-with-rashid:fix/openai-compatible-provider-name-mismatch
May 29, 2026
Merged

fix(api): normalize openai_compatible provider name in models endpoint (fixes #792)#801
lfnovo merged 1 commit into
lfnovo:mainfrom
code-with-rashid:fix/openai-compatible-provider-name-mismatch

Conversation

@code-with-rashid
Copy link
Copy Markdown
Contributor

Summary

Fixes #792 — credentials created for the openai-compatible provider could not be tested or used because the provider name was spelled with a hyphen in api/routers/models.py but with an underscore everywhere else (allow-list, credentials_service.py, dispatch / test / discover branches, the frontend api-keys/page.tsx).

This PR aligns the two locations in api/routers/models.py to the underscore form (openai_compatible) used by the rest of the codebase.

Changes

  • api/routers/models.py L417: provider_status["openai-compatible"]provider_status["openai_compatible"]
  • api/routers/models.py L445: if provider == "openai-compatible":if provider == "openai_compatible":
  • Esperanto itself reports the OpenAI-compatible provider with a hyphen in AIFactory.get_available_providers() (confirmed against esperanto==2.21.0). Added a single esperanto_name = "openai-compatible" local at the Esperanto-boundary inside the special-case branch, with a comment, so the lookup against esperanto_available[model_type] still succeeds.
  • tests/test_models_api.py: updated assertions on the API response payload to expect the underscore form. Mocked esperanto_available values keep the hyphen form (that's what real Esperanto returns).

Test plan

  • All 8 tests in tests/test_models_api.py::TestModelsProviderAvailability pass.
  • Verified Esperanto returns "openai-compatible" (hyphen) in modality lists, so the normalization at the boundary is needed.
  • Manual end-to-end smoke: create a credential via the UI for an OpenAI-compatible endpoint, click Test — should now succeed (or return the upstream auth/connection error) instead of failing with "Unknown provider: openai-compatible".

🤖 Generated with Claude Code

The /api/models/providers endpoint was exposing the OpenAI-compatible
provider under the hyphen form ("openai-compatible") while the rest of
the codebase - allow-list, credentials service, dispatch, test, and
discover branches - consistently uses the underscore form
("openai_compatible"). Frontend (api-keys/page.tsx) also uses the
underscore form throughout.

The mismatch meant credentials created against this provider could not
be tested or used: every code path that dispatched by provider rejected
them with "Unknown provider: openai-compatible".

Fixed by aligning provider_status and the special-case dispatch to the
underscore form. Esperanto itself exposes the provider with a hyphen, so
the only spot that still references the hyphen form is at the Esperanto
boundary, with a comment explaining why.

Tests in test_models_api.py were asserting the buggy hyphen form on the
API response; updated assertions to match the underscore form. Mocked
Esperanto returns keep the hyphen since that's what real Esperanto
returns.

Fixes lfnovo#792
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@lfnovo lfnovo merged commit 67541a5 into lfnovo:main May 29, 2026
8 of 9 checks passed
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.

[Bug]: openai-compatible credentials fail with "Unknown provider" — hyphen/underscore mismatch between routers/models.py and credentials_service.py

2 participants