AI Gateway credentials now return instanceUrl

The AI Gateway credentials endpoint now includes the instance base URL in its response, letting downstream services identify which n8n instance issued the credentials.
When external services or AI gateways call the /v1/gateway/credentials endpoint, they can now see which n8n instance they're communicating with. The response body now includes an instanceUrl field alongside the existing API version and cache metadata.
This matters for workflows where the AI gateway needs to resume operations or send callbacks back to the correct n8n instance — particularly in self-hosted or multi-tenant deployments where multiple instances may be running. Rather than requiring clients to track or infer the instance URL, the information is now provided directly in the credentials response.
The change lives in the CLI package's AI Gateway service, where the method from is called and injected into the response payload.
View Original GitHub Description
Description
Backport of #28520 to release-candidate/2.17.x.
Checklist for the author (@michael-radency) to go through.
- Review the backport changes
- Fix possible conflicts
- Merge to target branch
After this PR has been merged, it will be picked up in the next patch release for release track.
Original description
Summary
PR adds instanceUrl to the body of /v1/gateway/credentials
Related Linear tickets, Github issues, and Community forum posts
<!-- Include links to **Linear ticket** or Github issue or Community forum post. Important in order to close *automatically* and provide context to reviewers. https://linear.app/n8n/issue/[TICKET-ID] --> <!-- Use "closes #<issue-number>", "fixes #<issue-number>", or "resolves #<issue-number>" to automatically close issues when the PR is merged. -->Review / Merge checklist
- I have seen this code, I have run this code, and I take responsibility for this code.
- PR title and summary are descriptive. (conventions) <!-- **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** -->
- Docs updated or follow-up ticket created.
- Tests included. <!-- A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. -->
- PR Labeled with
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)