Skip to content

Add try-it page on Gateway usage example modal#21077

Merged
PattaraS merged 50 commits intomlflow:masterfrom
PattaraS:gateway-ui-based-invocation
Feb 27, 2026
Merged

Add try-it page on Gateway usage example modal#21077
PattaraS merged 50 commits intomlflow:masterfrom
PattaraS:gateway-ui-based-invocation

Conversation

@PattaraS
Copy link
Collaborator

@PattaraS PattaraS commented Feb 23, 2026

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

Adds an interactive "Try it" tab to the AI Gateway endpoint usage modal, letting users send requests directly to an endpoint from the UI.

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests
usage-modal

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Does this PR require updating the MLflow Skills repository?

  • No. You can skip the rest of this section.
  • Yes. Please link the corresponding PR or explain how you plan to update it.

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

AI Gateway endpoint usage modal now includes a "Try it" tab for sending requests interactively from the UI, with support for both Unified (MLflow Invocations) and Passthrough (OpenAI, Anthropic, Gemini) APIs.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

Yes should be selected for bug fixes, documentation updates, and other small changes. No should be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.

What is a minor/patch release?
  • Minor release: a release that increments the second part of the version number (e.g., 1.2.0 -> 1.3.0).
    Bug fixes, doc updates and new features usually go into minor releases.
  • Patch release: a release that increments the third part of the version number (e.g., 1.2.0 -> 1.2.1).
    Bug fixes and doc updates usually go into patch releases.
  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

Copilot AI review requested due to automatic review settings February 23, 2026 14:57
@github-actions
Copy link
Contributor

🛠 DevTools 🛠

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/21077/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/21077/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/21077/merge

@github-actions github-actions bot added the size/L Large PR (200-499 LoC) label Feb 23, 2026
@github-actions github-actions bot added v3.10.1 rn/feature Mention under Features in Changelogs. labels Feb 23, 2026
@PattaraS
Copy link
Collaborator Author

/autoformat

@github-actions github-actions bot removed the rn/feature Mention under Features in Changelogs. label Feb 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds an interactive "Try it" tab to the Endpoint Usage Modal in the MLflow Gateway UI, allowing users to test API endpoints directly from the browser without writing code.

Changes:

  • Adds a new "Try it" tab with interactive request/response interface for testing gateway endpoints
  • Supports both Unified (MLflow Invocations) and Passthrough (provider-specific) API modes
  • Includes provider selection (OpenAI, Anthropic, Google Gemini) for passthrough requests

Comment on lines +366 to +519
{activeTab === 'try-it' && (
<div css={{ display: 'flex', flexDirection: 'column', gap: theme.spacing.md }}>
<Typography.Text color="secondary">
<FormattedMessage
defaultMessage='Edit the request body below and click Send request to call the endpoint. Choose Unified for the MLflow Invocations API, or Passthrough for provider-specific APIs (OpenAI, Anthropic, Gemini).'
description="Try it tab description"
/>
</Typography.Text>
<div>
<Typography.Text bold css={{ display: 'block', marginBottom: theme.spacing.xs }}>
<FormattedMessage defaultMessage="API" description="API type selector label" />
</Typography.Text>
<SegmentedControlGroup
name="try-it-api-type"
componentId="mlflow.gateway.usage-modal.try-it.api-type"
value={tryItApiType}
onChange={({ target: { value } }) => {
setTryItApiType(value as 'unified' | 'passthrough');
setRequestBody(
value === 'unified' ? DEFAULT_REQUEST_BODY_UNIFIED : getPassthroughDefaultBody(tryItProvider, endpointName),
);
}}
css={{ marginBottom: theme.spacing.sm }}
>
<SegmentedControlButton value="unified">
<FormattedMessage defaultMessage="Unified (MLflow Invocations)" description="Unified API option" />
</SegmentedControlButton>
<SegmentedControlButton value="passthrough">
<FormattedMessage defaultMessage="Passthrough" description="Passthrough API option" />
</SegmentedControlButton>
</SegmentedControlGroup>
</div>
{tryItApiType === 'passthrough' && (
<div>
<Typography.Text bold css={{ display: 'block', marginBottom: theme.spacing.xs }}>
<FormattedMessage defaultMessage="Provider" description="Provider selector label" />
</Typography.Text>
<SegmentedControlGroup
name="try-it-provider"
componentId="mlflow.gateway.usage-modal.try-it.provider"
value={tryItProvider}
onChange={({ target: { value } }) => {
const provider = value as Provider;
setTryItProvider(provider);
setRequestBody(getPassthroughDefaultBody(provider, endpointName));
}}
css={{ marginBottom: theme.spacing.sm }}
>
<SegmentedControlButton value="openai">OpenAI</SegmentedControlButton>
<SegmentedControlButton value="anthropic">Anthropic</SegmentedControlButton>
<SegmentedControlButton value="gemini">Google Gemini</SegmentedControlButton>
</SegmentedControlGroup>
</div>
)}
<div
css={{
display: 'flex',
gap: theme.spacing.md,
minHeight: 0,
flex: 1,
}}
>
<div css={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column' }}>
<div css={{ display: 'flex', alignItems: 'center', gap: theme.spacing.xs, marginBottom: theme.spacing.xs }}>
<Typography.Text bold>
<FormattedMessage defaultMessage="Request" description="Request body label" />
</Typography.Text>
<Tooltip
content={
<FormattedMessage
defaultMessage='JSON body for the MLflow Invocations API. Use "messages" for chat or "input" for embeddings.'
description="Request body tooltip"
/>
}
>
<span css={{ cursor: 'help', color: theme.colors.textSecondary }} aria-label="Request help">
?
</span>
</Tooltip>
</div>
<Input.TextArea
componentId="mlflow.gateway.usage-modal.try-it.request"
value={requestBody}
onChange={(e) => setRequestBody(e.target.value)}
disabled={isSending}
rows={10}
css={{
fontFamily: 'monospace',
fontSize: theme.typography.fontSizeSm,
}}
/>
</div>
<div css={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column' }}>
<div css={{ display: 'flex', alignItems: 'center', gap: theme.spacing.xs, marginBottom: theme.spacing.xs }}>
<Typography.Text bold>
<FormattedMessage defaultMessage="Response" description="Response body label" />
</Typography.Text>
<Tooltip
content={
<FormattedMessage
defaultMessage="Response from the endpoint after clicking Send request."
description="Response body tooltip"
/>
}
>
<span css={{ cursor: 'help', color: theme.colors.textSecondary }} aria-label="Response help">
?
</span>
</Tooltip>
</div>
<Input.TextArea
componentId="mlflow.gateway.usage-modal.try-it.response"
value={responseBody}
readOnly
rows={10}
placeholder={
sendError
? undefined
: isSending
? undefined
: 'Click "Send request" to see the response here.'
}
css={{
fontFamily: 'monospace',
fontSize: theme.typography.fontSizeSm,
backgroundColor: theme.colors.backgroundSecondary,
}}
/>
{sendError && (
<Typography.Text color="danger" css={{ marginTop: theme.spacing.xs }}>
{sendError}
</Typography.Text>
)}
</div>
</div>
<div css={{ display: 'flex', gap: theme.spacing.sm }}>
<Button
componentId="mlflow.gateway.usage-modal.try-it.send"
type="primary"
onClick={handleSendRequest}
disabled={isSending}
>
<FormattedMessage defaultMessage="Send request" description="Send request button" />
</Button>
<Button
componentId="mlflow.gateway.usage-modal.try-it.reset"
onClick={handleResetExample}
disabled={isSending}
>
<FormattedMessage defaultMessage="Reset example" description="Reset example button" />
</Button>
</div>
</div>
)}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

🔴 CRITICAL: No test coverage exists for the new Try it tab functionality. The existing tests only cover the Unified and Passthrough tabs. Tests should be added to verify: request sending, error handling, API type switching, provider selection, response display, and state reset behavior.

Copilot uses AI. Check for mistakes.
? undefined
: isSending
? undefined
: 'Click "Send request" to see the response here.'
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

🟢 NIT: The hardcoded placeholder text "Click 'Send request' to see the response here." doesn't match the actual button text "Send request" in the code (without quotes around "Send request"). For consistency, either add quotes in the button FormattedMessage or remove them from the placeholder.

Suggested change
: 'Click "Send request" to see the response here.'
: 'Click Send request to see the response here.'

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

Documentation preview for 188815c is available at:

Changed Pages (1)

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

@PattaraS
Copy link
Collaborator Author

@copilot open a new pull request to apply changes based on the comments in this thread

@github-actions github-actions bot added rn/feature Mention under Features in Changelogs. area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server labels Feb 24, 2026
@PattaraS PattaraS self-assigned this Feb 24, 2026
@PattaraS
Copy link
Collaborator Author

/autoformat

1 similar comment
@PattaraS
Copy link
Collaborator Author

/autoformat

@PattaraS PattaraS changed the title Add try-it page Add try-it page on Gateway usage example modal Feb 24, 2026

const tryItRequestUrl = useMemo(() => {
if (tryItApiType === 'unified') {
return `${base}/gateway/${endpointName}/mlflow/invocations`;
Copy link
Collaborator

@TomeHirata TomeHirata Feb 24, 2026

Choose a reason for hiding this comment

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

Why we don't allow users to try unified chat completion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I missed that! Adding it now.

}
}, [open]);

const tryItRequestUrl = useMemo(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already show urls for each endpoint type in the curl example, can we consolidate the mapping util?

@PattaraS PattaraS added the ui-preview Deploy UI preview on Databricks Apps label Feb 24, 2026
[tryItApiType, tryItProvider, endpointName],
);

const handleSendRequest = useCallback(async () => {
Copy link
Collaborator

@TomeHirata TomeHirata Feb 24, 2026

Choose a reason for hiding this comment

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

Can we extract the main logic to a util that calls the invocation api and returns the response or raise an exception?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the PR with some refactor.

@TomeHirata
Copy link
Collaborator

Can we test if the test it functionality works even when auth is enabled?

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

UI Preview for this PR has been removed.

@PattaraS
Copy link
Collaborator Author

Can we test if the test it functionality works even when auth is enabled?

I did that (also added a test)

@TomeHirata
Copy link
Collaborator

@PattaraS sorry for the back and forth, but I started to think it's semantically clearer if we locate the "try it" tab in the same level as curl or python. So the information structure would be (unified|passthrough) => (try it|python|curl). also, since the try it functionality is shared between unified and passthrough and has sizable complexity, we might want to create a child component for the try it functionality, and then use it in EndpointUsageModal to avoid making this component large. What do you think?

@PattaraS
Copy link
Collaborator Author

@PattaraS sorry for the back and forth, but I started to think it's semantically clearer if we locate the "try it" tab in the same level as curl or python. So the information structure would be (unified|passthrough) => (try it|python|curl). also, since the try it functionality is shared between unified and passthrough and has sizable complexity, we might want to create a child component for the try it functionality, and then use it in EndpointUsageModal to avoid making this component large. What do you think?

I think that makes sense. Will make a code change accordingly.

Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
…ic-dangerous-direct-browser-access

Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

@PattaraS PattaraS enabled auto-merge February 27, 2026 08:53
@PattaraS PattaraS added this pull request to the merge queue Feb 27, 2026
Merged via the queue into mlflow:master with commit 6d221ef Feb 27, 2026
58 checks passed
@PattaraS PattaraS deleted the gateway-ui-based-invocation branch February 27, 2026 09:02
@github-actions github-actions bot added size/XL Extra-large PR (500+ LoC) and removed size/L Large PR (200-499 LoC) labels Feb 27, 2026
daniellok-db pushed a commit to daniellok-db/mlflow that referenced this pull request Mar 5, 2026
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
Co-authored-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
daniellok-db pushed a commit to daniellok-db/mlflow that referenced this pull request Mar 5, 2026
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
Co-authored-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
daniellok-db pushed a commit that referenced this pull request Mar 5, 2026
Signed-off-by: Pat Sukprasert <pattara.sk127@gmail.com>
Signed-off-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
Co-authored-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server rn/feature Mention under Features in Changelogs. size/XL Extra-large PR (500+ LoC) ui-preview Deploy UI preview on Databricks Apps v3.10.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants