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

OpenAI compatible API endpoints

Workers AI supports OpenAI compatible endpoints for text generation (/v1/chat/completions) and text embedding models (/v1/embeddings). This allows you to use the same code as you would for your OpenAI commands, but swap in Workers AI easily.

​​ Usage

​​ Workers AI

Normally, Workers AI requires you to specify the model name in the cURL endpoint or within the env.AI.run function.

With OpenAI compatible endpoints,you can leverage the openai-node sdk to make calls to Workers AI. This allows you to use Workers AI by simply changing the base URL and the model name.

​​ AI Gateway

These endpoints are also compatible with AI Gateway.