import { OpenAi, createAiClient } from '@modal-sh/mio-ai';

export interface CreateOpenAiClientParams {
  apiKey: string;
  organizationId?: string;
  apiVersion?: OpenAi.ApiVersion;
}

export const createOpenAiClient = (params: CreateOpenAiClientParams) => (
  createAiClient({
    platform: OpenAi.PLATFORM_ID,
    platformConfiguration: {
      apiKey: params.apiKey,
      organizationId: params.organizationId,
      apiVersion: params.apiVersion ?? OpenAi.ApiVersion.V1,
    },
  })
);
