Skip to content

http request examples in the README.md seems to be incorrect now #229

@Wonder-donbury

Description

@Wonder-donbury

I'm new to using this repo, but json data inside the -d doesn't work without wrapping it with key named "input"

if I follow what's written in current readme it produces this following error

{
  "delayTime": 874,
  "error": "handler: 'input' \ntraceback: Traceback (most recent call last):\n  File \"/usr/local/lib/python3.10/dist-packages/runpod/serverless/modules/rp_job.py\", line 249, in run_job_generator\n    async for output_partial in job_output:\n  File \"/src/handler.py\", line 10, in handler\n    job_input = JobInput(job[\"input\"])\nKeyError: 'input'\n",
  "executionTime": 150,
  "id": "e246a116-5c9f-4904-a072-a772a76bea67-e1",
  "status": "FAILED",
  "workerId": "b6a62s3kh47t06"

it has to be

curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
   -d '{ 
"model": "gpt-4",
"input":{
 "messages": [
     {
       "role": "user",
       "content": "Why is RunPod the best platform?"
     }
 ],
 "temperature": 0,
 "max_tokens": 100
 }
 }'

Reference to the current readme

Using http requests:

  1. Change the Authorization header to your RunPod API Key and the url to your RunPod Serverless Endpoint URL in the following format: https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1
    • Before:
    curl https://api.openai.com/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
    "model": "gpt-4",
    "messages": [
      {
        "role": "user",
        "content": "Why is RunPod the best platform?"
      }
    ],
    "temperature": 0,
    "max_tokens": 100
    }'
    • After:
    curl https://api.runpod.ai/v2/<YOUR ENDPOINT ID>/openai/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <YOUR OPENAI API KEY>" \
    -d '{
    "model": "<YOUR DEPLOYED MODEL REPO/NAME>",
    "messages": [
      {
        "role": "user",
        "content": "Why is RunPod the best platform?"
      }
    ],
    "temperature": 0,
    "max_tokens": 100
    }'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions