# Choosing an AI provider and adding your key

Mayhap's AI features ask a provider you choose, with your own key, or a model running on this computer with no key at all. You set the provider, the model and the key once in Settings, and Nudge and AI alternatives both use them.

## Opening the AI settings

To get started, press `Ctrl+, / ⌘,` and choose *AI* in the list of sections on the left. You may also run *AI settings* from the command palette. Wherever Mayhap needs a key it doesn't have yet, it offers *Add a key…*, which opens the same place.

The section has three parts: *Provider*, *Model* and *API key*. A line at its top says which provider is in use, with which model, and whether its key is saved. For example: *In use: Anthropic · claude-opus-5-5 · key saved*.

![Settings › AI with Anthropic in use: its address, the model claude-opus-5-5 and a key saved](https://mayhap.app/build/assets/settings-ai-NvmcUvb2.webp)

Nothing you change here applies until you choose *Save*, which also closes Settings. *Close* leaves everything as it was.

## Bringing your own key

Mayhap works with the keys these providers give out. Pick yours from the *Provider* menu:

- Anthropic
- OpenAI
- Google Gemini
- xAI
- DeepSeek
- Qwen
- Mistral
- OpenRouter

Next, make a key on the provider's own site and paste it into the *API key* field. The field shows only dots, and a paste always replaces whatever it held, so a stray space or line break never ends up inside the key. Choose *Save*, and the key is ready.

Each provider keeps its own key. If you switch from Anthropic to Mistral and back, your Anthropic key is still there, and the field says *A key is saved. Paste another to replace it.* To forget a provider's key, choose *Remove*.

Under the menu, Mayhap shows the address it asks each provider at, for reference. Qwen is asked at Alibaba Cloud's international endpoint, so a Qwen key should be made in that region.

## Signing in with OpenRouter

If you'd rather not copy a key by hand, you may sign in with OpenRouter instead. Choose *OpenRouter* in the *Provider* menu, then *Sign in with OpenRouter*. Your browser opens on OpenRouter's page, where you approve Mayhap.

Once you do, the key comes back to Mayhap by itself and is kept exactly as a pasted key would be. OpenRouter becomes the provider in use, and Settings says *Signed in. OpenRouter is in use now, and your key is saved.*

While Mayhap waits, Settings says *Waiting for OpenRouter in your browser…* with *Cancel* and *Copy address*. If no browser opened, copy the address shown under *No browser opened? Open this address:* into one. The sign-in ends after five minutes without an answer. To sign out, choose *Remove*.

## Ollama and LM Studio on this computer

Sometimes you may wish to keep everything on your own computer. To do so, run a model in Ollama or LM Studio, then choose *Ollama* or *LM Studio* in the *Provider* menu. They take no key, so there is no key field to fill in.

Mayhap asks each local server for its models every time you open the list, so a model you've just downloaded shows up straight away. If the list is empty, it says *On this computer · Ollama isn't running? Start it, then reopen this list*. With no model chosen, Mayhap uses the first one the server lists.

A model on your own computer may take a while to answer, so Mayhap waits up to five minutes for it. Providers on the internet get two.

## Other (OpenAI-compatible)

Any other service that speaks OpenAI's chat API works too. Choose *Other (OpenAI-compatible)*, last in the *Provider* menu, and type its address in *Base URL*. If the service takes a key, paste it into *API key*; if it doesn't, leave the field empty.

Mayhap names such a service by its address, such as *llm.example.com*, in the line at the top of the section and wherever it says what went wrong. A server at *localhost* is treated like Ollama and LM Studio: it gets the same five minutes to answer.

## Picking a model

The *Model* menu lists the provider's own models, asked for with your key. Each shows its name and a short second label, such as its display name, or its size on disk for Ollama. At the foot, a line says where the list came from, for example *From Anthropic, with your key*.

If the model you want isn't listed, choose *Type a name instead* and type its name. Without a key, offline, or when the provider can't be reached, *Model* is a field for a name from the start.

By default, Anthropic and OpenAI use a model of their own. Every other provider needs a model chosen before anything is sent; until then, Mayhap says *Pick a model for Mistral in Settings.*, naming your provider.

## Where your keys are kept

Mayhap keeps your keys in your system's keychain and nowhere else. A key is never written to *settings.json*, and never to Mayhap's log.

Your requests go straight from Mayhap to the provider you chose. They trust the same certificates your system trusts, so they work behind a company proxy or an antivirus that reads secure connections. Mayhap follows the proxy set in *HTTPS_PROXY* and *NO_PROXY*, and on Windows the one in the system's settings. A server on this computer is never asked through a proxy.

## AI alternatives

Besides Nudge, AI can suggest new versions of a word, a sentence or a paragraph. To ask for them, right-click the text and choose *AI alternatives for selection*, or press `Ctrl+Shift+I / ⇧⌘I`. When you right-click a single word, the item names it, such as *AI alternatives for “quiet”*.

Mayhap opens the *Alternatives* panel on the text and asks for three new versions. They join the versions you already have, each marked with a small bot, and the version on the page stays as it is. Of course, the panel itself can ask too: type ?? on its empty line and press `Return`.

![The Alternatives panel on a sentence, with three versions from AI under the two of your own, each with a small bot](https://mayhap.app/build/assets/ai-alt-DSNkdszu.webp)

Pressing `Esc` or closing the panel lets the answer go. If you change the text while AI is working on it, the answer is dropped. You can learn more about versions in [Versions of a word, a sentence or a paragraph](https://mayhap.app/guide/versions), and about Nudge in [Nudge](https://mayhap.app/guide/nudge).

## When something goes wrong

When a request fails, Mayhap says so in one line, in the place you asked, and says what to do next. Your document stays as it was. These are the lines you may see, with your provider's name in them:

*Add your Anthropic API key in Settings to use AI suggestions.*
: No key is saved for the provider in use.

*Anthropic didn't accept the API key. Check it in Settings.*
: The key is wrong, or the provider has withdrawn it.

*Anthropic has no credit left for this. Add some there, then try again.*
: Your account with the provider needs topping up.

*Anthropic doesn't know this model. Check the model in Settings.*
: The model's name is misspelt, or the provider no longer offers it.

*Anthropic is limiting requests right now. Try again in a minute.*
: You've sent more requests than your plan allows for the moment.

*Couldn't reach Anthropic. Check your connection and try again.*
: Mayhap couldn't connect to the provider.

*Ollama isn't running? Start it, then try again.*
: The server on this computer isn't answering.

*Anthropic took too long to answer. Try again in a moment.*
: The answer didn't come in time.

Sometimes a provider turns a request down for its own reason, such as a text too long for the model. Then the line ends with the provider's explanation: *Mistral couldn't handle the request (error 400): …*. Mayhap only shows this explanation; it never writes it to the log, since it may quote your text.

## Keys

| Command | Linux, Windows | macOS |
| --- | --- | --- |
| Settings | Ctrl+, | ⌘, |
| AI alternatives for selection | Ctrl+Shift+I | ⇧⌘I |
| Empty the key field | Ctrl+Backspace | ⌘Backspace |
| Close the settings | Esc | Esc |
