Add OpenAIKeyProvider + RealtimeSettings record
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
namespace backend.Realtime;
|
||||
|
||||
public class OpenAIKeyProvider
|
||||
{
|
||||
private readonly string? _key;
|
||||
|
||||
public OpenAIKeyProvider(IConfiguration cfg)
|
||||
{
|
||||
_key = cfg["OPENAI_API_KEY"] ?? cfg["OpenAI:ApiKey"];
|
||||
}
|
||||
|
||||
public bool HasKey => !string.IsNullOrWhiteSpace(_key);
|
||||
|
||||
public string GetRequired()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_key))
|
||||
throw new InvalidOperationException(
|
||||
"OPENAI_API_KEY is not configured. Set the env var on the Coolify app.");
|
||||
return _key!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user