复制令牌值以备后用

发布时间:2025-06-24 17:26:12  作者:北方职教升学中心  阅读量:325


  • 审查预填信息。

    前提条件

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

  • 转到 AI > Workers AI。

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

    $ curlhttps://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 具体文档

  • 您将使用 Workers AI REST API 来试验一个大型语言模型(LLM)。
  • 选择继续到摘要。

    1. 获取 API 令牌和账户 ID

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

  • 如果您选择创建一个 API 令牌而不使用模板,该令牌将需要 Workers AI - 读取 和 Workers AI - 编辑 的权限。stabe-diffusion1.5等等,非常丰富:

    模型名称模型任务描述
    0@hf/google/gemma-7b-itText GenerationFamily 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-awqText GenerationFamily 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-0106Text GenerationFamily 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.5Text EmbeddingsFeature 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-chatText GenerationFamily 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-instructText GenerationFamily 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-int8Text ClassificationSentiment analysis or text classification is a common NLP task that classifies a text input into labels or classes.
    7@cf/google/gemma-2b-it-loraText GenerationFamily 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-betaText GenerationFamily 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-instructText GenerationFamily 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-awqText GenerationFamily 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-awqText GenerationFamily 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-50Object DetectionObject 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-fp16Text GenerationFamily 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.1Text GenerationFamily 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-loraText GenerationFamily of generative text models, such as large language models (LLM), that can be adapted for a variety of natural language tasks.
    16@cf/openai/whisperAutomatic Speech RecognitionAutomatic speech recognition (ASR) models convert a speech signal, typically an audio input, to text.
    17@cf/tinyllama/tinyllama-1.1b-chat-v1.0Text GenerationFamily 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.2Text GenerationFamily 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-bf16Text GenerationFamily 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-hfImage-to-Text
    21@hf/thebloke/codellama-7b-instruct-awqText GenerationFamily 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-inpaintingText-to-ImageGenerates 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-awqText GenerationFamily 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-int8Text GenerationFamily 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-awqText GenerationFamily 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-awqText GenerationFamily 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-awqText GenerationFamily 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-awqText GenerationFamily 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-50Image ClassificationImage classification models take an image input and assigns it labels or classes.
    30@cf/bytedance/stable-diffusion-xl-lightningText-to-ImageGenerates 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-awqText GenerationFamily 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-loraText GenerationFamily 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-lcmText-to-ImageGenerates 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.0Text-to-ImageGenerates images from input text. These models can be used to generate and modify images based on text prompts.
    35@cf/meta/detr-resnet-50Object DetectionObject 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-awqText GenerationFamily 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.2bTranslationTranslation models convert a sequence of text from one language to another.
    38@hf/thebloke/deepseek-coder-6.7b-instruct-awqText GenerationFamily 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-awqText GenerationFamily 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.5Text EmbeddingsFeature 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-instructText GenerationFamily 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-instructText GenerationFamily 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-7bText GenerationFamily 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.5Text EmbeddingsFeature 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-500mImage-to-Text
    46@hf/thebloke/zephyr-7b-beta-awqText GenerationFamily 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-loraText GenerationFamily 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-chatText GenerationFamily 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-enAutomatic Speech RecognitionAutomatic speech recognition (ASR) models convert a speech signal, typically an audio input, to text.
    50@cf/defog/sqlcoder-7b-2Text GenerationFamily 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-2Text GenerationFamily 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-cnnSummarizationSummarization 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-img2imgText-to-ImageGenerates images from input text. These models can be used to generate and modify images based on text prompts.

    使用 Workers AI REST API

    本指南将指导您设置并部署您的第一个 Workers AI 项目。deepseek、

  • 获取您的账户 ID:
    • 回到使用 Workers AI API 的屏幕(您最初的标签页)。
    • 获取您的 API 令牌:
      • 选择获取 API 令牌。
      • 在获取账户 ID 下,复制账户 ID 的值。
      • 选择创建令牌。
      • 复制令牌值以备后用。
      • 选择使用 Workers AI API。

        Cloudflare上线了AI Worker,可以通过调用CF的接口来接入以下主流的开源AI模型,例如千问、llama2、llama3、

        2. 通过 API 运行模型

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

        获取这些值的步骤:

        • 登录到 Cloudflare 控制面板并选择您的账户。