OpenAI

~2 min read

OpenAI

GPT-4 / GPT-5 / o-series. Useful when you want a different reasoning style from Claude or when a model has capabilities the Anthropic line doesn’t.

Setting the key

OpenAI is one of the AI providers behind Lettuce’s enhancement features (publish metadata, semantic search embeddings, the answer / related / lint commands). Configure it either way:

The key from the GUI is stored in the macOS Keychain (service com.lettuce.app, account openai-api-key); the env var, if set, takes precedence. The raw value never touches disk in your vault.

To make OpenAI the active provider, select it in Settings → AI providers, or set LETTUCE_LLM_PROVIDER=openai for a CLI run.

Models

The default OpenAI model is gpt-4o-mini. Override it in Settings → AI providers (saved per provider), or for a single CLI run with LETTUCE_ENHANCE_MODEL:

LETTUCE_LLM_PROVIDER=openai LETTUCE_ENHANCE_MODEL=gpt-4o lettuce answer ~/vault "..."

Lettuce passes the model ID through verbatim. Examples:

Model Notes
gpt-4o-mini default
gpt-4o multimodal
o3-mini reasoning-optimised
gpt-4-turbo legacy

Use whatever your API key has access to.

Custom or Azure endpoints

Lettuce talks to https://api.openai.com/v1 by default. To point at Azure OpenAI or any other OpenAI-compatible host, use the OpenAI-compatible (custom) provider instead and set its base URL with LETTUCE_LLM_BASE_URL (or in Settings → AI providers). See AI providers/04 OpenAI-compatible and local models.

Connecting an MCP agent

Lettuce’s built-in AI features call the OpenAI API directly with the configured key. Running an interactive agent against your vault is separate: start the MCP server with lettuce serve and connect your agent client to it over the configured token. The agent sees every MCP tool its token has scope for (see Agent reference/03 Authentication), and picks up work via pending_directives — a > [!ai] <prompt> directive spliced into a note by a trigger or schedule.