Embedding API change? $.input is invalid

Out of nowhere I’m getting this error all the time, without fail. It was working perfectly before, no code changes since.

Error generating batch embeddings: Error code: 400 - 
{'error': {'message': "'$.input' is invalid. Please check the API reference: 
https://platform.openai.com/docs/api-reference.", 'type': 'invalid_request_error', 'param': None, 'code': None}}
1 Like

Models seem to be working fine. Python openai-1.16.2. Sending a batch of 4 in a list.

— text-embedding-3-small
==== 0 Embedding API Change? ====
Embedding API Change?: 1.00000
‘$.input’ is invalid.: 0.19563
Please check the API reference: 0.42215
invalid_request_error: 0.20202

— text-embedding-3-large
==== 0 Embedding API Change? ====
Embedding API Change?: 1.00000
‘$.input’ is invalid.: 0.18608
Please check the API reference: 0.36561
invalid_request_error: 0.19878

— text-embedding-ada-002
==== 0 Embedding API Change? ====
Embedding API Change?: 1.00000
‘$.input’ is invalid.: 0.71359
Please check the API reference: 0.79991
invalid_request_error: 0.73139

What is it, then, about your input that is invalid, we have to wonder…

Thanks, I’ll explore further on my end.

Same here… We also got it out of nowhere. Any updates to this?

I found the culprit of the issue here. The API accepts an empty string, and a list of strings, however, it returns the above-mentioned error when receiving a list with a single empty string. The documentation states that the input cannot be an empty string which is very confusion. The documentation should probably be updated, and meanwhile, to fix the issue, you should make sure to not send a list with a single empty string.

other than empty string, it can be caused by too large of list, you might try to batch the strings

  for i in trange(0, len(df_text), 100):
        if i + 100 <= len(df_text):
            batch = df_text.iloc[i:i+100]
        else:
            batch = df_text.iloc[i:]
      # do embeddings ...