Why is the data returned from openai azure endpoint different than in docs?

Nico Herrera 20 Reputation points
2024-10-02T16:03:12.2333333+00:00

Hello, Im using https://{endpoint}/openai/deployments/{deployment-id}/chat/completions?api-version=2024-06-01, but my response looks like

{
  id: 'xxxx',
  model: 'xxxx',
  created: 1727883132,
  object: 'extensions.chat.completion.chunk',
  choices: [
    { index: 0, delta: [Object], end_turn: false, finish_reason: null }
  ],
  system_fingerprint: 'xxxx'
}

instead of it looking like

{
  "body": {
    "id": "chatcmpl-7R1nGnsXO8n4oi9UPz2f3UHdgAYMn",
    "created": 1686676106,
    "choices": [
      {
        "index": 0,
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "Content of the completion [doc1].",
          "context": {
            "citations": [
              {
                "content": "Citation content.",
                "title": "Citation Title",
                "filepath": "contoso.txt",
                "url": "https://contoso.blob.windows.net/container/contoso.txt",
                "chunk_id": "0"
              }
            ],
            "intent": "dog care"
          }
        }
      }
    ],
    "usage": {
      "completion_tokens": 557,
      "prompt_tokens": 33,
      "total_tokens": 590
    }
  }
}

Why am i getting a different response?

Azure OpenAI in Foundry Models
0 comments No comments

Answer accepted by question author
Sina Salam 31,456 Reputation points Volunteer Moderator
2024-10-02T20:15:30.78+00:00

Hello Nico Herrera,

Welcome to the Microsoft Q&A and thank you for posting your questions here.

The reason is because you're receiving the response in streaming mode instead of a complete response. Check your code and disable Streaming Mode by setting the stream parameter in the request body to false (the default).

   {
     "messages": [
       {
         "role": "user",
         "content": "Your input here"
       }
     ],
     "max_tokens": 100,
     "stream": false
   }

I hope this is helpful! Do not hesitate to let me know if you have any other questions.


Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

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.