Skip to content

feat: support OpenAI model subpaths#4110

Open
spduan78 wants to merge 1 commit into
higress-group:mainfrom
spduan78:codex/support-openai-model-subpaths
Open

feat: support OpenAI model subpaths#4110
spduan78 wants to merge 1 commit into
higress-group:mainfrom
spduan78:codex/support-openai-model-subpaths

Conversation

@spduan78

@spduan78 spduan78 commented Jul 8, 2026

Copy link
Copy Markdown

Summary

Add OpenAI model resource subpath support for /v1/models/{model} in the AI proxy.

Higress already recognizes the model list endpoint /v1/models, but the OpenAI Models API also includes retrieving a model and deleting a fine-tuned model through the model resource path. Without a dedicated capability, these resource requests cannot be classified or remapped by capability path.

Changes

  • Add ApiNameRetrieveModel and PathOpenAIRetrieveModel.
  • Add OpenAI default capability mapping for the model resource path.
  • Add regex-based route detection for /v1/models/<model_id>.
  • Add {model_id} placeholder substitution in MapRequestPathByCapability.
  • Allow the new capability in provider JSON configuration.
  • Add regression tests for API detection, path remapping, default capabilities, and config parsing.

The internal placeholder is named {model_id} to avoid colliding with Azure deployment paths that already use {model} as a deployment placeholder.

Reference: OpenAI Models API reference documents list models, retrieve model, and delete fine-tuned model endpoints.

Tests

GOCACHE=/private/tmp/higress-go-cache go test ./... -run 'Test_getApiName|TestProviderConfig_FromJsonModelCapabilities|TestOpenAIProviderInitializer_DefaultCapabilitiesModels|TestUtil' -count=1
GOCACHE=/private/tmp/higress-go-cache go test ./provider -run 'TestAzureDefaultOpenAIV1Capabilities|TestOpenAIProviderInitializer_DefaultCapabilitiesModels|TestProviderConfig_FromJsonModelCapabilities' -count=1
GOCACHE=/private/tmp/higress-go-cache go test . -run 'Test_getApiName|TestUtil' -count=1
GOCACHE=/private/tmp/higress-go-cache go test ./...

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants