Skip to content

Use AzureOpenAI client and clean up env config in chat & image apps#37

Merged
jack-williams merged 2 commits intomainfrom
fix/openai-client-config
May 4, 2026
Merged

Use AzureOpenAI client and clean up env config in chat & image apps#37
jack-williams merged 2 commits intomainfrom
fix/openai-client-config

Conversation

@jack-williams
Copy link
Copy Markdown
Contributor

Cleans up how the chat & image apps configure their OpenAI client.

Changes

Use the dedicated AzureOpenAI client when a base URL is set

When VITE_OPENAI_BASE_URL is set, the apps now construct the SDK's AzureOpenAI class instead of the base OpenAI class with a raw baseURL. This uses the supported Azure auth path (single api-key header + api-version query param) instead of relying on the SDK's OpenAI defaults to talk to Azure.

Drop the dead process.env.OPENAI_* fallbacks

apps/*/vite.config.ts defines process.env as {}, so every process.env.OPENAI_* reference in ChatService / ImageService was inlined as undefined at build time and contributed nothing. The fallbacks looked plausible (a user might think setting OPENAI_BASE_URL would work) but silently did nothing. Configuration is now read only from import.meta.env.VITE_OPENAI_*, the supported way to surface env vars to a Vite client bundle.

New VITE_OPENAI_API_VERSION env var

Required when VITE_OPENAI_BASE_URL points at Azure OpenAI. Threaded through to the AzureOpenAI constructor. Added to vite-env.d.ts for both apps.

Default chat model is now gpt-4.1

Matches the existing default elsewhere in the codebase. Override with VITE_OPENAI_MODEL.

Tidy .env.example for both apps

Optional VITE_OPENAI_BASE_URL / VITE_OPENAI_API_VERSION / VITE_OPENAI_MODEL are commented out with realistic example values. Mirrors layout across both apps.

Document the optional config in the README

A new "Optional configuration" section covers VITE_OPENAI_MODEL, VITE_OPENAI_BASE_URL, and VITE_OPENAI_API_VERSION for both apps.

Context

Builds on the env-driven configuration introduced in #23. Co-authored with @based-jace, who did related groundwork in #31.

Verification

Jack Williams and others added 2 commits April 30, 2026 13:10
- Switch to the SDK's AzureOpenAI client when VITE_OPENAI_BASE_URL is set so
  Azure auth uses the supported single api-key header path with api-version,
  instead of the base OpenAI client with a manually-injected baseURL.
- Drop the dead process.env.OPENAI_* fallbacks. vite.config.ts defines
  process.env as {}, so those reads were inlined as undefined at build time
  and never did anything.
- Read VITE_OPENAI_API_VERSION (new) and use it when constructing the Azure
  client. Update vite-env.d.ts on both apps with the new optional types.
- Default chat model is now gpt-4.1 to match the rest of the codebase.
- Mirror the .env.example layout across both apps and comment out the optional
  vars so copying .env.example does not silently activate the Azure path with
  a placeholder URL.
- Document the optional VITE_OPENAI_* configuration in the README.

Co-authored-by: Jace Medlin <32235747+based-jace@users.noreply.github.com>
…nd API versatility (#38)

* Updated documentation and .env.example to include model limitations and API versatility

* Ran prettier on README

---------

Co-authored-by: Jace Medlin (AIM Consulting Addison Group) <v-jacemedlin@gmail.com>
@jack-williams jack-williams merged commit 6f2a51a into main May 4, 2026
5 checks passed
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