0

I want to use web search when calling GPT on Azure using Python.

I can call GPT on Azure using Python as follows:

import os
from openai import AzureOpenAI
endpoint = "https://somewhere.openai.azure.com/"
model_name = "gpt5"
deployment = "gpt5"
subscription_key = ""
api_version = "2024年12月01日-preview"
client = AzureOpenAI(
 api_version=api_version,
 azure_endpoint=endpoint,
 api_key=subscription_key,
)
response = client.chat.completions.create(
 messages=[
 {
 "role": "system",
 "content": "You are a funny assistant.",
 },
 {
 "role": "user",
 "content": "Tell me a joke about birds",
 }
 ],
 max_completion_tokens=16384,
 model=deployment
)
print(response.choices[0].message.content)

How do I add web search? Just like ChatGPT can do:

enter image description here

asked Oct 4 at 5:54
1
  • 1
    you can do this in 2 ways, if you want to be in the azure ecosystem then you can use bing search or other wise you can use something like tavily, firecrawl, you will have to provide web search as a function call when creating the response (refer to platform.openai.com/docs/guides/function-calling) Commented Oct 4 at 11:46

1 Answer 1

0

Based on learn.microsoft.com (mirror 1; mirror 2), web search with GPT on Azure using Python is not supported yet:

Not currently supported:

  • The web search tool

  • Image generation using multi-turn editing and streaming - coming soon

  • Images can't be uploaded as a file and then referenced as input. Coming soon.

There's a known issue with the following:

  • PDF as an input file is now supported , but setting file upload purpose to user_data is not currently supported.

  • Performance issues when background mode is used with streaming. The issue is expected to be resolved soon.

answered Oct 5 at 2:30
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.