Documentation

Complete reference for Flask Code features and APIs

Overview

Flask Code is an AI-powered coding assistant that transforms multiple AI providers into a unified agent interface. It supports both graphical (Tkinter) and command-line interfaces, allowing developers to choose their preferred workflow.

Note: Flask Code is not an AI itself; it transforms an AI into an AI agent with extended capabilities and persistent state management.

Features

Multi-Provider Support

Seamlessly switch between Gemini, Groq, and OpenRouter without restarting. Each provider can have its own API key stored securely.

Dual Interface

Choose between a polished Tkinter desktop application or a powerful terminal-based chat interface based on your workflow needs.

User Management

Register multiple user accounts with PIN-based authentication. Each user's settings and preferences persist across sessions.

API Key Management

Store up to three API keys in dedicated slots and switch between them on-the-fly. Perfect for managing multiple accounts or providers.

Rich Output

Chat responses render with markdown formatting, code syntax highlighting, and code blocks for better readability.

Command System

Use built-in commands to register accounts, switch models, manage keys, and control the application without leaving chat.

Architecture

Core Components
Component Responsibility
main.py Terminal chat entry point
user-interface.py Tkinter GUI entry point
engine.py Core chat processing and provider routing
auth.py User registration and PIN authentication
apikey_settings.py Per-user API key and provider preference storage
gemini_client.py Gemini API integration
groq_client.py Groq API integration
openrouter_client.py OpenRouter API integration
markdown_highlighter.py Markdown rendering and syntax highlighting

API Key Management

Storing Keys

API keys are stored in a YAML-formatted .apikeys file with three slots:

key_1: YOUR_GEMINI_API_KEY
key_2: YOUR_GROQ_API_KEY
key_3: YOUR_OPENROUTER_API_KEY
Security: Never commit .apikeys to version control. It is already in .gitignore.
Switching Keys

Use the /apikey command to switch between stored keys:

/apikey 1
/apikey 2
/apikey 3
Environment Variable Fallback

Flask Code checks for the GEMINI_API_KEY environment variable if no keys are found in .apikeys:

set GEMINI_API_KEY=YOUR_KEY
python main.py

Supported Providers

Google Gemini

Default provider

Google's advanced AI model with multimodal capabilities.

Command: /model gemini

Setup: Get API key at Google AI Studio

Groq

Fast inference

Optimized for speed with various open-source models.

Command: /model groq

Setup: Get API key at Groq Console

OpenRouter

Provider aggregator

Access dozens of models through one API.

Command: /model openrouter

Setup: Get API key at OpenRouter

Command Reference

Command Syntax Description
/register-as /register-as Opens a popup dialog to create a new user account
/login-as /login-as <username> <password> Log in as an existing user
/apikey /apikey <1|2|3> Switch to the specified API key slot
/model /model <provider> Switch provider (gemini, groq, openrouter)
/help /help Display all available commands
/logout /logout Log out of the current account
/exit /exit Close the application

Troubleshooting

Solution: Ensure Tkinter is installed:

  • Windows: Reinstall Python and check "tcl/tk and IDLE" during installation
  • Linux: Run sudo apt-get install python3-tk
  • macOS: Tkinter is included with Python

Verify installation with: python -m tkinter

Solution:

  • Verify .apikeys file exists in the Flask Code directory
  • Check that the file is in valid YAML format with keys: key_1, key_2, key_3
  • Ensure API keys are not empty or invalid
  • Try setting the GEMINI_API_KEY environment variable as a fallback

Solution:

  • Verify your API keys are active and have remaining quota
  • Check your internet connection
  • Confirm the provider's API is not experiencing downtime
  • Try switching to a different provider

Solution: Reinstall dependencies:

python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Configuration

Configuration Files
.apikeys

Secret file containing API keys (git-ignored)

Format: YAML with keys key_1, key_2, key_3

⚠️ Never commit to Git

.apikeys_example

Template for new installations

Copy this to .apikeys and fill in your keys

✓ Safe to commit

apikey_settings.py

Per-user settings storage

Stores preferred provider and API key slot for each user

Created automatically after first login

requirements.txt

Python dependencies

Install with: pip install -r requirements.txt

Main: PyYAML 6.0+