Moderation API not working with project scoped API key

The moderations endpoint is not working when using a project API key. It seems like the endpoint works as expected if the API key is scoped Default project.

This example request results in 500:

curl .../v1/moderations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "input": [
          {
            "type": "text",
            "text": "This is my text I want to test..."
          }
     ],
     "model": "omni-moderation-latest"
  }'

And the one from the docs results in the same 500:

  curl ..../v1/moderations \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "omni-moderation-latest",
    "input": "...text to classify goes here..."
  }'

Response is http status 500 and body:

{
  "error": {
    "message": "Unexpected error",
    "type": "server_error",
    "param": null,
    "code": null
  }
}

Both these calls work fine using an API key from the Default project.

Any one fixed this issue? It’s happening for me as well.

Funnily enough, I’m getting the same response with any kind of key.

Any updates on this topic? I’m still experiencing the issue.

Ok, we figured it out. Under Limits, you need to make the models available.

3 Likes