A community member has associated this post with a similar question:
Databricks AI_QUERY fails with certain OpenAI models

Only moderators can edit this content.

Databricks AI_QUERY fails with o1-mini and text-embedding-ada-002

James Bentley 10 Reputation points
2025-03-12T17:23:00.6933333+00:00

As of sometime between March 7th and March 12, the Databricks AI_QUERY function has become very temperamental with some Azure OpenAI models.

Asking a basic question of our Mosaic AI o1-mini serving endpoint using AI_QUERY causes an error sometimes but not every time:

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

Sometimes we get this:

"[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"

And other times an output as expected:

result: "The capital of the United Kingdom is **London**."
errorMessage: null

With the error suggesting the resource is not available: https://learn.microsoft.com/en-us/azure/databricks/error-messages/sqlstates#class-57-operator-intervention

We have also noticed a similar issue arise in the same past few days with embedding, but the error is different.

Running an OpenAI embedding model such as:

spark.sql("""
SELECT AI_QUERY(
        'text-embedding-ada-002',
        request => 'What is the capital of United Kingdom?',
        failOnError => false
    )
 """).display()

Now always yields:

[REMOTE_FUNCTION_HTTP_RESULT_UNEXPECTED_ERROR] Failed to evaluate the ai_query SQL function due to inability to process the unexpected remote HTTP response; the error message is 'Missing valid errors field in remote response.'. Check API documentation: https://docs.databricks.com/en/generative-ai/generative-ai.html. Please fix the problem indicated in the error message and retry the query again. SQLSTATE: 57012

It is worth noting that both of these models work fine through the machine learning playground. Also we can't seem to replicate the issue with any other chat models (4o, Llama 70B) or embedding models (bge-large-en).

Has anyone else experience this in the past few days? Might it be related to the March 2025 release of Azure Databricks?

Thanks everyone!

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