Skip to content

AI API Configuration

GitHub Copilot edited this page May 12, 2026 · 2 revisions

AI API Configuration

mdedit.io includes an AI assistant for editing and document work. You bring your own API key — no key is bundled with the app.

Supported Providers

Provider Env Variable Free Tier Default Model
Groq (recommended) GROQ_API_KEY Yes — console.groq.com llama-3.3-70b-versatile
Google Gemini GEMINI_API_KEY Yes — ai.google.dev gemini-2.5-flash
OpenAI OPENAI_API_KEY No gpt-4.1
Anthropic Claude ANTHROPIC_API_KEY No claude-3-7-sonnet-latest

Groq is the recommended starting point — it has a free developer tier and fast inference.

Setup

Add the key to your .env file (based on .env.example):

# Groq (recommended)
GROQ_API_KEY=your_groq_api_key_here

# Optional: Google Gemini fallback
GEMINI_API_KEY=your_gemini_api_key_here

# Optional: override which provider and model to use by default
DEFAULT_AI_PROVIDER=groq
DEFAULT_AI_MODEL=llama-3.3-70b-versatile

Restart the container after changing .env:

docker compose up -d --force-recreate

Provider Priority

If no DEFAULT_AI_PROVIDER is set, the app picks the first provider that has a valid API key, in this order:

  1. Groq
  2. Gemini
  3. OpenAI
  4. Claude

Using AI in the Editor

Open the AI panel with Alt+Space (primary) or Ctrl+Space (fallback on Linux where Alt+Space conflicts with the window manager). Type your request in plain language — the assistant reads your current document and applies changes directly.

Available Actions

Action What happens
ADVICE The AI explains or answers — no document change
REPLACE Replaces the entire document with the AI's version
APPEND Appends text at the end of the document
PREPEND Prepends text at the start
INSERT Inserts text at the cursor position

API Endpoint

For programmatic use or integration:

POST /api/chat/complete

Request

{
  "prompt": "The user request",
  "document": "The current Markdown document (optional)",
  "history": []
}

Response

{
  "message": "Response / explanation to the user",
  "markdown": "Updated Markdown — or null for ADVICE",
  "action": "REPLACE | INSERT | APPEND | PREPEND | ADVICE"
}

Example

curl -X POST http://localhost:3210/api/chat/complete \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Write an introduction about AI", "document": ""}'

See Also

Clone this wiki locally