mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
e35d22807e
Punchcard-Session: coral-workshop-workshop-3f
23 lines
914 B
TypeScript
23 lines
914 B
TypeScript
import type { OpenClawConfig } from "openclaw/plugin-sdk/provider-auth";
|
|
import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
|
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
|
|
export async function resolveXaiRealtimeApiKey(
|
|
configApiKey: string | undefined,
|
|
cfg: OpenClawConfig | undefined,
|
|
): Promise<string> {
|
|
const direct =
|
|
normalizeOptionalString(configApiKey) ?? normalizeOptionalString(process.env.XAI_API_KEY);
|
|
if (direct) {
|
|
return direct;
|
|
}
|
|
const auth = await resolveApiKeyForProvider({ provider: "xai", cfg });
|
|
const oauthKey = normalizeOptionalString(auth?.apiKey);
|
|
if (oauthKey) {
|
|
return oauthKey;
|
|
}
|
|
throw new Error(
|
|
"xAI credentials missing for realtime voice. Sign in with `openclaw onboard --auth-choice xai-oauth`, run `openclaw onboard --auth-choice xai-api-key`, or set XAI_API_KEY.",
|
|
);
|
|
}
|