Repository navigation
fix(runtime): honor *_BASE_URL env vars in resolveModel for OpenAI-compatible endpoints - #6140
Merged
Merged
Conversation
…mpatible endpoints resolveModel() built each provider with only an apiKey, so a string model spec (e.g. "openai/gpt-4o-mini") could not target an OpenAI-compatible endpoint — OPENAI_BASE_URL was silently ignored, and the only workaround was to construct the LanguageModel yourself and pass the instance. Same gap for Anthropic and Google. Now resolveModel passes baseURL from the standard env var (OPENAI_BASE_URL / ANTHROPIC_BASE_URL / GOOGLE_GENERATIVE_AI_BASE_URL). It is undefined when unset, so the provider falls back to its default endpoint — fully backward compatible. Tests: adds resolve-model-baseurl.test.ts (4 cases). Existing resolveModel tests unchanged (118 runtime tests pass locally). Discovered while building an OpenAI-compatible agent on the V2 runtime + @copilotkit/react-native. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
davidmckayv
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
July 23, 2026 21:35
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
Contributor
|
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
The vi.fn mock factories were 0-arg but invoked with the provider options in the vi.mock adapters, tripping tsc (TS2554). vitest transpiles without type- checking, so it passed vitest locally but failed the check-types job. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tylerslaton
approved these changes
Jul 24, 2026
samjulien
added a commit
that referenced
this pull request
Jul 28, 2026
## What Expands the React Native docs page from a "get to first chat" quickstart into a full production guide, matching the depth of the Slack/Teams frontend pages. The existing quickstart Steps are unchanged; the new material is added after them. ### Production sections added - **Headless imports** — `@copilotkit/react-native/headless` for a custom-UI app, avoiding the chat/attachment native peer deps the default barrel re-exports. - **Metro configuration for release bundles** — `unstable_enablePackageExports` + browser-first `unstable_conditionNames` so the transitive `jose` dependency resolves to its browser build (fails only at release-bundle time otherwise). - **Polyfills** — documents the real auto-installed barrel + granular subpaths, including the `crypto` polyfill (backed by `Math.random`) and the recommendation to install a secure RNG for production. - **Provider options** — the full `CopilotKitProvider` prop surface: `runtimeUrl`, `headers` (auth), `credentials`, `properties`, `onError`, `debug`, `defaultThrottleMs`, `useSingleEndpoint`. - **Runtime and model wiring** — the string model form, `OPENAI_BASE_URL` (and Anthropic/Google equivalents) for OpenAI-compatible endpoints, `createCopilotNodeListener` zero-dep serving, and `BuiltInAgent` options. - **Connecting from a device or bench** — LAN IP, Android emulator `10.0.2.2`, `adb reverse` for USB, and Android release cleartext HTTP via `expo-build-properties`. - **Frontend tools and generative UI** — `useFrontendTool` with zod/Standard Schema, the send-a-turn recipe, `useAgent` read-only subscribe + `threadId`, discriminated-union params, and variable-length `ScrollView` rendering. - **Run lifecycle and UI** — `isRunning` outliving the visible compose, and gating overlays/reveal motion accordingly. - **Voice and speech-to-text** — DIY STT with a graceful-fallback warning for de-Googled/automotive hardware. - Refreshed **What's included** and **Known limitations**, plus a **Next steps** section. ### Dependency on runtime / react-native fixes Three of the four fixes this guide relies on are now **merged to `main`**, so it documents them as current behavior: - `@copilotkit/react-native/headless` subpath (headless provider + hooks without chat/attachment deps) — #6142 ✅ merged - `resolveModel` honoring `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL` / `GOOGLE_GENERATIVE_AI_BASE_URL` for the string model form — #6140 ✅ merged - union / `anyOf` / `oneOf` tool-param schemas surviving JSON-schema→zod conversion — #6143 ✅ merged The fourth — `useAgent` accepting an optional `threadId` (#6141) — is **still open**. The guide therefore does **not** document it as working; it is listed under **Known limitations** instead, and will be promoted once #6141 lands. Every API, export, env var, and behavior in the page was independently re-verified against the package source (three parallel source audits over `packages/{react-native,react-core,runtime}`). That pass turned up one overstatement, fixed in 6eefe2b: only `/headless` and the root barrel side-effect-import the polyfill barrel — `@copilotkit/react-native/components` does not, so the "all three surfaces auto-install" wording was corrected. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Problem
resolveModel()builds each provider with only anapiKey, so a string model spec (e.g."openai/gpt-4o-mini") cannot target an OpenAI-compatible endpoint — Azure OpenAI, OpenRouter, an LLM gateway, or a local server (vLLM / LM Studio / Ollama).OPENAI_BASE_URLis silently ignored, and the only workaround is to drop the ergonomic string form and construct aLanguageModelinstance yourself. The same gap exists for Anthropic and Google.Fix
resolveModelnow passesbaseURLfrom the standard env var for each provider:OPENAI_BASE_URLANTHROPIC_BASE_URLGOOGLE_GENERATIVE_AI_BASE_URLIt is
undefinedwhen the var is unset, so each provider falls back to its default endpoint — fully backward compatible (no behavior change unless you opt in).Tests
Adds
resolve-model-baseurl.test.ts(4 cases): each provider forwards its env var to the SDK factory, and an unset var leavesbaseURLundefined. All existingresolveModeltests pass unchanged (118 runtime tests green locally).Context
Found while building an OpenAI-compatible agent on the V2 runtime +
@copilotkit/react-native, where the string model form couldn't reach the configured endpoint.🤖 Generated with Claude Code