Cloudflare 中文文档
Workers AI
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Bindings

​​ Workers

Workers provides a serverless execution environment that allows you to create new applications or augment existing ones.

To use Workers AI with Workers, you must create a Workers AI binding. Bindings allow your Workers to interact with resources, like Workers AI, on the Cloudflare Developer Platform. You create bindings on the Cloudflare dashboard or by updating your wrangler.toml file.

To bind Workers AI to your Worker, add the following to the end of your wrangler.toml file:

​​ Pages Functions

Pages Functions allow you to build full-stack applications with Cloudflare Pages by executing code on the Cloudflare network. Functions are Workers under the hood.

To configure a Workers AI binding in your Pages Function, you must use the Cloudflare dashboard. Refer to Workers AI bindings for instructions.

​​ Methods

​​ async env.AI.run()

async env.AI.run() runs a model. Takes a model as the first parameter, and an object as the second parameter.

Parameters

  • model string required

    • The model to run.

    Supported options

    • stream boolean optional
      • Returns a stream of results as they are available.