Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

15.6 KB
Raw Blame
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["3263"],{67175(e,i,r){r.r(i),r.d(i,{metadata:()=>n,default:()=>a,frontMatter:()=>l,contentTitle:()=>t,toc:()=>c,assets:()=>o});var n=JSON.parse('{"id":"reference/provider-fallback","title":"Provider Fallback","description":"Configure multiple LLM providers. Mercury tries them in order and falls back automatically. When a provider fails, Mercury tries the next one and remembers the last successful provider.","source":"@site/docs/reference/provider-fallback.mdx","sourceDirName":"reference","slug":"/reference/provider-fallback","permalink":"/docs/reference/provider-fallback","draft":false,"unlisted":false,"editUrl":"https://github.com/cosmicstack-labs/mercury-agent/tree/main/website/docs/reference/provider-fallback.mdx","tags":[],"version":"current","frontMatter":{"id":"provider-fallback","title":"Provider Fallback"},"sidebar":"docsSidebar","previous":{"title":"Second Brain","permalink":"/docs/reference/second-brain"},"next":{"title":"Scheduling","permalink":"/docs/reference/scheduling"}}'),s=r(74848),d=r(28453);let l={id:"provider-fallback",title:"Provider Fallback"},t,o={},c=[{value:"Session Model Switching",id:"session-model-switching",level:2},{value:"Supported Providers",id:"supported-providers",level:2},{value:"API Key Providers",id:"api-key-providers",level:3},{value:"OAuth Providers (No API Key Needed)",id:"oauth-providers-no-api-key-needed",level:3},{value:"ChatGPT Web (ChatGPT Plus/Pro)",id:"chatgpt-web-chatgpt-pluspro",level:2},{value:"Setup",id:"setup",level:3},{value:"How It Works",id:"how-it-works",level:3},{value:"Available Models",id:"available-models",level:3},{value:"Environment Variables",id:"environment-variables",level:3},{value:"GitHub Copilot",id:"github-copilot",level:2},{value:"Setup",id:"setup-1",level:3},{value:"How It Works",id:"how-it-works-1",level:3},{value:"Available Models",id:"available-models-1",level:3},{value:"Environment Variables",id:"environment-variables-1",level:3},{value:"Configuring Providers",id:"configuring-providers",level:2}];function h(e){let i={admonition:"admonition",code:"code",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.p,{children:"Configure multiple LLM providers. Mercury tries them in order and falls back automatically. When a provider fails, Mercury tries the next one and remembers the last successful provider."}),"\n",(0,s.jsx)(i.h2,{id:"session-model-switching",children:"Session Model Switching"}),"\n",(0,s.jsx)(i.p,{children:"You can switch the active provider/model at runtime without restarting Mercury:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"/models"})," \u2014 shows configured providers and current active model"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"/models use <provider>"})," \u2014 switches the active session model"]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"/models doctor"})," \u2014 points to setup flow for adding/configuring providers"]}),"\n"]}),"\n",(0,s.jsxs)(i.p,{children:["This is a session-level switch for the running process. Use ",(0,s.jsx)(i.code,{children:"mercury doctor"})," to change persisted defaults."]}),"\n",(0,s.jsx)(i.h2,{id:"supported-providers",children:"Supported Providers"}),"\n",(0,s.jsx)(i.h3,{id:"api-key-providers",children:"API Key Providers"}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Provider"}),(0,s.jsx)(i.th,{children:"Default Model"}),(0,s.jsx)(i.th,{children:"API Key"}),(0,s.jsx)(i.th,{children:"Configuration"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"DeepSeek"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"deepseek-chat"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"DEEPSEEK_API_KEY"})}),(0,s.jsx)(i.td,{children:"Default provider, cost-effective"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"OpenAI"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"gpt-4o-mini"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"OPENAI_API_KEY"})}),(0,s.jsx)(i.td,{children:"GPT-4o-mini, GPT-4o, o3, etc."})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"Anthropic"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"claude-sonnet-4-20250514"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"ANTHROPIC_API_KEY"})}),(0,s.jsx)(i.td,{children:"Claude Sonnet, Haiku, Opus"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"Grok (xAI)"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"grok-4"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"GROK_API_KEY"})}),(0,s.jsx)(i.td,{children:"OpenAI-compatible endpoint"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"Ollama Cloud"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"gpt-oss:120b"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"OLLAMA_CLOUD_API_KEY"})}),(0,s.jsx)(i.td,{children:"Remote Ollama models via API"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"Ollama Local"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"gpt-oss:20b"})}),(0,s.jsx)(i.td,{children:"No key needed"}),(0,s.jsx)(i.td,{children:"Local Ollama instance (127.0.0.1:11434)"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"Atomic Chat"})}),(0,s.jsx)(i.td,{children:"Configurable"}),(0,s.jsx)(i.td,{children:"No key needed"}),(0,s.jsx)(i.td,{children:"Local Atomic Chat OpenAI API (127.0.0.1:1337/v1)"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"OpenAI Compatible"})}),(0,s.jsx)(i.td,{children:"Configurable"}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"OPENAI_COMPAT_API_KEY"})}),(0,s.jsx)(i.td,{children:"Any OpenAI-compatible server"})]})]})]}),"\n",(0,s.jsx)(i.h3,{id:"oauth-providers-no-api-key-needed",children:"OAuth Providers (No API Key Needed)"}),"\n",(0,s.jsx)(i.p,{children:"These providers authenticate through your browser using OAuth device flow \u2014 no API key required."}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Provider"}),(0,s.jsx)(i.th,{children:"Default Model"}),(0,s.jsx)(i.th,{children:"Subscription Required"}),(0,s.jsx)(i.th,{children:"Configuration"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"ChatGPT Web"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"gpt-5.4-mini"})}),(0,s.jsx)(i.td,{children:"ChatGPT Plus or Pro"}),(0,s.jsx)(i.td,{children:"Uses your ChatGPT subscription"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.strong,{children:"GitHub Copilot"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"gpt-4o"})}),(0,s.jsx)(i.td,{children:"GitHub Copilot"}),(0,s.jsx)(i.td,{children:"Uses your Copilot subscription"})]})]})]}),"\n",(0,s.jsx)(i.h2,{id:"chatgpt-web-chatgpt-pluspro",children:"ChatGPT Web (ChatGPT Plus/Pro)"}),"\n",(0,s.jsx)(i.p,{children:"Use your existing ChatGPT Plus or Pro subscription as a Mercury provider. No API key or separate billing \u2014 it runs through the same backend as chatgpt.com."}),"\n",(0,s.jsx)(i.h3,{id:"setup",children:"Setup"}),"\n",(0,s.jsxs)(i.ol,{children:["\n",(0,s.jsxs)(i.li,{children:["Run ",(0,s.jsx)(i.code,{children:"mercury doctor"})," (or first-time ",(0,s.jsx)(i.code,{children:"mercury"})," setup)"]}),"\n",(0,s.jsxs)(i.li,{children:["Select ",(0,s.jsx)(i.strong,{children:"OpenAI"})," from the provider list"]}),"\n",(0,s.jsxs)(i.li,{children:["Choose ",(0,s.jsx)(i.strong,{children:"ChatGPT Plus/Pro (OAuth \u2014 use your subscription)"})]}),"\n",(0,s.jsx)(i.li,{children:"A browser window opens \u2014 sign in with your OpenAI account and enter the device code shown in the terminal"}),"\n",(0,s.jsx)(i.li,{children:"Mercury fetches available models from your account and lets you pick a default"}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"how-it-works",children:"How It Works"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Authenticates via OpenAI's device flow OAuth (same flow used by the Codex CLI)"}),"\n",(0,s.jsxs)(i.li,{children:["Uses the ChatGPT Responses API at ",(0,s.jsx)(i.code,{children:"chatgpt.com/backend-api/codex"})]}),"\n",(0,s.jsxs)(i.li,{children:["Session tokens are stored locally at ",(0,s.jsx)(i.code,{children:"~/.mercury/chatgpt-session.json"})]}),"\n",(0,s.jsx)(i.li,{children:"Access tokens auto-refresh when they expire \u2014 no manual re-authentication needed"}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"available-models",children:"Available Models"}),"\n",(0,s.jsx)(i.p,{children:"Models are fetched from your account. Typical models available on the codex endpoint include:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"gpt-5.5"}),", ",(0,s.jsx)(i.code,{children:"gpt-5.4"}),", ",(0,s.jsx)(i.code,{children:"gpt-5.4-mini"}),", ",(0,s.jsx)(i.code,{children:"gpt-5.3-codex"}),", ",(0,s.jsx)(i.code,{children:"gpt-5.2"})]}),"\n"]}),"\n",(0,s.jsx)(i.admonition,{title:"Not all ChatGPT models are supported",type:"warning",children:(0,s.jsxs)(i.p,{children:["Only models available on the codex/responses endpoint work with this provider. Some models like ",(0,s.jsx)(i.code,{children:"gpt-4o"}),", ",(0,s.jsx)(i.code,{children:"o3"}),", and ",(0,s.jsx)(i.code,{children:"o4-mini"})," are not available through this endpoint."]})}),"\n",(0,s.jsx)(i.h3,{id:"environment-variables",children:"Environment Variables"}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Variable"}),(0,s.jsx)(i.th,{children:"Default"}),(0,s.jsx)(i.th,{children:"Description"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"CHATGPT_WEB_ENABLED"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"false"})}),(0,s.jsx)(i.td,{children:"Enable the ChatGPT Web provider"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"CHATGPT_WEB_MODEL"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"gpt-5.4-mini"})}),(0,s.jsx)(i.td,{children:"Default model to use"})]})]})]}),"\n",(0,s.jsx)(i.h2,{id:"github-copilot",children:"GitHub Copilot"}),"\n",(0,s.jsx)(i.p,{children:"Use your GitHub Copilot subscription as a Mercury provider. Authenticates through GitHub OAuth and accesses models through the Copilot API."}),"\n",(0,s.jsx)(i.h3,{id:"setup-1",children:"Setup"}),"\n",(0,s.jsxs)(i.ol,{children:["\n",(0,s.jsxs)(i.li,{children:["Run ",(0,s.jsx)(i.code,{children:"mercury doctor"})," (or first-time ",(0,s.jsx)(i.code,{children:"mercury"})," setup)"]}),"\n",(0,s.jsxs)(i.li,{children:["Select ",(0,s.jsx)(i.strong,{children:"GitHub Copilot"})," from the provider list"]}),"\n",(0,s.jsx)(i.li,{children:"A browser window opens \u2014 sign in with your GitHub account and enter the device code shown in the terminal"}),"\n",(0,s.jsx)(i.li,{children:"Mercury fetches available models from the Copilot API and lets you pick a default"}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"how-it-works-1",children:"How It Works"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:"Authenticates via GitHub's device flow OAuth"}),"\n",(0,s.jsx)(i.li,{children:"Exchanges the GitHub token for a short-lived Copilot API token (auto-refreshed every ~30 minutes)"}),"\n",(0,s.jsx)(i.li,{children:"Uses the Copilot API endpoint with OpenAI-compatible requests"}),"\n",(0,s.jsxs)(i.li,{children:["Session stored locally at ",(0,s.jsx)(i.code,{children:"~/.mercury/github-session.json"})]}),"\n",(0,s.jsx)(i.li,{children:"GitHub OAuth tokens don't expire \u2014 they remain valid until revoked on github.com"}),"\n"]}),"\n",(0,s.jsx)(i.h3,{id:"available-models-1",children:"Available Models"}),"\n",(0,s.jsx)(i.p,{children:"Models are fetched dynamically from the Copilot API. Typical models include:"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"claude-sonnet-4.6"}),", ",(0,s.jsx)(i.code,{children:"gpt-4o"}),", ",(0,s.jsx)(i.code,{children:"gpt-5.4"}),", ",(0,s.jsx)(i.code,{children:"claude-opus-4.6"}),", ",(0,s.jsx)(i.code,{children:"gpt-4.1"}),", ",(0,s.jsx)(i.code,{children:"gpt-4o-mini"}),", ",(0,s.jsx)(i.code,{children:"gemini-3.1-pro-preview"})]}),"\n"]}),"\n",(0,s.jsx)(i.admonition,{title:"Multi-vendor models through one subscription",type:"tip",children:(0,s.jsx)(i.p,{children:"GitHub Copilot provides access to models from OpenAI, Anthropic, and Google \u2014 all through a single subscription. This makes it one of the most versatile provider options."})}),"\n",(0,s.jsx)(i.h3,{id:"environment-variables-1",children:"Environment Variables"}),"\n",(0,s.jsxs)(i.table,{children:[(0,s.jsx)(i.thead,{children:(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.th,{children:"Variable"}),(0,s.jsx)(i.th,{children:"Default"}),(0,s.jsx)(i.th,{children:"Description"})]})}),(0,s.jsxs)(i.tbody,{children:[(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"GITHUB_COPILOT_ENABLED"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"false"})}),(0,s.jsx)(i.td,{children:"Enable the GitHub Copilot provider"})]}),(0,s.jsxs)(i.tr,{children:[(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"GITHUB_COPILOT_MODEL"})}),(0,s.jsx)(i.td,{children:(0,s.jsx)(i.code,{children:"gpt-4o"})}),(0,s.jsx)(i.td,{children:"Default model to use"})]})]})]}),"\n",(0,s.jsx)(i.admonition,{title:"Copilot subscription required",type:"info",children:(0,s.jsx)(i.p,{children:'GitHub Copilot must be active on your GitHub account. If the Copilot token exchange fails, Mercury will show: "Is GitHub Copilot enabled for your account?"'})}),"\n",(0,s.jsx)(i.h2,{id:"configuring-providers",children:"Configuring Providers"}),"\n",(0,s.jsxs)(i.p,{children:["Run ",(0,s.jsx)(i.code,{children:"mercury doctor"})," and enter API keys for the providers you want to use. For OAuth providers (ChatGPT Web, GitHub Copilot), the setup flow opens your browser for authentication \u2014 no keys to copy/paste."]}),"\n",(0,s.jsxs)(i.p,{children:["You can also set environment variables directly or edit ",(0,s.jsx)(i.code,{children:"~/.mercury/mercury.yaml"}),"."]}),"\n",(0,s.jsx)(i.admonition,{title:"Environment variables",type:"tip",children:(0,s.jsxs)(i.p,{children:["Each provider has env vars for its API key, base URL, and model. For example, DeepSeek uses ",(0,s.jsx)(i.code,{children:"DEEPSEEK_API_KEY"}),", ",(0,s.jsx)(i.code,{children:"DEEPSEEK_BASE_URL"}),", and ",(0,s.jsx)(i.code,{children:"DEEPSEEK_MODEL"}),". Ollama Local requires no API key \u2014 just set ",(0,s.jsx)(i.code,{children:"OLLAMA_LOCAL_ENABLED=true"})," and ",(0,s.jsx)(i.code,{children:"OLLAMA_LOCAL_MODEL"})," to your preferred local model. Atomic Chat uses ",(0,s.jsx)(i.code,{children:"ATOMIC_CHAT_ENABLED=true"}),", ",(0,s.jsx)(i.code,{children:"ATOMIC_CHAT_BASE_URL"})," (default ",(0,s.jsx)(i.code,{children:"http://127.0.0.1:1337/v1"}),"), and ",(0,s.jsx)(i.code,{children:"ATOMIC_CHAT_MODEL"}),"."]})})]})}function a(e={}){let{wrapper:i}={...(0,d.R)(),...e.components};return i?(0,s.jsx)(i,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453(e,i,r){r.d(i,{R:()=>l,x:()=>t});var n=r(96540);let s={},d=n.createContext(s);function l(e){let i=n.useContext(d);return n.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function t(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),n.createElement(d.Provider,{value:i},e.children)}}}]);