我试图使用Locust对OpenAI的GPT-3.5-TURBO进行工作负载分析。
from locust import HttpUser, between, taskclass 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 )
我遇到了这个错误:
POST /v1/chat/completion/: HTTPError('404 Client Error: Not Found for url: /v1/chat/completion/')
我的Azure OpenAI工作负载分析脚本使用完全相同的结构运行正常。我遗漏了什么?
回答:
这是拼写错误。应该是:
https://api.openai.com/v1/chat/completions
而不是:
https://api.openai.com/v1/chat/completion/