Skip to content

feat(ai): introduce new env variables to configure provider instances#365

Open
ondrej-langr wants to merge 3 commits into
Openpanel-dev:mainfrom
ondrej-langr:main
Open

feat(ai): introduce new env variables to configure provider instances#365
ondrej-langr wants to merge 3 commits into
Openpanel-dev:mainfrom
ondrej-langr:main

Conversation

@ondrej-langr
Copy link
Copy Markdown

@ondrej-langr ondrej-langr commented May 15, 2026

This adds support for custom OpenAI and Anthropic model providers like Azure which requires changing the base url of each request. Sometimes it is also necessary to define other properties which does this change as well. Makes anything configurable except headers.

Summary by CodeRabbit

  • Documentation
    • Clarified that AI features are optional when API keys are not configured; moved the informational note to the top of the AI section for better visibility.
    • Added and documented new configuration options for OpenAI and Anthropic providers: base URL, project, organization, token, and version settings.

Review Change Stack

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 15, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f57e97b-a17d-4c5b-8191-864b19b9ea55

📥 Commits

Reviewing files that changed from the base of the PR and between b651a7d and 179887f.

📒 Files selected for processing (1)
  • packages/trpc/src/agents/models.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/trpc/src/agents/models.ts

📝 Walkthrough

Walkthrough

Provider initialization refactored from direct process.env reads to Zod-backed environment schemas for OpenAI and Anthropic; providers now warn when API keys are absent and accept optional config fields. Documentation expanded with new OpenAI and Anthropic environment variable entries and an “AI assistant is optional” callout.

Changes

AI Provider Environment Configuration

Layer / File(s) Summary
Environment schema definitions and provider refactoring
packages/trpc/src/agents/models.ts
Zod schemas added for OpenAI and Anthropic env validation; provider factories parse process.env via schemas, log warnings when API keys are missing, and pass optional configuration (OPENAI_BASE_URL, OPENAI_PROJECT, OPENAI_ORGANIZATION, ANTHROPIC_BASE_URL, ANTHROPIC_TOKEN, ANTHROPIC_VERSION) to client constructors.
Environment variables documentation
apps/public/content/docs/self-hosting/environment-variables.mdx
Clarifies AI assistant is optional; adds detailed OpenAI entries (OPENAI_BASE_URL, OPENAI_PROJECT, OPENAI_ORGANIZATION) and Anthropic entries (ANTHROPIC_BASE_URL, ANTHROPIC_TOKEN, ANTHROPIC_VERSION) with types, optionality, defaults, and examples.

Sequence Diagram

sequenceDiagram
  participant Factory as Provider Factory (openai/anthropic)
  participant ProcessEnv as process.env
  participant Schema as Zod Schema
  participant Client as OpenAI/Anthropic Client

  Factory->>ProcessEnv: read environment
  Factory->>Schema: parse(process.env)
  Schema-->>Factory: validated {apiKey, baseURL, project, organization, authToken, version}
  note over Factory: warn if API key missing
  Factory->>Client: new Client({baseURL, project, organization, authToken, version})
  Client-->>Factory: initialized instance
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit nibbles env and keys,
Parses Zod fields with gentle ease,
Warns if a token hops away,
Lets optional URLs stay,
Hooray — the clients wake and play 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing new environment variables (OPENAI_BASE_URL, OPENAI_PROJECT, OPENAI_ORGANIZATION, ANTHROPIC_BASE_URL, ANTHROPIC_TOKEN, ANTHROPIC_VERSION) to configure AI provider instances.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/trpc/src/agents/models.ts`:
- Line 4: Replace the default Zod import used in this file: change the existing
default import statement "import z from 'zod'" to the named import form "import
{ z } from 'zod'" so it matches the codebase convention and other modules that
reference the z symbol (e.g., usages of z.object, z.string, etc.).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5373cf03-d804-426e-804a-acd54990de67

📥 Commits

Reviewing files that changed from the base of the PR and between 8c1636d and b651a7d.

📒 Files selected for processing (2)
  • apps/public/content/docs/self-hosting/environment-variables.mdx
  • packages/trpc/src/agents/models.ts

Comment thread packages/trpc/src/agents/models.ts Outdated
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