Skip to content

feat: rust sglang server openai apis - #32998

Closed
mrain wants to merge 5 commits into
sgl-project:rainj-me/rust-serverfrom
mrain:cl/rust-openai-apis
Closed

mrain wants to merge 5 commits into
sgl-project:rainj-me/rust-serverfrom
mrain:cl/rust-openai-apis

Conversation

@mrain

@mrain mrain commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Implemented the full OpenAI APIs for rust sglang server.
Based on #29799

Modifications

Implemented APIs:

  • v1/models
  • v1/completions
  • v1/chat/completions
  • v1/responses

Some design decisions

  • n fanout: Fan-out in HTTP layer — submits n separate GenerateRequests, each with n=1. Matches external API behavior, avoids native n > 1 rejection
  • Auth: --api-key Bearer token gating on all OpenAI endpoints (default: open for no key configured)
  • Deprecated function_call/functions: Explicitly rejected with migration message (Python silently ignores)
  • text_offset: SGLang emits [-1] sentinels; post-processed in completion_response_value since Dynamo types it as u32
  • system_fingerprint: Removed from responses (Python doesn't include it)
  • reasoning_content: null: Serialized into every SSE delta chunk (Python compat)
  • 400 for unknown model: Consistently 400 on generation endpoints (Python convention)

Accuracy Tests

  • Python integration tests: Existing TestOpenAIServer, TestOpenAIFunctionCalling, TestOpenAIResponses classes reused verbatim behind is_rust_server_built() guards via class attribute aliasing
  • Rust unit tests: 26 tests covering deserialization, unary fold ordering, streaming deltas, tool-call parsing, marker buffering, split-marker handling, response lifecycle events, logprob shapes

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #30651200216
Latest PR Test (Extra): ❌ Run #30651196411

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Jul 31, 2026
@mrain
mrain changed the base branch from main to rainj-me/rust-server July 31, 2026 02:50
@mrain
mrain force-pushed the cl/rust-openai-apis branch from 27b4a9a to 16b2750 Compare July 31, 2026 02:52
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

https://github.com/sgl-project/sglang/blob/27b4a9a918b4b2b5fe9db6e857b14a788af94586/python/sglang/srt/managers/scheduler.py#L1832-L1837
P1 Badge Start only one Rust frontend for data-parallel serving

When dp_size > 1, every data-parallel scheduler has local PP/attention-TP/attention-CP rank zero, so every worker passes this predicate and calls RustServer.launch. Each launch binds the same server_args.host:server_args.port, causing all but one scheduler to fail with an address-in-use error and preventing the DP deployment from starting; the frontend needs to be hosted once and requests routed to the DP workers, or Rust mode must reject DP configurations explicitly.


https://github.com/sgl-project/sglang/blob/27b4a9a918b4b2b5fe9db6e857b14a788af94586/python/sglang/srt/managers/rust_server.py#L81-L85
P1 Badge Honor TLS settings when launching the Rust listener

When --ssl-certfile is configured, this still launches a plain TCP/HTTP Axum listener and never passes the certificate or key to the Rust server. Meanwhile _execute_server_warmup derives an https:// URL from the same ServerArgs, so its first request fails the TLS handshake and kills the process; even with warmup skipped, HTTPS clients cannot connect. Rust mode should configure TLS or reject SSL options before launch.


https://github.com/sgl-project/sglang/blob/27b4a9a918b4b2b5fe9db6e857b14a788af94586/rust/sglang-server/src/api_server/openai.rs#L90-L93
P2 Badge Resolve all supported chat-template argument forms

When --chat-template is a documented built-in template name, read_to_string treats that name as a filesystem path and disables chat support when the file is absent; for a supported JSON template file, it instead installs the entire JSON document as Jinja source. Consequently /v1/chat/completions and /v1/responses return “no usable chat template” or render an invalid prompt for valid existing CLI configurations. This needs the same built-in/Jinja/JSON resolution semantics as Python's TemplateManager.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 31, 2026
@mrain mrain changed the title feat: rust sglang server open apis feat: rust sglang server openai apis Jul 31, 2026
@merrymercy
merrymercy deleted the branch sgl-project:rainj-me/rust-server July 31, 2026 18:56
@merrymercy merrymercy closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants