Account

BYOK

Run Cohub Chats on your own API key in Home Space or connect a ChatGPT (Codex) subscription in Settings → BYOK and share it with others.

This page explains how to run Cohub Chats and CLI prompts using your own API key or model subscription instead of Cohub credits, how to share a connected subscription safely with other users, and how to handle token refresh, usage limits, and common errors.

Choose a method

BYOK (bring your own key) supports two approaches:

API key Subscription
Where to set up Home Space .cohub/models.json Settings → BYOK (/settings/byok) or cohub byok login
Credentials Your literal baseUrl and apiKey OAuth sign-in stored encrypted on the server
Who can use it Only you You, plus anyone you share it with
Supported providers Any provider matching the 8 allowed API adapters ChatGPT (Codex) (openai-codex)

Neither method spends Cohub credits, and both keep working even when your Cohub balance is zero — usage is billed to your own key or subscription plan. Multimodal generation and decision calls still run on platform credentials.

API key: Home Space .cohub/models.json

Add a custom provider to .cohub/models.json in your Home Space (slug home):

{
  "providers": {
    "my-provider": {
      "api": "openai-completions",
      "baseUrl": "https://models.example.com/v1",
      "apiKey": "sk-...",
      "models": [{ "id": "my-model", "contextWindow": 128000 }]
    }
  }
}

Configuration rules:

  • Provider name: Choose any name except cohub, which is reserved for Cohub's platform models. Entries placed under cohub can only override allowlisted parameters (such as contextWindow or maxTokens) on existing platform model IDs — connection fields (baseUrl, apiKey) and unknown model IDs are ignored, and contextWindow overrides are capped at the platform value. If a connected subscription provider uses the same name as a models.json provider, the subscription provider takes precedence.
  • apiKey: Required, non-empty, and sent literally as written. User configurations never read environment variables. For endpoints that require no auth or authenticate via custom headers, pass an explicit non-secret placeholder string.
  • api: Must be one of anthropic-messages, azure-openai-responses, google-generative-ai, mistral-conversations, openai-codex-responses, openai-completions, openai-responses, or pi-messages. Cloud adapters that rely on ambient service credentials (such as Bedrock and Vertex) are platform-only.
  • Model fields: Each entry in models requires id. Optional fields include name, reasoning, input (["text"] or ["text", "image"]), contextWindow, maxTokens, cost, defaultThinkingLevel, thinkingLevelMap, headers, hidden, and imageUrlInput.

After editing .cohub/models.json, create a Save in your Home Space to publish the configuration. The provider then appears in the model picker across all your Spaces. Verify from a terminal:

cohub models ls

apiKey is stored in plain text inside .cohub/models.json. Keep your Home Space private and never share that file.

Subscription: Settings → BYOK

Connect a model subscription you already pay for. Its models appear in the catalog as <your username>/<name>, for example alice/codex. Currently ChatGPT (Codex) (openai-codex, default name codex) is supported.

Connect in the web UI

  1. Set a username in Settings → General if you do not have one yet (providers are named after your username).
  2. Open Settings → BYOK, choose the provider, enter a name (1–32 characters: lowercase letters, digits, and dashes, starting with a letter or digit), and select Connect.
  3. Select Open sign-in page and enter the device code shown. If your account cannot use device codes, select Use a sign-in link instead, sign in, copy the localhost redirect address that fails to load in the browser, and paste it back into Cohub.

Once connected, select the provider's models from the model picker in any Chat.

Credential storage, refresh, and usage limits

  • Encrypted storage: OAuth credentials are stored encrypted on the server (AES-256-GCM) and never enter a Sandbox, workspace file, or another user's view.
  • Automatic refresh: Cohub refreshes active tokens automatically in the background (hourly checks for tokens expiring within 96 hours, plus request-time refresh within 5 minutes of expiry). If a token is revoked or cannot be refreshed, status changes to Sign in again and you (plus anyone you shared it with) are notified. Signing in again with the same name and provider kind replaces the credential and clears the error and cooldown.
  • Usage limits: When the subscription reports a reached usage limit, status changes to Limit reached · resets <time>. Requests fail immediately until the reset time, and both owner and grantees are notified.
  • Quota windows: Each provider shows its subscription windows (for example 5 hours and 7 days) with the percentage used and the reset time, for the owner and everyone it is shared with. They are read from the provider when you open the BYOK settings, at most every 5 minutes. cohub byok show <provider> prints them too.

Share a subscription with others

  1. On a connected provider in Settings → BYOK, select Share and enter the recipient's username (you cannot share with yourself).
  2. The recipient sees the provider under Shared with you and picks its models as <owner username>/<name> (for example alice/codex).
  3. Grantees see only the plan name, never your account email or sign-in credentials. Sharing sends the recipient a notification governed by Mentions in Settings → Notifications.

Management and usage rules:

  • 30-day usage breakdown: Each owned provider shows requests and total tokens per user (including you) over the last 30 days. Counts cover Agent Session turns (including compactions); raw completion endpoints are not listed in this Session usage table, though they still enforce grants and cooldowns and count against your subscription.
  • Immediate revocation: Removing a user stops sharing immediately — their next LLM request fails even inside a running Chat.
  • Leaving or deleting: A recipient can remove a shared provider at any time from Shared with you. Removing a provider you own deletes its stored sign-in and revokes all shares.

Manage and run from the CLI

Connect, inspect, and share subscription providers from the CLI:

cohub byok login                  # connect ChatGPT (Codex) as "codex"
cohub byok login --name work      # connect under a custom name
cohub byok login --link           # sign-in link flow (requires an interactive terminal)
cohub byok list                   # list yours and shared providers (`cohub byok` also lists)
cohub byok show codex             # show models, shares, and 30-day usage
cohub byok share codex bob
cohub byok unshare codex bob
cohub byok leave alice/codex      # remove a provider shared with you
cohub byok rm codex               # disconnect, delete stored sign-in, and stop sharing

List available model IDs and run a prompt on a BYOK model with cohub prompt:

cohub models ls
cohub prompt -p alice/codex -m <model> "Summarize README.md"

BYOK management endpoints require a user login session and do not accept Agent execution tokens.

Boundaries and common errors

Symptom or error Cause and fix
Edits to .cohub/models.json do not appear in the model picker Create a Save in your Home Space (home) to publish the file; fix any JSON syntax error or symlink warning reported on Save.
Custom API key fails authentication when set to an env var name User apiKey values are literal strings and never read environment variables; write the actual key.
Custom provider rejected for unsupported adapter Only the 8 API-key adapters listed above are allowed in user models.json; Bedrock and Vertex are platform-only.
Cannot connect a subscription or providers disappear from the catalog Set a username in Settings → General. Renaming your username breaks existing <old-username>/<name> model references and hides prior 30-day usage recorded under the old username; clearing your username hides all owned subscription providers until a username is set again.
Device code sign-in is rejected by your account Use Use a sign-in link instead (or cohub byok login --link in an interactive terminal) and paste the redirected localhost URL.
Provider shows Sign in again Refresh token was revoked or refresh failed; re-authenticate in Settings → BYOK or run cohub byok login --name <name>.
Requests fail with reached its usage limit Wait until the reset time shown in Settings → BYOK or cohub byok list; the agent does not auto-retry usage-limit errors.
Shared provider fails mid-Chat (is no longer shared with you / needs its owner to sign in again) The owner revoked sharing, removed the provider, or needs to re-authenticate.
cohub byok commands fail inside an automated Agent run BYOK management APIs accept user principals only, not Agent execution tokens; run them from a user-authenticated CLI session or Settings → BYOK.

Next steps

  • Chats — pick models per Chat and run turns
  • Saves — publish Home Space config files by creating a Save
  • Spaces — understand Home Space and Space-level configuration
  • CLI — full cohub prompt, cohub models, and cohub byok reference