AI Credentials

View as Markdown

AI credentials give your workspaces access to LLM providers — OpenAI, Anthropic, Google, or any OpenAI-compatible endpoint. Agents like Stagehand and browser-use use these credentials to reason about pages and execute instructions.

Access via bctrl.aiCredentials.

list()

List all AI credentials in your organization.

1const credentials = await bctrl.aiCredentials.list();

Returns AiCredential[]


create(request)

Create a new AI credential.

1await bctrl.aiCredentials.create({
2 id: "openai-prod",
3 provider: "openai",
4 label: "Production OpenAI",
5 apiKey: "sk-...",
6 defaultModel: "gpt-4o",
7});
ParameterTypeRequiredDescription
idstringYesUnique identifier for this credential
provider'openai' | 'anthropic' | 'google' | 'openai-compatible'YesAI provider
labelstringYesHuman-readable label
apiKeystringYesProvider API key
baseUrlstringNoCustom base URL (for openai-compatible)
defaultModelstringNoDefault model to use
enabledbooleanNoWhether the credential is active (default: true)

Returns AiCredential


get(id)

Get a specific credential by ID.

1const cred = await bctrl.aiCredentials.get("openai-prod");
ParameterTypeRequiredDescription
idstringYesCredential ID

Returns AiCredential


update(id, request)

Update an existing credential.

1await bctrl.aiCredentials.update("openai-prod", {
2 defaultModel: "gpt-4o-mini",
3 enabled: true,
4});
ParameterTypeRequiredDescription
idstringYesCredential ID
requestAiCredentialUpdateRequestYesFields to update

Returns AiCredential


delete(id)

Delete a credential.

1await bctrl.aiCredentials.delete("openai-prod");
ParameterTypeRequiredDescription
idstringYesCredential ID

test(id)

Test that a credential can connect to its provider.

1const result = await bctrl.aiCredentials.test("openai-prod");
ParameterTypeRequiredDescription
idstringYesCredential ID

Returns AiCredentialTestResponse


Usage with workspaces

Credentials are mounted to workspaces via the ai mount. See Scopes & Inheritance for details.

1const workspace = await bctrl.workspaces.create({
2 name: "my-agent",
3 mounts: {
4 ai: {
5 allow: ["openai-prod"],
6 defaults: { openai: "openai-prod" },
7 },
8 },
9});