Skip to content

Conversation

@gyancr7
Copy link

@gyancr7 gyancr7 commented Jan 12, 2026

Overview

Adds support for Azure AI Anthropic API endpoints alongside the existing direct Anthropic API, with an extensible architecture that simplifies future integration of additional AI providers (OpenAI, Azure OpenAI, Google Gemini, etc.).

Problem

HyperDX currently only supports Anthropic's direct API for AI-powered query assistance. Organizations using Azure AI services cannot integrate Anthropic models through Azure's infrastructure.

Solution

1. Core Refactoring

New controllers/ai.ts:

  • Centralized getAIModel() function for all AI configuration
  • Multi-provider architecture
  • Clean separation of concerns from business logic

Updated config.ts:

  • Provider-agnostic environment variables
  • Backward compatibility with legacy configuration
  • Clear migration path for existing deployments

Simplified routers/api/ai.ts:

  • Removed inline AI configuration
  • Single line: const model = getAIModel()
  • Business logic unchanged

2. Configuration

New Environment Variables (Recommended)

AI_API_KEY=your-api-key           # API key for any provider
AI_BASE_URL=https://...           # Optional: Custom endpoint
AI_MODEL_NAME=model-name          # Optional: Model/deployment name

Legacy Variables (Still Supported)

ANTHROPIC_API_KEY=sk-ant-api03-xxx  # Auto-detected if no AI_PROVIDER set

Fixes #1588

- Add ANTHROPIC_BASE_URL and ANTHROPIC_DEPLOYMENT_NAME environment variables
- Update Anthropic client configuration to support both direct API and Azure endpoints
- Maintain backward compatibility with existing direct Anthropic API setup
- Use deployment name when Azure endpoint is configured, otherwise default model

Fixes hyperdxio#1588
@changeset-bot
Copy link

changeset-bot bot commented Jan 12, 2026

⚠️ No Changeset found

Latest commit: c44e39c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jan 12, 2026

@gyancr7 is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

// const model = anthropic('claude-3-5-haiku-latest');
const model = anthropic('claude-sonnet-4-5-20250929');
// Use Azure deployment name if configured, otherwise use default model
const modelName = config.ANTHROPIC_DEPLOYMENT_NAME || 'claude-sonnet-4-5-20250929';
Copy link
Member

Choose a reason for hiding this comment

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

Can we change this to AI_MODEL_NAME? Want to try and keep model name configuration generic (so we can add providers in the future)


const anthropic = createAnthropic({
// Support both direct Anthropic API and Azure AI endpoints
const anthropicConfig: any = {
Copy link
Member

Choose a reason for hiding this comment

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

Could we type this configuration? Something like this:

      type AnthropicConfig = NonNullable<Parameters<typeof createAnthropic>[0]>;
      const payload: AnthropicConfig = {
        apiKey: config.ANTHROPIC_API_KEY,
      };

anthropicConfig.baseURL = config.ANTHROPIC_BASE_URL;
}

const anthropic = createAnthropic(anthropicConfig);
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to do this, but if you are open to it, I would love to make this easier for others to extend since we've had a few issues about supporting other providers.

What I was thinking is we create a new file and function called getAIModel in api/src/controllers/ai.ts This function helps abstract some of this code so we can reuse this and add AI to other spots.

import { anthropic } from '@ai-sdk/anthropic'
import type { LanguageModel } from 'ai'

export function getAIModel(): LanguageModel {
  const modelName = config.AI_MODEL_NAME
  
   if (!config.ANTHROPIC_API_KEY) {
        throw new Error('No ANTHROPIC_API_KEY defined');
      }

   /// your logic here

   return model;
}

Then, down the road, we can enhance this function to do something like config.AI_PROVIDER and if it's set to openai or something else we have all the logic in one spot.

Copy link
Author

@gyancr7 gyancr7 Jan 12, 2026

Choose a reason for hiding this comment

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

Makes complete sense, I would be happy to contribute for this.

…safety

- Create getAIModel() function in controllers/ai.ts with proper TypeScript types
- Add provider-agnostic config: AI_PROVIDER, AI_API_KEY, AI_MODEL_NAME
- Support future providers (OpenAI, Azure OpenAI, Google) via architecture
- Maintain backward compatibility with ANTHROPIC_API_KEY

Addresses PR hyperdxio#1590 feedback from brandon-pereira
Fixes hyperdxio#1588
@gyancr7
Copy link
Author

gyancr7 commented Jan 19, 2026

@brandon-pereira I have tried addressing the review comments in this commit 6a9c24f

@gyancr7 gyancr7 changed the title feat: Add support for Azure AI Anthropic API endpoints feat: extending AI support for multi-providers Jan 19, 2026
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.

Add support for Azure AI Anthropic API endpoints alongside direct Anthropic API

2 participants