Get started - Workers AI local dev
In this guide, you will get started with Workers AI, experiment with a large language model (LLM), and deploy your first AI powered app on the Workers platform.
 Before you begin
Setup your local development environment, if this is your first time developing with Wrangler.
 1. Create a Workers project
Create a new project named hello-ai by running:
When setting up your hello-ai Worker, answer the setup questions as follows:
- Enter hello-aifor the directory to create in
- Choose "Hello World" scriptfor the type of application
- Select yesto using TypeScript
- Select yesto using Git
- Select noto deploying
This will create a new hello-ai directory. Your new hello-ai directory will include:
- A "Hello World"Worker atsrc/index.ts
- A wrangler.tomlconfiguration file.
Navigate to your app directory:
 2. Connect your Worker to Workers AI
You must create a binding for your Worker to connect to Workers AI. Bindings allow your Workers to access resources or services, like Workers AI, on the Cloudflare developer platform. You create bindings by updating your wrangler.toml file.
To bind Workers AI to your Worker, add the following to the end of your wrangler.toml file:
wrangler.toml[ai]
binding = "AI" # i.e. available in your Worker on env.AI
You can also bind Workers AI to a Pages Function. For more information, refer to Functions Bindings.
 3. Install the Workers AI client library
 4. Run an inference task in your Worker
Now we are ready to run an inference task in our our worker. In this case, we will use an LLM, like lambda-2, to answer a questions.
Go to your hello-ai and update the index.ts with the following code:
"src/index.ts"import { Ai } from '@cloudflare/ai'
export interface Env {  // If you set another name in wrangler.toml as the value for 'binding',  // replace "AI" with the variable name you defined.  AI: any;
}
export default {  async fetch(request: Request, env: Env) {    const ai = new Ai(env.AI);
    const response = await ai.run('@cf/meta/llama-2-7b-chat-int8', {        prompt: "What is the origin of the phrase Hello, World"      }    );
    return new Response(JSON.stringify(response));  },
};
After configuring your Worker, you can test your project locally before you deploy globally.
 5. Develop locally with Wrangler
While in your project directory, test Workers AI locally by running. Note, you will be prompted to login at this time:
When you run npx wrangler dev, Wrangler will give you a URL (most likely localhost:8787) to review your Worker. After you visit the URL Wrangler provides, you will see this message:
 6. Deploy your AI Worker
Before deploying your AI Worker globally, log in with your Cloudflare account by running:
You will be directed to a web page asking you to log in to the Cloudflare dashboard. After you have logged in, you will be asked if Wrangler can make changes to your Cloudflare account. Scroll down and select Allow to continue.
Finally, deploy your Worker to make your project accessible on the Internet. To deploy your Worker, run:
You can now visit the URL to run your AI Worker.
By finishing this tutorial, you have created a Worker, connected it to Workers AI, and ran an inference tasks from your model.
 Next steps
If you have any feature requests or notice any bugs, share your feedback directly with the Cloudflare team by joining the Cloudflare Developers community on Discord.