Ask: questions about your circuit

Ask a model about the circuit on the canvas and the code that runs it, in the Ask tab beside Serial, on your own API key from the AI provider you pick.

What it costs and who sees it. Mokxi does not charge for Ask and does not pay for it either: it runs on an API key from your own account with an AI provider, and that provider bills your account for every question. You can use Anthropic, OpenAI, Google Gemini, OpenRouter, Mistral, or any service or local server that speaks OpenAI's API. Where your key is kept depends on whether you are signed in; see Where your key is kept.

Getting a key

Open the Ask tab (the Ask button in the serial monitor's header, or the Ask tab of the bottom sheet on a phone) and pick a provider at the top of the settings. The panel shows the steps for that provider. In short:

  • Anthropic: at console.anthropic.com, add credit under Billing, then Create key under API keys. Keys start with sk-ant-.
  • OpenAI: at platform.openai.com, add credit under Billing, then Create new secret key. Keys start with sk-.
  • Google Gemini: at aistudio.google.com, press Get API key. Keys start with AIza. The free tier has small per-minute and daily limits; turn on billing in AI Studio for more.
  • OpenRouter: at openrouter.ai, add credit, then Create key. Keys start with sk-or-. One OpenRouter account reaches hundreds of models from many companies, which makes it the easiest way to try models from a provider not listed here.
  • Mistral: at console.mistral.ai, choose a plan under Billing, then Create new key.

Paste the key and press Save to account (signed in) or Save key (signed out). Each provider keeps its own key, so you can switch between them in the settings without pasting again.

Test connection checks the key and the model without asking a question. For Anthropic and Gemini it also checks the model exists, and for OpenAI, OpenRouter and Mistral it looks the model up in the list of models the key can use; none of these costs anything.

Where your key is kept

Signed in, a key you save belongs to your Mokxi account. It is encrypted before it is stored, and it is never shown again, not even to you: the settings only say which providers have a key and its last four characters, with Replace and Remove. The key is never sent back to your browser. Each question goes to Mokxi's server, which adds the key, passes the question to the provider and streams the answer straight back; it does not keep or log the question, the answer or the key. The same key works on any computer you sign in on. Teachers never see a student's key. Closing your account deletes every key on it.

Signed out, a key stays in this browser only, one per provider, and questions go from this browser straight to the provider, so Mokxi never sees them. Remove key forgets it. Signing in keeps keys safely with your account instead.

If you saved a key in this browser and then sign in, Ask offers once to move it onto your account. Either way it is removed from the browser, since a signed-in account keeps keys on the account only.

Signing out forgets every key in this browser, so the next person on a shared or school computer cannot ask questions on your account.

Other services and models on your own computer

Pick OpenAI-compatible (custom base URL) for any service that speaks OpenAI's API, or a model running on your own computer. The Presets list fills in the address and a model for Groq, Together AI, DeepSeek, xAI, Ollama and LM Studio; for anything else, type the base URL (the part before /chat/completions, usually ending in /v1) and the model's name as that service spells it. A server on your own computer needs no key: leave the box empty.

Signed in, a key for a hosted service is saved to your account with its address, and that address has to be a public https:// one. A server on your own computer is different: Mokxi's server cannot reach it, so questions to it always go straight from your browser, with no key, and nothing about it is saved to your account.

A server on your computer has to be told to let web pages call it, or the browser blocks the request before it arrives (this is called CORS):

  • Ollama: quit it, then start it again with the environment variable OLLAMA_ORIGINS set to https://mokxi.com (or *). On a Mac with the Ollama app, run launchctl setenv OLLAMA_ORIGINS "https://mokxi.com" in Terminal and restart the app. Pull the model first, for example ollama pull qwen2.5-coder. The base URL is http://localhost:11434/v1.
  • LM Studio: in the Developer tab, start the server and turn on Enable CORS, and load a model. The base URL is http://localhost:1234/v1.

Plain http:// only works for a server on the same computer as the browser. A server anywhere else needs an https:// address, because a secure page is not allowed to call a plain one.

Choosing a model

Each provider has a short list in the settings, with its default first, and Another model… takes any model id the provider offers. The defaults are Claude Sonnet 5 for Anthropic, GPT-6 Sol for OpenAI, Gemini 3.8 Flash for Google, Auto for OpenRouter (it picks a model for each question) and Mistral Medium for Mistral. Bigger models answer hard bugs better and cost more per question; a small local model costs nothing but gets more wrong.

What is sent with a question

Each question carries your project as it is at that moment:

  • the parts on the canvas and their properties, and which pins are connected to which (worked out the same way the simulator works it out);
  • the code file open in the editor, with line numbers;
  • the last 60 lines of serial output from this run;
  • the compiler's errors and warnings from the last build;
  • while the simulation runs, the live readings of every part that reports one.

Each of those is capped, so a very large circuit or a chatty sketch cannot make one question expensive; when something is cut, the text sent says so. What is sent, under the question box, shows exactly the text that would go with a question asked now, and where it goes.

The same text goes to every provider. Ask only sends text and reads text back, so every provider can do everything Ask does.

A follow-up question also carries the last few questions and answers, so you can say "and what about the other LED?", but only the newest question carries the project. New chat starts over.

Using the code in an answer

Code in an answer has three buttons under it:

  • Copy puts it on the clipboard.
  • Insert at cursor puts it where the cursor is in the code editor, replacing any selection.
  • Replace file, only for a whole sketch (one with both setup() and loop()), replaces the open file after asking you first.

Nothing an answer says changes your project unless you press one of these. Insert and Replace are ordinary edits: Ctrl+Z (Cmd+Z on a Mac) in the editor takes them back. They do nothing on code that is locked or that you are only watching.

When it goes wrong

The message names the provider and says what to do. The common ones:

  • Did not accept that API key: the key was not copied whole, was deleted, or belongs to another provider (the settings notice a key from a different provider and say which). Paste it again or make a new one.
  • No credit left: add credit on the provider's billing page. For Gemini, a free key has used up its quota; wait for it to reset or turn on billing.
  • Model not available: the model's name is wrong or your key cannot use it. Pick another in the settings. For Ollama, pull the model first.
  • Rate limit: your account asked too much too quickly. Wait a minute.
  • Busy: the provider is overloaded. Try again in a moment.
  • A lot of questions in a row: Mokxi limits how fast one account can ask through its server. Wait a minute.
  • Could not reach: check your connection. Some school and office networks block AI providers. For a server on your computer, check it is running and that CORS is turned on (see above).

The model can be wrong. It sees the project as text, not the canvas, and it does not run your circuit; check what it says against the simulation.