Cloudflare 免费 AI接口服务 AI Worker

CSDN 2024-07-04 10:01:07 阅读 54

Cloudflare上线了AI Worker,可以通过调用CF的接口来接入以下主流的开源AI模型,例如千问、llama2、llama3、deepseek、stabe-diffusion1.5等等,非常丰富:

模型名称 模型任务 描述
0 @hf/google/gemma-7b-it Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
1 @cf/qwen/qwen1.5-14b-chat-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
2 @cf/openchat/openchat-3.5-0106 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
3 @cf/baai/bge-large-en-v1.5 Text Embeddings Feature extraction models transform raw data into numerical features that can be processed while preserving the information in the original dataset. These models are ideal as part of building vector search applications or Retrieval Augmented Generation workflows with Large Language Models (LLM).
4 @cf/qwen/qwen1.5-0.5b-chat Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
5 @hf/meta-llama/meta-llama-3-8b-instruct Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
6 @cf/huggingface/distilbert-sst-2-int8 Text Classification Sentiment analysis or text classification is a common NLP task that classifies a text input into labels or classes.
7 @cf/google/gemma-2b-it-lora Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
8 @hf/nexusflow/starling-lm-7b-beta Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
9 @cf/meta/llama-3-8b-instruct Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
10 @hf/thebloke/llamaguard-7b-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
11 @hf/thebloke/neural-chat-7b-v3-1-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
12 @cf/facebook/detr-resnet-50 Object Detection Object detection models can detect instances of objects like persons, faces, license plates, or others in an image. This task takes an image as input and returns a list of detected objects, each one containing a label, a probability score, and its surrounding box coordinates.
13 @cf/meta/llama-2-7b-chat-fp16 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
14 @cf/mistral/mistral-7b-instruct-v0.1 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
15 @cf/mistral/mistral-7b-instruct-v0.2-lora Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
16 @cf/openai/whisper Automatic Speech Recognition Automatic speech recognition (ASR) models convert a speech signal, typically an audio input, to text.
17 @cf/tinyllama/tinyllama-1.1b-chat-v1.0 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
18 @hf/mistral/mistral-7b-instruct-v0.2 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
19 @cf/fblgit/una-cybertron-7b-v2-bf16 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
20 @cf/llava-hf/llava-1.5-7b-hf Image-to-Text
21 @hf/thebloke/codellama-7b-instruct-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
22 @cf/runwayml/stable-diffusion-v1-5-inpainting Text-to-Image Generates images from input text. These models can be used to generate and modify images based on text prompts.
23 @cf/thebloke/discolm-german-7b-v1-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
24 @cf/meta/llama-2-7b-chat-int8 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
25 @hf/thebloke/mistral-7b-instruct-v0.1-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
26 @hf/thebloke/openchat_3.5-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
27 @cf/qwen/qwen1.5-7b-chat-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
28 @hf/thebloke/llama-2-13b-chat-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
29 @cf/microsoft/resnet-50 Image Classification Image classification models take an image input and assigns it labels or classes.
30 @cf/bytedance/stable-diffusion-xl-lightning Text-to-Image Generates images from input text. These models can be used to generate and modify images based on text prompts.
31 @hf/thebloke/deepseek-coder-6.7b-base-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
32 @cf/meta-llama/llama-2-7b-chat-hf-lora Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
33 @cf/lykon/dreamshaper-8-lcm Text-to-Image Generates images from input text. These models can be used to generate and modify images based on text prompts.
34 @cf/stabilityai/stable-diffusion-xl-base-1.0 Text-to-Image Generates images from input text. These models can be used to generate and modify images based on text prompts.
35 @cf/meta/detr-resnet-50 Object Detection Object detection models can detect instances of objects like persons, faces, license plates, or others in an image. This task takes an image as input and returns a list of detected objects, each one containing a label, a probability score, and its surrounding box coordinates.
36 @hf/thebloke/openhermes-2.5-mistral-7b-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
37 @cf/meta/m2m100-1.2b Translation Translation models convert a sequence of text from one language to another.
38 @hf/thebloke/deepseek-coder-6.7b-instruct-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
39 @cf/mistral/mixtral-8x7b-instruct-v0.1-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
40 @cf/baai/bge-small-en-v1.5 Text Embeddings Feature extraction models transform raw data into numerical features that can be processed while preserving the information in the original dataset. These models are ideal as part of building vector search applications or Retrieval Augmented Generation workflows with Large Language Models (LLM).
41 @cf/deepseek-ai/deepseek-math-7b-instruct Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
42 @cf/tiiuae/falcon-7b-instruct Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
43 @hf/nousresearch/hermes-2-pro-mistral-7b Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
44 @cf/baai/bge-base-en-v1.5 Text Embeddings Feature extraction models transform raw data into numerical features that can be processed while preserving the information in the original dataset. These models are ideal as part of building vector search applications or Retrieval Augmented Generation workflows with Large Language Models (LLM).
45 @cf/unum/uform-gen2-qwen-500m Image-to-Text
46 @hf/thebloke/zephyr-7b-beta-awq Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
47 @cf/google/gemma-7b-it-lora Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
48 @cf/qwen/qwen1.5-1.8b-chat Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
49 @cf/openai/whisper-tiny-en Automatic Speech Recognition Automatic speech recognition (ASR) models convert a speech signal, typically an audio input, to text.
50 @cf/defog/sqlcoder-7b-2 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
51 @cf/microsoft/phi-2 Text Generation Family of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
52 @cf/facebook/bart-large-cnn Summarization Summarization is the task of producing a shorter version of a document while preserving its important information. Some models can extract text from the original input, while other models can generate entirely new text.
53 @cf/runwayml/stable-diffusion-v1-5-img2img Text-to-Image Generates images from input text. These models can be used to generate and modify images based on text prompts.

使用 Workers AI REST API

本指南将指导您设置并部署您的第一个 Workers AI 项目。您将使用 Workers AI REST API 来试验一个大型语言模型(LLM)。

前提条件

如果您还没有,那么请注册一个 Cloudflare 账户。

1. 获取 API 令牌和账户 ID

您需要您的 API 令牌和账户 ID 来使用 REST API。

获取这些值的步骤:

登录到 Cloudflare 控制面板并选择您的账户。转到 AI > Workers AI。选择使用 Workers AI API。获取您的 API 令牌:

选择获取 API 令牌。审查预填信息。选择继续到摘要。选择创建令牌。复制令牌值以备后用。 获取您的账户 ID:

回到使用 Workers AI API 的屏幕(您最初的标签页)。在获取账户 ID 下,复制账户 ID 的值。

如果您选择创建一个 API 令牌而不使用模板,该令牌将需要 Workers AI - 读取 和 Workers AI - 编辑 的权限。

2. 通过 API 运行模型

创建您的 API 令牌后,使用您的 API 令牌在请求中进行身份验证并向 API 发出请求。

您将使用执行 AI 模型端点来运行 @cloudflare/meta-llama/llama-2-7b-chat-int8 模型:

$ curl https://api.cloudflare.com/client/v4/accounts/{ ACCOUNT_ID}/ai/run/@cf/meta/llama-2-7b-chat-int8 \

-H 'Authorization: Bearer {API_TOKEN}' \

-d '{ "prompt": "Where did the phrase Hello World come from" }'

可以参考cloudflare的接口页面:

Cloudflare AI rest API接口说明

Cloudflare AI rest API 具体文档



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。