Skip to content

Migrate service model base url#3560

Merged
peterschmidt85 merged 6 commits intomasterfrom
migrate-service-model-base-url
Feb 17, 2026
Merged

Migrate service model base url#3560
peterschmidt85 merged 6 commits intomasterfrom
migrate-service-model-base-url

Conversation

@peterschmidt85
Copy link
Contributor

@peterschmidt85 peterschmidt85 commented Feb 10, 2026

Summary

Migrate service.model.base_url from the deprecated gateway.{domain} model aggregation endpoint to the service endpoint for openai-format models.

  • service.model.base_url: For openai format, set to service_url + prefix (e.g. https://run-name.domain.com/v1). For other formats, keep the existing gateway.{domain} URL.
  • Default probe URL: Derive from model's prefix field instead of hardcoding /v1.
  • CORS on gateway service endpoints: Add CORS support (preflight handling + response headers) to the service.jinja2 nginx template, enabled only for services with openai-format models. Strips upstream CORS headers to avoid duplicates.
  • cors_enabled on Service model: Store CORS flag per-service for correctness with multiple services. Includes a startup migration for gateways with pre-existing state.

peterschmidt85 and others added 5 commits February 10, 2026 11:53
…/v1`) if `model` has `openai` format.

- Add CORS support to the gateway service endppoint (if `model` has `openai` format)
… backward compatibility (with older verions of gateway)
Now that service.model.base_url points to service.url + /v1 for
openai-format models, it is no longer deprecated and can be recommended
as the model endpoint.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@peterschmidt85 peterschmidt85 marked this pull request as ready for review February 10, 2026 12:23
Copy link
Collaborator

@Bihan Bihan left a comment

Choose a reason for hiding this comment

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

These changes do not affect SGLang router–based services, before or after PR

@peterschmidt85
Copy link
Contributor Author

@jvstme Let me know once you have a look. In principle, we can also merge as is.

strip_prefix: bool = True # only used in-server
replicas: tuple[Replica, ...]
router: Optional[AnyRouterConfig] = None
cors_enabled: bool = False # only used on gateways; enabled for openai-format models
Copy link
Collaborator

Choose a reason for hiding this comment

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

(nit) Whether CORS is enabled is a decision the gateway takes based on existing data points, not a new data point, so I'd prefer not to persist it in the repo.

But if there isn't a different and easy way to implement that decision, I don't mind keeping it as is

Copy link
Collaborator

Choose a reason for hiding this comment

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

This CORS policy is more permissive than what we have on the gateway.* endpoint, because this policy allows cross-origin requests to the entire service, not just the model. Consider setting a stricter policy by returning the CORS headers only from /v1 (or a different configured OpenAI API prefix). Should be relatively easy to implement with an if ($request_uri ~ ^/<prefix>) block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if you don't strongly insist, I'd prefer to implement it separately from the main PR.

Comment on lines +84 to +87
proxy_hide_header 'Access-Control-Allow-Origin';
proxy_hide_header 'Access-Control-Allow-Methods';
proxy_hide_header 'Access-Control-Allow-Headers';
proxy_hide_header 'Access-Control-Allow-Credentials';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that this prevents users from configuring their own CORS policy for the service. For example, users may want to set a stricter Access-Control-Allow-Origin, which is a requirement if they also set Access-Control-Allow-Credentials (which is forbidden when Access-Control-Allow-Origin is *).

But I'm not sure if there's an easy way to set headers conditionally, based on whether a header was returned by the upstream.

Maybe this limitation won't have any realistic impact if we only set our CORS policy on /v1 (or another configured OpenAI API prefix)

@peterschmidt85 peterschmidt85 merged commit 5cc60b7 into master Feb 17, 2026
28 checks passed
@peterschmidt85 peterschmidt85 deleted the migrate-service-model-base-url branch February 17, 2026 09:01
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