> ## Documentation Index
> Fetch the complete documentation index at: https://docs.electronhub.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Regenerate API Key

> Generate a new API key for the authenticated user

<Warning>
  Immediately invalidates the current primary API key. Proxy keys are unaffected. The old key cannot be recovered.
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.electronhub.ai/v1/auth/key/regen \
    -H "Authorization: Bearer $ELECTRONHUB_API_KEY"
  ```

  ```python Python theme={null}
  import httpx

  client = httpx.Client()
  response = client.get(
      "https://api.electronhub.ai/v1/auth/key/regen",
      headers={
          "Authorization": f"Bearer {api_key}"
      }
  )

  result = response.json()
  new_api_key = result["key"]
  print(f"New API key: {new_api_key}")

  # Important: Update your applications with the new key
  print("Remember to update all applications with the new API key!")
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.electronhub.ai/v1/auth/key/regen', {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${process.env.ELECTRONHUB_API_KEY}`,
    },
  });

  const result = await response.json();
  const newApiKey = result.key;
  console.log(`New API key: ${newApiKey}`);

  // Important: Update your applications with the new key
  console.log('Remember to update all applications with the new API key!');
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "key": "ek-1234567890abcdef1234567890abcdef"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /auth/key/regen
openapi: 3.0.1
info:
  title: Electron Hub API
  description: >-
    Unified API platform integrating 200+ AI models for chat, image generation,
    speech-to-text, embeddings, and more.
  version: 1.0.0
  contact:
    name: Electron Hub Support
    email: support@electronhub.ai
    url: https://discord.com/invite/electronhub
  license:
    name: MIT
servers:
  - url: https://api.electronhub.ai/v1
    description: Production API v1
security:
  - bearerAuth: []
paths:
  /auth/key/regen:
    get:
      summary: Regenerate API Key
      description: Generate a new API key for the authenticated user
      operationId: regenerateApiKey
      responses:
        '200':
          description: New API key generated
          content:
            application/json:
              schema:
                type: object
                properties:
                  key:
                    type: string
                    description: The new API key
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your API key (starts with 'ek-')

````