docs/deepseek.md
CodexBar can use either a DeepSeek API key or a signed-in DeepSeek Platform session for the remaining credit balance. Detailed cost and token usage comes from the Platform session; an API key cannot authenticate the private dashboard endpoints.
DEEPSEEK_API_KEY / DEEPSEEK_KEY, or selected from DeepSeek token accounts in ~/.codexbar/config.json.GET https://api.deepseek.com/user/balanceAuthorization: Bearer <api key>, Accept: application/jsonis_available, and a balance_infos array with per-currency entries
(total_balance, granted_balance, topped_up_balance).GET https://platform.deepseek.com/api/v0/users/get_user_summaryAuthorization: Bearer <platform userToken>, Accept: application/jsonGET https://platform.deepseek.com/api/v0/usage/amount?month=<month>&year=<year>GET https://platform.deepseek.com/api/v0/usage/cost?month=<month>&year=<year>Authorization: Bearer <platform userToken>, Accept: application/jsonCodexBar resolves the Platform userToken in this order:
DEEPSEEK_PLATFORM_TOKEN / DEEPSEEK_USER_TOKEN or a legacy
providers[].cookieHeader value preserved from an existing config.userToken from the https://platform.deepseek.com local-storage origin in Chrome.The legacy config value remains a compatibility fallback so upgrading cannot silently erase a working browser-only session. An unscoped legacy or environment token is never combined with an API-key balance; API enrichment requires a session saved for that credential scope. New automatic imports are never written back to config.
CodexBar checks every Chrome profile containing a parseable userToken against DeepSeek. Rejected or expired
sessions are omitted. Settings shows a Chrome profile picker containing only valid sessions. With no API key, one
valid session is selected automatically; with multiple valid sessions, CodexBar reuses the saved choice or asks once.
When an API key supplies the balance, a new or changed API credential requires an explicit session selection before
website usage is combined with it. CodexBar persists a stable browser/profile identifier, not an absolute home-directory path, and
keeps automatically imported tokens in memory only. The choice is scoped to a non-reversible fingerprint of the
active API credential and saved-account slot, so replacing a key or switching accounts cannot silently reuse an old
browser session. Validation results are cached briefly so normal
refreshes do not probe every profile, and a temporary network failure does not erase a previously validated profile.
If the selected session expires, CodexBar asks before switching to another valid profile.
If no session is valid, the menu keeps the API-key balance when one exists; otherwise it asks the user to sign in to
DeepSeek Platform in Chrome. Authentication failures returned as top-level or nested DeepSeek codes 40002 and
40003 are treated as expired sessions.
$50.00 (Paid: $40.00 / Granted: $10.00).is_available is false, it shows "Balance unavailable for API calls".DEEPSEEK_API_KEY / DEEPSEEK_KEY.Sources/CodexBarCore/Providers/DeepSeek/DeepSeekProviderDescriptor.swift (descriptor + fetch strategy)Sources/CodexBarCore/Providers/DeepSeek/DeepSeekUsageFetcher.swift (HTTP client + JSON parser)Sources/CodexBarCore/Providers/DeepSeek/DeepSeekPlatformTokenImporter.swift (Chrome Platform session import)Sources/CodexBarCore/Providers/DeepSeek/DeepSeekSettingsReader.swift (env var resolution)Sources/CodexBar/Providers/DeepSeek/DeepSeekProviderImplementation.swift (provider activation and token-account visibility)Sources/CodexBarCore/TokenAccountSupportCatalog+Data.swift (DeepSeek token-account injection)