Skip to content

API Key Configuration

RenzMc edited this page Sep 6, 2025 · 1 revision

πŸ” API Key Configuration

This guide explains how to configure API keys for different AI providers supported by the Acode AI CLI Assistant Plugin.

πŸ›‘οΈ Security Overview

The plugin uses advanced encryption to protect your API keys:

  • AES-GCM Encryption: Provides both confidentiality and integrity
  • PBKDF2 Key Derivation: Processes your passphrase with 100,000 iterations
  • Random IVs: Each encryption uses a unique initialization vector
  • Local Storage: All keys are stored locally on your device

πŸ€– Provider Configuration

OpenAI

  1. Obtain an API key from OpenAI Platform
  2. In the plugin, select "OpenAI" as your provider
  3. Enter your API key when prompted
  4. Select from available models (GPT-4, GPT-3.5 Turbo, etc.)

Google Gemini

  1. Get an API key from Google AI Studio
  2. Select "Google" as your provider in the plugin
  3. Enter your Gemini API key
  4. Choose from available Gemini models

Ollama (Local)

  1. Install Ollama on your device:
    curl https://ollama.ai/install.sh | sh
  2. Pull a model (e.g., CodeLlama):
    ollama pull codellama
  3. Select "Ollama" as your provider
  4. Use the default endpoint or configure a custom one

Groq

  1. Sign up at Groq Cloud
  2. Create an API key in your account settings
  3. Select "Groq" as your provider in the plugin
  4. Enter your API key and choose a model

Anthropic Claude

  1. Sign up at Anthropic Console
  2. Generate an API key
  3. Select "Anthropic" as your provider
  4. Enter your API key and select a Claude model

OpenRouter

  1. Sign up at OpenRouter
  2. Generate an API key
  3. Select "OpenRouter" as your provider
  4. Enter your API key and choose from available models

Qwen

  1. Obtain an API key from Alibaba Cloud
  2. Select "Qwen" as your provider
  3. Enter your API key
  4. Choose from Qwen models (Turbo, Plus, Max)

OpenAI-Like

  1. Prepare your API endpoint URL
  2. Obtain an API key from your service provider
  3. Select "OpenAI-Like" as your provider
  4. Enter:
    • API Key
    • API Base URL
    • Model name

πŸ”§ Managing API Keys

Adding New API Keys

  1. Open the AI assistant
  2. Click the menu icon (three dots) in the header
  3. Select "Provider" to change provider
  4. Choose your new provider
  5. Enter the API key when prompted

Updating Existing API Keys

  1. Open the AI assistant
  2. Click the menu icon in the header
  3. Select "Provider" to change provider
  4. Choose the same provider you're currently using
  5. Enter your new API key when prompted

Viewing Current Configuration

  1. Open the AI assistant
  2. Click the menu icon in the header
  3. The current provider and model will be displayed

Removing API Keys

API keys are stored in Acode's local storage and can be removed by:

  1. Changing to a different provider
  2. Or clearing Acode's app data (which will remove all plugin data)

⚑ Real-Time API Status

The plugin provides visual feedback on API connectivity:

  • Green Indicator: API is connected and functioning
  • Yellow Indicator: API is processing a request
  • Red Indicator: API connection error or rate limit exceeded

πŸ“ˆ API Usage Monitoring

The plugin tracks your token usage:

  • Total Tokens: All tokens used since installation
  • Today's Tokens: Tokens used in the current day
  • Session Tokens: Tokens used in the current session

You can view this information in the plugin header.

πŸ”’ Encryption Details

How API Keys Are Protected

  1. When you enter an API key, it's encrypted with AES-GCM
  2. Your passphrase is used with PBKDF2 to derive the encryption key
  3. A random initialization vector is generated for each encryption
  4. The encrypted key and IV are stored in local storage

Passphrase Management

  • Your passphrase is never stored
  • You must enter it each time you want to change API keys
  • If you forget your passphrase, you'll need to reconfigure all API keys

πŸ”„ Switching Between Providers

You can easily switch between AI providers:

  1. Open the AI assistant
  2. Click the menu icon in the header
  3. Select "Provider"
  4. Choose from the available providers
  5. Enter API key if required for the new provider
  6. Select a model for the new provider

πŸ› Troubleshooting API Key Issues

Common API Key Problems

Invalid API Key

  • Error message: "Invalid API key"
  • Solution: Verify your API key is correct and active
  • Check that you're using the right key for the selected provider

Rate Limit Exceeded

  • Error message: "Rate limit exceeded"
  • Solution: Wait before making more requests
  • Consider upgrading your API plan if available

Connection Failed

  • Error message: "Connection failed"
  • Solution:
    1. Check your internet connection
    2. Verify the API endpoint is accessible
    3. Check that your API key has the required permissions

Model Not Available

  • Error message: "Model not available"
  • Solution:
    1. Check that the model name is correct
    2. Verify the model is available in your account
    3. Try selecting a different model

API Key Verification

To verify your API key is working:

  1. Open the AI assistant
  2. Send a simple query
  3. Check for proper response
  4. If errors occur, verify your key on the provider's platform

πŸ“ž Getting Help

If you encounter issues with API key configuration:

  1. Check the Common Issues documentation
  2. Visit our GitHub Issues page
  3. Join our Discussions community for support

Clone this wiki locally