Skip to content

docs(core): clarify Model.model_name is the upstream id (#302 / AISIX-Cloud#470) - #384

Merged
moonming merged 2 commits into
mainfrom
docs/model-upstream-id-clarify
May 23, 2026
Merged

docs(core): clarify Model.model_name is the upstream id (#302 / AISIX-Cloud#470)#384
moonming merged 2 commits into
mainfrom
docs/model-upstream-id-clarify

Conversation

@moonming

@moonming moonming commented May 23, 2026

Copy link
Copy Markdown
Member

Summary

The `Model` struct has two identifiers:

Field Role
`display_name` Customer-facing alias the SDK sends in `POST /v1/chat/completions { model: ... }`
`model_name` Upstream id the LLM API expects (e.g. `"gpt-4o-mini-2024-08-06"`)

The field names alone don't make this obvious. Some other proxy gateways in the ecosystem use the name `model_name` to mean the opposite — i.e. the customer-facing alias — with a separate `model` sub-field for the upstream id. A reader who knows that convention from a neighbour project will get the AISIX struct backwards on first read.

This PR is a 14-line doc comment on `Model.model_name` (`crates/aisix-core/src/models/model.rs:220`) that explicitly calls out the convention reversal. Zero behaviour change, zero wire change, no test impact.

Why not just rename it?

Renaming `model_name` → `upstream_id` to remove the ambiguity is tracked at api7/AISIX-Cloud#470. It's a coordinated wire-format change that touches ai-gateway + cp-api + dashboard + ~110 test fixtures + PG column. Cost-vs-benefit isn't there today — the field is internal-only (no customer-facing surface), and a doc comment captures 80% of the clarity benefit at 1% of the migration cost.

The rename can ride along the next big wire revision; until then, the comment carries the disambiguation.

Test plan

  • `cargo check -p aisix-core` — clean (verified locally)
  • `cargo fmt --check` — applied (verified locally)
  • No new tests needed (doc-only change)

Closes the doc-clarity half of the audit finding on #302 A2/B8/M19 (Model rename). cp-api side has a companion 1-line doc comment landing as a separate PR in api7/AISIX-Cloud.

Summary by CodeRabbit

  • Documentation
    • Enhanced documentation for model identifier fields, clarifying upstream naming conventions and their distinction from customer-facing aliases.

Review Change Stack

#302 / AISIX-Cloud#470)

The Model struct has two identifiers — `display_name` (customer-facing
alias the chat client sends) and `model_name` (upstream id the LLM API
expects). The field NAMES alone do not make this obvious, and some
other proxy gateways in the ecosystem use `model_name` to mean the
opposite — i.e. the alias, with a separate `model` field for the
upstream id. A reader who knows that convention from a neighbour
project will get this backwards on first read.

Renaming the field to `upstream_id` to remove the ambiguity is tracked
at api7/AISIX-Cloud#470, but it's a coordinated wire-format change
across ai-gateway + cp-api + dashboard + ~110 test fixtures + PG
column. Not justified by the cost-vs-benefit today (see #470 audit
discussion).

This commit takes the cheap-and-correct path: a 14-line doc comment
on `Model.model_name` that explicitly names the convention reversal
so the next reader doesn't get tripped up. Zero behaviour change,
zero wire change, no test impact.

`cargo check -p aisix-core` clean. `cargo fmt` applied.
Copilot AI review requested due to automatic review settings May 23, 2026 01:40
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@moonming, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 3 reviews/hour. Refill in 14 minutes and 25 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 5b2deabc-47d3-48aa-91eb-e020aa49b218

📥 Commits

Reviewing files that changed from the base of the PR and between 5c0fb3d and 5aa9ed1.

📒 Files selected for processing (1)
  • schemas/resources/model.schema.json
📝 Walkthrough

Walkthrough

The PR expands documentation for the Model.model_name field in the core model struct, clarifying that it represents the upstream model identifier sent to the provider. The updated doc comment includes example values, explains the naming convention distinction from display_name, and references a deferred rename plan.

Changes

Model field documentation clarification

Layer / File(s) Summary
Model.model_name field documentation
crates/aisix-core/src/models/model.rs
Model.model_name doc comment expanded with explicit upstream identifier contract description, example upstream ids, and clarification of naming convention ("footgun"), distinguishing it from customer-facing display_name. Deferred rename to upstream_id is documented.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates aisix-core documentation to clarify the semantic difference between Model.display_name (customer-facing alias used on gateway APIs) and Model.model_name (the upstream/provider-facing identifier), explicitly warning about the common convention mismatch with other gateways.

Changes:

  • Expanded the rustdoc comment on Model.model_name to describe its role and common confusion with other projects.
  • Added a NOTE explaining the “footgun” naming reversal vs other gateways and linked the longer-term rename tracking issue.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +220 to +223
/// Upstream model id sent to the provider — the literal string
/// the upstream LLM API expects in its `model` field
/// (e.g. `"gpt-4o"`, `"claude-sonnet-4-5"`,
/// `"gpt-4o-mini-2024-08-06"`). `None` for routing models.
…c expansion

The JsonSchema derive macro emits Rust doc comments as the schema's
`description` field. The longer doc on `Model.model_name` (previous
commit) expanded the schema's description string; the CI `schema drift
(resources)` job caught it and asked for the regenerated file to be
committed.

`cargo run -p aisix-core --bin dump-schema` regenerated all 8
resource schemas; only `model.schema.json` actually changed (the
others are unchanged because no other resource's docs were touched).
@moonming
moonming merged commit 550716d into main May 23, 2026
8 checks passed
@jarvis9443
jarvis9443 deleted the docs/model-upstream-id-clarify branch June 25, 2026 06:25
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.

2 participants