Databricks AI_QUERY fails with certain OpenAI models

James Bentley 10 Reputation points
2025-03-12T17:41:44.71+00:00

We have been using successfully using the AI_QUERY function in Azure Databricks to interact with o1-mini and text-embedding-ada-002 models.

However in the past few days, we have started to encounter errors. Calling our o1-mini model as usual using:

spark.sql("""
SELECT AI_QUERY(
        'o1-mini', 
        request => 'What is the capital of United Kingdom?',
        failOnError => false,
        modelParameters => named_struct('temperature', 1)
    )
 """).display()

Sometimes, but not every time, results in the error:

"[REMOTE_FUNCTION_HTTP_FAILED_ERROR] The remote HTTP request failed with code 400, and error message 'HTTP request failed with status: {\"error_code\":\"BAD_REQUEST\",\"message\":\"{\\\\\"external_model_provider\\\\\":\\\\\"openai\\\\\",\\\\\"external_model_error\\\\\":{\\\\\"error\\\\\":{\\\\\"message\\\\\":\\\\\"Invalid prompt: your prompt was flagged as potentially violating our usage policy. Please try again with a different prompt: https://platform.openai.com/docs/guides/reasoning#advice-on-prompting\\\\\",\\\\\"type\\\\\":\\\\\"invalid_request_error\\\\\",\\\\\"param\\\\\":null,\\\\\"code\\\\\":\\\\\"invalid_prompt\\\\\"}}}\"}' SQLSTATE: 57012"

This can also be reliably replicated across different Databricks workspaces and different deployments of o1-mini.

We have started encountering issues with text-embedding-ada-002 as well.

These models work fine when being interacted with directly or through the model playground, and equally other models such as 4o, Llama 70B, and bge-large seem to be unaffected.

Has anyone else encountered these issues? Or does anyone else find this when running in their workspace?

Thanks :)

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
{count} vote

1 answer

Sort by: Most helpful
  1. Ganesh Gurram 7,230 Reputation points Moderator
    2025-03-17T07:10:28.3633333+00:00

    @James Bentley - Apologies for the delayed response, and we appreciate your patience.

    As per the recommendation from our internal team, you may try disabling or lowering the severity of the AOAI content filters to see if that helps resolve the issue.

    Hope this helps. Do let us know if you have any further queries.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.