Skip to content

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.

  1. Install dependencies

    Terminal window
    npm install opencontrol hono @ai-sdk/anthropic

    Here we use Anthropic’s Claude.

  2. Create the server

    Terminal window
    touch src/opencontrol.ts
    src/opencontrol.ts
    import { create } from "opencontrol"
    import { handle } from "hono/aws-lambda"
    const app = create({
    // model: ...,
    // tools: [ ]
    })
    export const handler = handle(app)
  3. 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")
    })
  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.