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.
2,368 questions
{count} vote

Your answer

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