| 721 | }; |
| 722 | |
| 723 | const validateConfiguration = () => { |
| 724 | const apiKey = window?.env?.OPENAI_API_KEY ?? OPENAI_API_KEY; |
| 725 | const baseUrl = window?.env?.OPENAI_API_ENDPOINT ?? OPENAI_API_ENDPOINT; |
| 726 | const modelName = window?.env?.LLM_MODEL_NAME ?? LLM_MODEL_NAME; |
| 727 | |
| 728 | // If using custom endpoint and model, don't require OpenAI API key |
| 729 | if (baseUrl && modelName) { |
| 730 | return { useCustomEndpoint: true }; |
| 731 | } |
| 732 | |
| 733 | // If using OpenAI's service, require API key |
| 734 | if (apiKey) { |
| 735 | return { useCustomEndpoint: false }; |
| 736 | } |
| 737 | |
| 738 | throw new Error( |
| 739 | 'Configuration Error: Either provide an OpenAI API key or both a custom endpoint and model name' |
| 740 | ); |
| 741 | }; |
| 742 | |
| 743 | export const exportSQL = async ( |
| 744 | diagram: Diagram, |