404 error when doing workload anlysis using locust on OpenAI API (GPT.35)

题意:"使用 Locust 对 OpenAI API (GPT-3.5) 进行工作负载分析时出现 404 错误。"

问题背景:

I am trying to do some workload analysis on OpenAI GPT-3.5-TURBO using locust.

"我正在使用 Locust 对 OpenAI GPT-3.5-TURBO 进行一些工作负载分析。"

python 复制代码
from locust import HttpUser, between, task


class OpenAIUser(HttpUser):

    wait_time = between(1, 2)  # wait between 1 and 2 seconds
    host = "https://api.openai.com/"

    def on_start(self):

        self.headers = {
            "Content-Type": "application/json",
            "Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        }

        self.data = {
            "model": "gpt-3.5-turbo",
            "messages": [
                {
                    "role": "system",
                    "content": "You are a helpful story teller."
                },
                {
                    "role": "user",
                    "content": "Tell me a 100 word story"
                }
            ]
        }

    @task
    def test_chat_completion(self):
        self.client.post(
            "https://api.openai.com/v1/chat/completion/",
            json=self.data,
            headers=self.headers
        )

I get this error:

得到如下错误信息:

复制代码
POST /v1/chat/completion/: HTTPError('404 Client Error: Not Found for url: /v1/chat/completion/')

My script for Azure OpenAI workload analysis works fine with this exact same structure. What am I missing?

"我用于 Azure OpenAI 工作负载分析的脚本在相同的结构下运行正常。我漏掉了什么?"

问题解决:

Typo error. Should be:

"拼写错误。应该是:"

复制代码
https://api.openai.com/v1/chat/completions

and not: 而不是:

复制代码
https://api.openai.com/v1/chat/completion/
相关推荐
这里有鱼汤7 分钟前
95%开发者未充分利用的Python特性:解包操作性能实测与最佳实践
python
这里有鱼汤8 分钟前
🎨 Matplotlib十大高级绘图技巧,学会了升职加薪(不骗你)
后端·python
www_pp_8 分钟前
# 利用迁移学习优化食物分类模型:基于ResNet18的实践
人工智能·深度学习·迁移学习
令狐少侠201111 分钟前
python后端程序部署到服务器 Ubuntu并配合 Vue 前端页面运行
服务器·前端·python
亚马逊云开发者15 分钟前
基于 Amazon Nova 和 TEN 框架的实时音视频交互解决方案
人工智能
听风吹等浪起16 分钟前
改进系列(9):基于VisionTransformer+InceptionDW+Focal_loss改进实现的遥感地面目标识别
人工智能·计算机视觉·目标跟踪
独立开阀者_FwtCoder18 分钟前
Trae + 设计 MCP :实现 UI 到网页自动化
前端·javascript·人工智能
悠悠海风23 分钟前
目标检测中的损失函数(二) | BIoU RIoU α-IoU
人工智能·深度学习·目标检测
闭月之泪舞24 分钟前
《CBOW 词向量转化实战:让自然语言处理 “读懂” 文字背后的含义》
人工智能·自然语言处理·easyui
Anarkh_Lee30 分钟前
Python 项目环境配置与 Vanna 安装避坑指南 (PyCharm + venv)
人工智能·python·pycharm