Skip to content

Latest commit

 

History

History
122 lines (101 loc) · 8.41 KB

model-providers.md

File metadata and controls

122 lines (101 loc) · 8.41 KB

Model providers, owners and pod secrets

Model providers

A model provider is a saved way for an agent CLI to reach its models other than its usual sign-in. Today the one kind is Amazon Bedrock, for Claude Code (Anthropic models) and Codex (OpenAI models on Bedrock, through Codex's built-in amazon-bedrock provider).

Pointing an agent at an OpenAI-/Anthropic-compatible endpoint (a proxy such as LiteLLM) is the other route: a connection's shellEnv exports the base-URL variables and a secret carries the key. See LiteLLM proxy.

Managed in Settings → Model providers (GET/POST/PATCH/DELETE /api/model-providers, services/model-provider-service.ts, table model_providers). A provider has:

  • a name and an owner: the organization (owner_user_id null; admins only) or one person;
  • the agents it serves (claude-code, codex) and the models it offers each, in picker order (the first is the default; bedrockDefaultModels suggests us.anthropic.claude-… / openai.gpt-… ids for the region);
  • a region;
  • on your machines: an optional AWS profile name (blank = the machine's default AWS credentials);
  • in pods: access-key (AWS key id + secret + optional session token), bearer-token (a Bedrock API key), ambient (the pod's own IAM role, e.g. IRSA on EKS) or none (machines only). Stored credentials are AES-256-GCM encrypted on the row (AAD model_provider|<id>) and never returned; the API only says hasPodCredentials.

Work picks a provider with agentOptions.modelProvider = <id>, and its model field (claudeModel / copilotModel) then holds one of the provider's model ids. The web, iOS and Android forms only show the Provider switch once a provider serves the chosen runtime.

bedrockRuntime() in @optio/shared is the one mapping to the CLIs, used by both run locations:

Claude Code Codex
env CLAUDE_CODE_USE_BEDROCK=1, AWS_REGION, AWS_DEFAULT_REGION AWS_REGION, AWS_DEFAULT_REGION
flags — -c model_provider="amazon-bedrock"
credentials pods: AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN or AWS_BEARER_TOKEN_BEDROCK; machines: AWS_PROFILE or the default chain same

Pods: the task, workflow and persistent-agent workers call resolveProviderForWork (which re-checks the owner, agent, workspace and pod credentials at run time and fails the run with a clear message otherwise) and podProviderRuntime; the agent's sign-in mode becomes bedrock, so no Anthropic / OpenAI key is required. Machines: see "Model providers" in optio-local.md.

Agent credentials

A credential is how an agent CLI signs in for one piece of pod work: one of the agent's known sign-in secrets, or a model provider. The Who section's Signed in with row (GET /api/agents/credentials?agentType=&owner=, services/agent-credential-service.ts) lists:

  • the organization's secrets of the agent's known names — Claude Code: CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_API_KEY, CLAUDE_VERTEX_PROJECT_ID; Codex: OPENAI_API_KEY, CODEX_APP_SERVER_URL; Gemini: GEMINI_API_KEY, GOOGLE_CLOUD_PROJECT; Copilot: COPILOT_GITHUB_TOKEN; Cursor: CURSOR_API_KEY; OpenCode: ANTHROPIC_API_KEY / OPENAI_API_KEY / GROQ_API_KEY; OpenClaw: OPENCLAW_API_KEY — and the viewer's own (user-scope) rows of those names;
  • the model providers that serve the agent (kind: "provider", the same pick as the Provider row used to be);
  • default: true on the one a run with no pick uses: the nearest secret of the name the deployment's CLAUDE_AUTH_MODE / CODEX_AUTH_MODE / GEMINI_AUTH_MODE selects (the owner's own mode and row first for private work).

Values are never returned. The + (POST /api/agents/credentials) stores a value as the named secret for the organization (admins) or for the caller (scope: user), replacing that owner's existing one (the row id, which work holds, stays the same), after checking it with the service when it can — Anthropic, OpenAI and Gemini model lists, GitHub /user (POST /api/agents/credentials/verify runs that check alone, for a "Test" button). Vertex projects are listed but come from the setup wizard. Bedrock is added in Settings → Model providers.

Work picks a secret credential with agentOptions.credential = "secret:<row id>" (a provider is still agentOptions.modelProvider; never both). POST /api/work / PATCH /api/work/:id check the pick with the provider pick (workResourcesError): a private credential is usable only by work its owner owns, and work on a machine takes none (the machine's own CLI login). A run then gets the value as that env var and the auth mode it implies — oauth-token / api-key / vertex-ai for Claude Code, api-key / app-server (with --app-server <url>) for Codex — over the deployment's default, in the Repo Task worker and in pooledAgentEnv (Jobs, persistent agents).

Owners

Model providers, secrets (scope: "user"), connections, MCP servers, skills, prompts and work (tasks, work_definitions, persistent_agents) have an owner: the organization (null) or one person (owner_user_id). The visibility rule every kind shares is in scope.md and services/ownership.ts; the work-specific rules (services/work-ownership.ts):

  • Private work runs with its owner's secrets, providers and connections. Only its owner (and, read-only, a workspace admin) sees it; only its owner may change it, run it by hand, message it, resume it or change its triggers (403). Admins may delete it.
  • Organization work can only use organization providers, secrets and connections (400 otherwise). Its runs never look up anyone's personal secrets, agent sign-in included.
  • New work is personal when the body says owner: "me", when it runs on a machine (always), or when it picks something personal; otherwise the organization's. Making organization work personal takes an admin or its creator.
  • Tasks spawned by a scheduled Task inherit its owner and picked secrets.
  • A personal connection reaches only work its owner owns (getConnectionsForTask).

Pod secrets

podSecrets (on tasks, work_definitions, persistent_agents) is the list of secret names a piece of work gives its agent. GET /api/secrets/pickable lists what a viewer can pick: the organization's global secrets and their own; identity tokens (ANTHROPIC_API_KEY, …) and Optio's own settings (*_AUTH_MODE, Vertex settings) are never offered. Global secrets are the deployment's, so only the founding workspace (the oldest, as for requireDeploymentAdmin) may pick them (mayUseDeploymentSecrets); work in any other workspace picks its owner's own or uses a connection. At run time resolvePodSecrets takes the owner's secret first, then the repo's, then the organization's, under the same rule. null keeps the legacy behavior. The workspace setting Pods get only the secrets work picks (workspaces.restrict_pod_secrets) also stops repo pods from receiving every organization secret during setup.

Joining a workspace by email domain

workspaces.auto_join_domains + auto_join_role (member or viewer; workspace settings, admins only; public mail domains are refused). After an OAuth sign-in, joinWorkspacesByEmailDomain adds the user to every workspace listing their email's domain, but only when the provider vouches for the email (OAuthUser.emailVerified: Google verified_email, OIDC email_verified, GitHub's verified primary, GitLab's confirmed email; an LDAP or SAML address only with that provider's trustEmail). A first-time user's default workspace becomes the first one joined, so no empty personal workspace is created. A workspace admin may list their own email's domain only when that email is verified (users.email_verified); any other domain takes a deployment admin.