Get Started
How to get started with OpenControl.
OpenControl lets you control your infrastructure with AI. It is meant to live in your codebase and be deployed as a part of your infrastructure.
Let’s get started.
-
Install dependencies
Terminal window npm install opencontrol hono @ai-sdk/anthropicHere we use Anthropic’s Claude.
-
Create the server
Terminal window touch src/opencontrol.tssrc/opencontrol.ts import { create } from "opencontrol"import { handle } from "hono/aws-lambda"const app = create({// model: ...,// tools: [ ]})export const handler = handle(app) -
Pick the model
src/opencontrol.ts import { Resource } from "sst"import { createAnthropic } from "@ai-sdk/anthropic"const app = create({model: createAnthropic({apiKey: Resource.AnthropicKey.value,})("claude-3-7-sonnet-20250219")}) -
Define your tools
src/opencontrol.ts import { tool } from "opencontrol/tool"import { Inventory } from "@acme/core/inventory/index"const inventory = tool({name: "inventory_record",description: "Record new inventory event to track in or out amounts",args: Inventory.record.schema,async run(input) {return Inventory.record(input)}})const app = create({tools: [inventory]})We’ve got some more examples of tools you can use.
-
Infrastructure
We are using
OpenControl
SST component here. But since OpenControl is just a Hono app, you can deploy it however you want.sst.config.ts const anthropicKey = new sst.Secret("AnthropicKey")const server = new sst.aws.OpenControl("MyServer", {server: {handler: "src/opencontrol.handler",link: [anthropicKey]}})We are defining a secret for the Anthropic API key and linking it to our OpenControl server.
-
Link any resources
sst.config.ts const bucket = new sst.aws.Bucket("MyBucket")const server = new sst.aws.OpenControl("MyServer", {server: {handler: "src/opencontrol.handler",link: [bucket]}})If your tools need to access to your resources, you can link them as well.
-
Grant permissions
If you are using the AWS tool, you’ll need to give your OpenControl server permissions to access your AWS account.
sst.config.ts const server = new sst.aws.OpenControl("MyServer", {server: {handler: "src/opencontrol.handler",policies: $dev? ["arn:aws:iam::aws:policy/AdministratorAccess"]: ["arn:aws:iam::aws:policy/ReadOnlyAccess"]}})Here we are giving it admin access in dev but read-only access in prod.
-
Deploy
Currently, OpenControl uses basic auth but we’ll be adding support for OAuth soon.
sst.config.ts return {OpenControlUrl: server.url,OpenControlPassword: server.password}You can print out the URL of your server and it’s password and deploy.
Terminal window sst deploy
Now head over to the URL, login with the password, and you can use AI to talk to your infrastructure.
Examples
Check out how Terminal uses OpenControl.