fix(ai-gateway): resolve gateway by app id in the path - #226
Merged
Conversation
Contributor
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Contributor
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
connection() built the domain-routed gateway URL (${serverUrl}/api/ai/openai/v1),
which requires the request Host to resolve the app. In the browser the SDK
targets the shared host, so a backend function's gateway call lands on a host
that resolves to no app and 404s ("App not found for this domain").
Build the app_id-routed URL instead (${serverUrl}/api/apps/${appId}/ai/openai/v1),
matching how every other runtime module (entities, functions, connectors,
analytics, ...) places appId in the path. The gateway then resolves the app
from the URL regardless of which host the request came in on.
Pairs with the backend app_id mount in base44-dev/apper#15443.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…party SDKs
Replace the Mastra and OpenAI-SDK examples with a single minimal example
showing the connection() -> { baseURL, token } handoff against the
OpenAI-compatible Chat Completions endpoint, and drop specific library names
from the module prose. Keeps the docs client-agnostic ("any OpenAI-compatible
client") instead of pinning third-party SDKs/versions.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
yardend-wix
force-pushed
the
fix/ai-gateway-app-id-route
branch
from
July 9, 2026 13:03
4f6024f to
ee4d816
Compare
Contributor
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/sdk@0.8.37-pr.226.49a8ffdPrefer not to change any import paths? Install using npm alias so your code still imports npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.37-pr.226.49a8ffd"Or add it to your {
"dependencies": {
"@base44/sdk": "npm:@base44-preview/sdk@0.8.37-pr.226.49a8ffd"
}
}
Preview published to npm registry — try new features instantly! |
…aw fetch Replace the bare fetch example with a compact ToolLoopAgent — a background action triggered on a record, with tools that carry input schemas and a finish tool — matching the SDK's house example style (no Deno/npm: scaffolding). Keeps the "point any OpenAI-compatible client at baseURL/token" note. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
DolevEpshtein
approved these changes
Jul 9, 2026
3 tasks
wixysam
pushed a commit
that referenced
this pull request
Jul 28, 2026
* docs(ai-gateway): publish AI Gateway module reference The AI Gateway module's JSDoc was already updated in #226, but the types were never added to the docs pipeline whitelist, so the module never appeared in the generated SDK reference. Add AiGatewayModule and AiGatewayConnection to the docs pipeline, and rewrite the JSDoc for reference quality: explain what an OpenAI-compatible client is, clarify that the credit quota is shared across all app users (not per-user), link to the current model list, and split the growing intro into Models / Authentication Modes / Billing and limits sections. * docs(ai-gateway): fix review feedback on rationale and examples Correct the misleading security claim that calling from a backend function keeps the token out of the browser — it's the same session token already used for every other SDK call. The real reason to use a backend function is code integrity: your instructions, tools, and business logic stay server-side where you can enforce your own auth, rate, and spend limits. Also show where the base44 client comes from in both examples (createClientFromRequest), instead of using a bare base44 with no indication of its origin. * docs(ai-gateway): remove gated model from suggested list claude_opus_4_8 is behind a feature flag and not open to users yet. * docs(ai-gateway): address review feedback on tone, accuracy, and example length Tighten the backend-function rationale, merge the redundant Models intro sentence into the model-options pointer, correct the Authentication Modes section (no permission difference between modes, just which token is returned), note that per-user usage limits are left to the caller to build, and shorten both example tab titles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
base44.aiGateway.connection()built the domain-routed gateway URL:baseURL: `${serverUrl}/api/ai/openai/v1`That endpoint resolves the app from the request Host. But in the browser the SDK targets the shared platform host (
serverUrldefaults tohttps://base44.app), so when a backend function calls the gateway, the injectedBase44-Api-Urlis that shared host — the call lands on a host that resolves to no app and 404s ("App not found for this domain").