OpenAI

~3 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
gpt-6-luna OpenAI’s replacement for the 4o models, cheapest GPT-6
gpt-6.1-terra faster and stronger than Luna

OpenAI shuts down gpt-4o and gpt-4o-mini on 14 January 2027. You don’t have to act: when OpenAI reports that the model you chose no longer exists, Lettuce retries that request once with gpt-6-luna. Choose gpt-6-luna yourself to switch now. GPT-6 Sol and Astra are not offered, because they can’t switch reasoning off, which OpenAI’s Chat Completions API needs for the structured answers Lettuce asks for. o3-mini and gpt-4-turbo were shut down on 23 October 2026: a saved o3-mini or gpt-4-turbo is read as gpt-4o-mini.

The same retry applies to Anthropic and Gemini: a request to a retired model moves once to that provider’s current default.

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.