Skip to content

feat(auth): add ElevenLabs provider to auth profile system #403

@alexey-pelykh

Description

@alexey-pelykh

Problem

The auth profile system knows about model API providers (OpenAI, Anthropic, Google, Deepgram, etc.) but does not know about ElevenLabs. This means:

  • No elevenlabs:default profile can be created during onboarding
  • No key rotation for ElevenLabs
  • TTS ElevenLabs keys live in a separate config silo (messages.tts.elevenlabs.apiKey)

Proposed changes

1. Add ElevenLabs to env var resolution

In src/auth/provider-auth.ts, add ElevenLabs as a special-case handler in resolveEnvApiKey (before the generic envMap) to support the legacy XI_API_KEY fallback:

if (normalized === "elevenlabs") {
  return pick("ELEVENLABS_API_KEY") ?? pick("XI_API_KEY");
}

2. Add ElevenLabs to env injection mapping

In src/auth/env-injection.ts, add to resolveProviderEnvVarName:

const envMap: Record<string, string> = {
  // ... existing entries
  elevenlabs: "ELEVENLABS_API_KEY",  // ← add
};

Without this, auth profile → CLI env var injection won't work for ElevenLabs.

3. Onboarding support

Add ElevenLabs credential setter and CLI flag:

src/commands/onboard-auth.credentials.ts — add setter:

export async function setElevenLabsApiKey(key: string) {
  upsertAuthProfile({
    profileId: "elevenlabs:default",
    credential: {
      type: "api_key",
      provider: "elevenlabs",
      key,
    },
  });
}

src/commands/onboard-provider-auth-flags.ts — add flag entry for --elevenlabs-api-key.

When TTS is configured with provider: "elevenlabs", the onboarding flow should:

  • Prompt for ElevenLabs API key
  • Store as elevenlabs:default in auth profiles
  • Remove the need for messages.tts.elevenlabs.apiKey config field

4. Profile ID format

Following existing conventions:

  • elevenlabs:default — primary ElevenLabs API key
  • elevenlabs:{label} — additional keys for rotation

Files to change

File Change
src/auth/provider-auth.ts Add elevenlabs special-case to resolveEnvApiKey
src/auth/env-injection.ts Add elevenlabs to resolveProviderEnvVarName envMap
src/commands/onboard-auth.credentials.ts Add setElevenLabsApiKey() setter
src/commands/onboard-provider-auth-flags.ts Add --elevenlabs-api-key flag

Notes

  • Auth profile types use open provider: string — no type changes needed
  • normalizeProviderId("elevenlabs") returns "elevenlabs" directly — no normalization rule needed
  • listProfilesForProvider() works automatically for any provider string

Upstream compatibility

This change is designed to be submittable upstream to OpenClaw:

  • Additive only — no existing behavior changes
  • Follows established provider patterns (same as deepgram, openai, etc.)
  • ElevenLabs is already used by upstream OpenClaw's TTS module

Depends on

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions