Prime Agent ships with Anthropic, OpenAI, and GitHub Copilot built in; authenticate via /login in interactive mode or configure credentials via environment variables, config files, or auth.json in order of precedence. Custom model providers compatible with OpenAI, Anthropic, or Google APIs can be added to ~/.prime/agent/models.json; custom API protocols or OAuth flows require extensions. MCP (Model Context Protocol) is a protocol Prime Agent uses to register and communicate with external model providers; providers are tracked at runtime and can be added dynamically via mcp-command.ts.
Built-in subscription providers are Anthropic Claude Pro/Max, OpenAI ChatGPT Plus/Pro (Codex), and GitHub Copilot; authenticate via /login in interactive mode.[1] A model-registry.ts bug caused Prime Agent to advertise an unsupported Codex client version during model-discovery requests, breaking model enumeration for Codex-backed providers; the fix reports a version string the Codex endpoint accepts. The regression test 702-codex-client-version.test.ts guards against future misalignment between the model-registry.ts version constant and the client version accepted by the upstream Codex API. In packages/ai/src/providers/anthropic.ts, the hardcoded impersonated Claude Code version string is 2.1.257, required for compatibility with Fable 5.x; version mismatches silently break model routing rather than producing explicit errors.
Custom providers and models can be added via ~/.prime/agent/models.json if they speak a supported API (OpenAI, Anthropic, or Google); custom APIs or OAuth require extensions instead.[1] Prime Inference credential precedence follows this order: the PRIME_API_KEY environment variable first, then the Prime CLI config, then auth.json.[2] Extensions are separately installable plugins that enable Prime Agent to support custom API protocols or OAuth authentication flows not covered by built-in providers. Credentials for non-standard APIs cannot be configured in Prime Agent without an extension. In resolve-config-value.ts, the credential resolver treats environment variables set to empty strings as unset, normalizing them to undefined so the fallback chain continues rather than propagating an empty credential value that would cause downstream auth failures. When an MCP provider is added via mcp-command.ts, Prime Agent triggers a refresh of all registered MCP providers so the agent operates with current provider state rather than the stale list cached at startup. The MCP provider refresh logic is coordinated by agent-session.ts, threaded through interactive-mode-services.ts and interactive-mode.ts; interactive-mode-services.ts owns the post-add refresh contract. Test coverage for MCP provider refresh after a provider is added resides in test/interactive-mode-services.test.ts and test/interactive-mode-status.test.ts. The OAuth implementation in packages/ai/src/mcp/oauth.ts performs protected-resource metadata discovery before token exchange, following the MCP OAuth spec's Resource Indicator flow; the resource parameter is populated from the /.well-known/oauth-protected-resource document. Test coverage for the MCP OAuth protected-resource discovery sequence resides in packages/ai/test/mcp-oauth.test.ts. In interactive-mode.ts, the list of available connection models is derived from live state on each read rather than stored as a separate field, eliminating stale-state bugs where the model list could diverge from underlying reality after auth changes or model-registry refreshes. In interactive-mode.ts, a shadow boolean flag for session-started state has been replaced with a direct read of messageCount, eliminating stale-state bugs where the session indicator could diverge from underlying reality. In packages/ai/src/providers/openai-completions.ts, Anthropic prompt-caching logic advances the cache-control marker through the full message sequence, including tool-result messages, positioning the marker after all results before applying the final cache-control annotation to ensure optimal cache hits. Test coverage for Anthropic cache-control marker placement across tool results in multi-turn conversations resides in openai-completions-cache-control-format.test.ts.
As of v0.2.0, /effort sets the reasoning level, replacing the previous Shift+Tab thinking-level cycle.[3] Reasoning capability metadata for Prime Agent models is defined in packages/ai/src/types.ts; adding a reasoning-capable model no longer requires manual code changes — the capability is sourced from the provider's catalog entry. The generate-models.ts script pulls reasoning capability flags from upstream provider metadata; provider adapters for Anthropic, Google, Google Vertex, Amazon Bedrock, OpenAI-completions, and openrouter-reasoning.ts consume these flags. Reasoning-level support (low/medium/high token budgets for thinking models) is derived from provider metadata in the packages/ai layer rather than maintained as a static per-model list. generate-models.ts generates the Prime Inference model catalog at packages/ai/src/models.generated.ts; the file should not be hand-edited. model-resolver.ts resolves model identifiers against the generated catalog at packages/ai/src/models.generated.ts; drift between the two — or between either and related tests — causes runtime resolution failures. The /fast effort toggle is supported for sessions authenticated via raw OpenAI API keys; model-selection and header logic are implemented in packages/ai/src/models.ts, providers/openai-responses.ts, and providers/openai-codex-responses.ts, with interactive-mode availability checks enforced in interactive-mode.ts. The Prime Inference provider integration contributes models to the generated catalog (packages/ai/src/models.generated.ts); test coverage for Prime Inference model availability resides in test/prime-inference-models.test.ts. The Fireworks provider integration contributes models to the Prime Inference model catalog (packages/ai/src/models.generated.ts); test coverage for Fireworks model availability resides in test/fireworks-models.test.ts.
Sources