<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic AI_QUERY fails with o1-mini in Generative AI</title>
    <link>https://community.databricks.com/t5/generative-ai/ai-query-fails-with-o1-mini/m-p/112396#M790</link>
    <description>&lt;P&gt;As of sometime between March 7th and March 12, the AI_QUERY function has become very temperamental with Azure OpenAI models.&lt;/P&gt;&lt;P&gt;Asking a basic question of our Mosaic AI o1-mini serving endpoint using AI_QUERY causes an error&amp;nbsp;&lt;EM&gt;sometimes&lt;/EM&gt; but not&amp;nbsp;&lt;EM&gt;every&lt;/EM&gt; time:&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spark.sql("""
SELECT AI_QUERY(
        'o1-mini', 
        request =&amp;gt; 'What is the capital of United Kingdom?',
        failOnError =&amp;gt; false,
        modelParameters =&amp;gt; named_struct('temperature', 1)
    )
 """).display()&lt;/LI-CODE&gt;&lt;P&gt;Sometimes we get this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"[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"&lt;/LI-CODE&gt;&lt;P&gt;And other times an output as expected:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;result: "The capital of the United Kingdom is **London**."
errorMessage: null&lt;/LI-CODE&gt;&lt;P&gt;With the error suggesting the resource is not available:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jAAmes_bentley_0-1741797431261.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15364iF0B009304792370B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jAAmes_bentley_0-1741797431261.png" alt="jAAmes_bentley_0-1741797431261.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We have also noticed a similar issue arise in the same past few days with embedding, but the error is different.&lt;/P&gt;&lt;P&gt;Running an OpenAI embedding model such as:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spark.sql("""
SELECT AI_QUERY(
        'text-embedding-ada-002',
        request =&amp;gt; 'What is the capital of United Kingdom?',
        failOnError =&amp;gt; false
    )
 """).display()&lt;/LI-CODE&gt;&lt;P&gt;Now&amp;nbsp;&lt;STRONG&gt;always&lt;/STRONG&gt; yields:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is worth noting that both of these models work fine through the machine learning playground.&lt;/P&gt;&lt;P&gt;Has anyone else experience this in the past few days? Might it be related to the March 2025 release of Azure Databricks?&lt;BR /&gt;Thanks everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Mar 2025 16:42:21 GMT</pubDate>
    <dc:creator>jAAmes_bentley</dc:creator>
    <dc:date>2025-03-12T16:42:21Z</dc:date>
    <item>
      <title>AI_QUERY fails with o1-mini</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-fails-with-o1-mini/m-p/112396#M790</link>
      <description>&lt;P&gt;As of sometime between March 7th and March 12, the AI_QUERY function has become very temperamental with Azure OpenAI models.&lt;/P&gt;&lt;P&gt;Asking a basic question of our Mosaic AI o1-mini serving endpoint using AI_QUERY causes an error&amp;nbsp;&lt;EM&gt;sometimes&lt;/EM&gt; but not&amp;nbsp;&lt;EM&gt;every&lt;/EM&gt; time:&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spark.sql("""
SELECT AI_QUERY(
        'o1-mini', 
        request =&amp;gt; 'What is the capital of United Kingdom?',
        failOnError =&amp;gt; false,
        modelParameters =&amp;gt; named_struct('temperature', 1)
    )
 """).display()&lt;/LI-CODE&gt;&lt;P&gt;Sometimes we get this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"[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"&lt;/LI-CODE&gt;&lt;P&gt;And other times an output as expected:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;result: "The capital of the United Kingdom is **London**."
errorMessage: null&lt;/LI-CODE&gt;&lt;P&gt;With the error suggesting the resource is not available:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jAAmes_bentley_0-1741797431261.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/15364iF0B009304792370B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jAAmes_bentley_0-1741797431261.png" alt="jAAmes_bentley_0-1741797431261.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We have also noticed a similar issue arise in the same past few days with embedding, but the error is different.&lt;/P&gt;&lt;P&gt;Running an OpenAI embedding model such as:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spark.sql("""
SELECT AI_QUERY(
        'text-embedding-ada-002',
        request =&amp;gt; 'What is the capital of United Kingdom?',
        failOnError =&amp;gt; false
    )
 """).display()&lt;/LI-CODE&gt;&lt;P&gt;Now&amp;nbsp;&lt;STRONG&gt;always&lt;/STRONG&gt; yields:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is worth noting that both of these models work fine through the machine learning playground.&lt;/P&gt;&lt;P&gt;Has anyone else experience this in the past few days? Might it be related to the March 2025 release of Azure Databricks?&lt;BR /&gt;Thanks everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 16:42:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-fails-with-o1-mini/m-p/112396#M790</guid>
      <dc:creator>jAAmes_bentley</dc:creator>
      <dc:date>2025-03-12T16:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: AI_QUERY fails with o1-mini</title>
      <link>https://community.databricks.com/t5/generative-ai/ai-query-fails-with-o1-mini/m-p/137242#M1318</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/111453"&gt;@jAAmes_bentley&lt;/a&gt;&amp;nbsp;, I did some digging and here is what I found.&lt;/P&gt;
&lt;H3&gt;Root Cause: Unsupported Temperature Parameter&lt;/H3&gt;
&lt;P&gt;The primary issue with your `AI_QUERY` call to &lt;STRONG&gt;o1-mini is the temperature parameter&lt;/STRONG&gt;. OpenAI's o1-series models (o1, o1-mini, o1-preview, o3-mini) &lt;STRONG&gt;do not support the `temperature` parameter at all&lt;/STRONG&gt;—even when set to the default value of 1. When you include `modelParameters =&amp;gt; named_struct('temperature', 1)`, it causes the OpenAI API to reject the request, resulting in the misleading "Invalid prompt" error.&lt;/P&gt;
&lt;P&gt;The o1 reasoning models also don't support other sampling parameters like `top_p`, `presence_penalty`, `frequency_penalty`, and several others that work with GPT-4o and earlier models.&lt;/P&gt;
&lt;H2&gt;Solution for o1-mini&lt;/H2&gt;
&lt;P&gt;&lt;STRONG&gt;Remove the `modelParameters` argument entirely&lt;/STRONG&gt; when calling o1-mini:&lt;/P&gt;
&lt;P&gt;```python&lt;BR /&gt;spark.sql("""&lt;BR /&gt;SELECT AI_QUERY(&lt;BR /&gt;'o1-mini', &lt;BR /&gt;request =&amp;gt; 'What is the capital of United Kingdom?',&lt;BR /&gt;failOnError =&amp;gt; false&lt;BR /&gt;)&lt;BR /&gt;""").display()&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;This should resolve the intermittent 400 errors you're experiencing.&lt;/P&gt;
&lt;H2&gt;Embedding Model Issue&lt;/H2&gt;
&lt;P&gt;The `text-embedding-ada-002` error is separate and indicates a response parsing issue rather than a parameter problem. The error `Missing valid errors field in remote response` suggests that Databricks `AI_QUERY` is receiving an unexpected response format from the embedding endpoint.&lt;/P&gt;
&lt;P&gt;For embeddings through `AI_QUERY`, ensure your endpoint configuration matches the expected response schema. Since the model works in the ML playground, this may be a temporary API integration issue between Databricks and Azure OpenAI that emerged in the March 2025 release timeframe.&lt;/P&gt;
&lt;H2&gt;Why It Works in ML Playground&lt;/H2&gt;
&lt;P&gt;The ML playground likely handles model-specific parameter restrictions automatically, stripping unsupported parameters before sending requests to OpenAI. The `AI_QUERY` function passes parameters directly, requiring you to manually ensure compatibility with each model's constraints.&lt;/P&gt;
&lt;P&gt;Hope this helps, Louis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Nov 2025 12:49:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/ai-query-fails-with-o1-mini/m-p/137242#M1318</guid>
      <dc:creator>Louis_Frolio</dc:creator>
      <dc:date>2025-11-01T12:49:55Z</dc:date>
    </item>
  </channel>
</rss>

