SQL Server 2025 Azure open AI Vector Embedding for ai_generate_embeddings

Harshala 0 Reputation points
2025-09-13T12:11:13.46+00:00

Hi Team,

Currently I am trying to implement Vector Search using SQL Server 2025 and SSMS 21. For getting embeddings I am trying below code using ai_generate_embeddings, however i am getting empty embeddings.

Code :

Creating Credentials

CREATE DATABASE SCOPED CREDENTIAL [https://XXX.openai.azure.com]

WITH IDENTITY = 'HTTPEndpointHeaders',

SECRET = '{"api-key":"abcdefghi"}';

Create external model model1237

with (

location = 'https://XXX.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15',

credential = [https://XXX.openai.azure.com],

api_format ='Azure OpenAI',

model_type =EMBEDDINGS,

model = 'text-embedding-ada-002'

);

declare @qv vector(1536) = ai_generate_embeddings('Hello World' use model model1237)

select @qv

but here I am getting empty embeddings. Could you please advise why i am getting empty embeddings. i tried different ways but still getting null embeddings from ai_generate_embeddings.

please advise.

Header 1 Header 2
Cell 1 Cell 2
Cell 3 Cell 4
SQL Server Database Engine
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 127.7K Reputation points MVP Volunteer Moderator
    2025-09-13T20:50:27.2+00:00

    I get the same result when I run your code. Not that I expected it work, since I assume that you don't post your actual API key in public. But it tells me that with an invalid key, you get NULL back. So that could be the reason.

    For deeper troubleshooting, you can set up an extended-evens session with the events external_rest_endpoint_summary and external_rest_endpoint_summary. They include information about the REST call, including http_response_code.

    I don't have an OPEN AI account myself, so I cannot test further myself.

    0 comments No comments

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.