> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://platform.bctrl.ai/llms.txt.
> For full documentation content, see https://platform.bctrl.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://platform.bctrl.ai/_mcp/server.

# AI Providers

> Bring your own model keys. Hosted agents and tools use them by reference.

A provider holds one set of model credentials - OpenAI, Anthropic, and others. [Hosted agents](/sdk/hosted-agents) and tools reference it by id, so the key is never passed inline or returned in a response.

## Create a provider

```ts
const provider = await bctrl.aiProviders.create({
  provider: "anthropic",
  name: "anthropic-prod",
  apiKey: process.env.ANTHROPIC_API_KEY!,
  defaultModel: "claude-opus-4-8",
  test: true,
});
```

Set `test: true` to validate the key against the provider before saving.

## List, read, update

```ts
const { data } = await bctrl.aiProviders.list();
const one = await bctrl.aiProviders.get(provider.id);

await bctrl.aiProviders.update(provider.id, { defaultModel: "claude-sonnet-4-6" });
```

## Test and delete

```ts
const result = await bctrl.aiProviders.test(provider.id);
await bctrl.aiProviders.delete(provider.id);
```

## Use in an agent

Pass the provider id when running a [hosted agent](/sdk/hosted-agents):

```ts
await bctrl.runtimes.invocations.stagehand.agent(runtime.id, {
  instruction: "Summarize the dashboard.",
  aiProviderId: provider.id,
  model: "claude-opus-4-8",
});
```

## Next

* [Hosted agents](/sdk/hosted-agents) - point agents at a provider
* [Invocations](/sdk/invocations) - the underlying call
* [Vault](/sdk/vault) - other secrets, stored separately