Add an OpenAI API key to a desktop AI agent safely.
Create a project-scoped OpenAI API key, store it securely in MultiAgentOS, test it with a small request, and route between hosted OpenAI models and local models on demand. Five steps, under fifteen minutes, plus a checklist for safe key handling.
Route each task through the right model or tool surface.
MultiAgentOS supports API keys, local servers, CLI pipes, OAuth, terminal templates, and local AI/GGUF workflows.
- 1 Choose provider
- 2 Store secret
- 3 Test model
- 4 Enable tools
Why use an OpenAI API key with MultiAgentOS?
Local models are excellent for private work, repetitive tasks, and offline use. But for the hardest reasoning, the freshest multimodal capabilities, or specific OpenAI workflows, a hosted model is still the right tool. MultiAgentOS lets you keep an OpenAI key beside your local model so you can route each task to the right brain.
1. Create a project API key
Sign in to platform.openai.com and create the key in the project you want MultiAgentOS to use. Give it a descriptive name like multiagentos-desktop so you can recognise it in the keys list later.
Project keys scope your spend, your model access, and your usage limits. They are also easier to rotate without breaking other integrations.
2. Store the key as a secret
Treat the key like a password. Three safe places to put it:
- MultiAgentOS secure settings. Open Settings, choose the API Key connection, paste the key. It is stored in your OS credential store.
- An environment variable.
OPENAI_API_KEYis the standard. MultiAgentOS will pick it up automatically if no key is set in settings. - A password manager or secret manager. Useful for teams or for syncing across machines.
Never:
- Paste the key into client-side JavaScript or any code that ships to a browser.
- Commit the key to a public or shared repository.
- Include the key in a screenshot, support ticket, bug report, or Loom video.
- Send the key in plain chat to anyone, including ChatGPT.
3. Test a small request
Before pointing the agent at production work, send a short, low-risk prompt. A single sentence asking for a single sentence back is enough to confirm:
- The key is accepted.
- The model name you chose is available on this account.
- Billing and usage limits are healthy.
- The agent renders the response cleanly in MultiAgentOS.
If you see a 401 error, the key is wrong or revoked. A 429 error means rate limits or billing — check the dashboard.
4. Route intentionally between OpenAI and local models
The most common mistake is sending every prompt to OpenAI by default. That bills you for tasks a local model could handle, and sends private data to a third party unnecessarily.
A useful default split:
- Local model (Ollama, LM Studio, GGUF). Daily chat, code review, file Q&A on private data, repetitive transforms, background subagent work.
- OpenAI hosted model. Hard planning steps, multimodal reasoning over images, complex tool-use chains, anything that has stalled a local model.
MultiAgentOS lets you switch the active connection per conversation, and supervised subagents can be configured with their own model so you do not pay frontier-model rates for janitorial work.
5. Rotate keys when needed
If a key is ever exposed — in a screenshot, a shared log, a leaked file — rotate immediately:
- Revoke the exposed key in the OpenAI dashboard.
- Create a fresh key with the same name suffixed with a date.
- Update MultiAgentOS settings or the
OPENAI_API_KEYenvironment variable. - Audit the project usage logs for unauthorised activity.
Do not try to "fix" an exposed key by deleting local history. The key is already public; only revocation actually closes the hole.
Safe-handling checklist
- One project key per machine, named for that machine.
- Monthly usage limit set in the dashboard.
- Key stored in OS credential store or env var — never in code.
- Rotation date in your calendar (90 days is a reasonable default).
- Subagent turn budgets set so a loop cannot blow your budget overnight.
Related guides
- Set up Ollama for local AI agents — pair OpenAI with a local model for routing.
- Connect MCP tools to desktop AI agents — least-privilege tool wiring.
- Local LLMs vs cloud APIs — the 5-year cost reality — when each makes economic sense.
- Desktop AI agent use case — what an agent on Mac/Windows actually does.
FAQ
Does MultiAgentOS store my OpenAI key in the cloud?
No. Keys are stored locally in your OS credential store, exactly like any other native desktop app. MultiAgentOS does not have a sync service.
Can I use Azure OpenAI instead?
Yes. Use the OAuth connection type in MultiAgentOS settings to connect Azure OpenAI, Google Vertex AI, HuggingFace, or other custom providers.
What is the cheapest way to run a desktop agent?
Local models for everything you can, OpenAI for the few requests that need it. Most users land at a small monthly OpenAI bill plus zero variable cost for the rest.