Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
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...
#1: Initial revision
How can I use web search with GPT on Azure using Python?
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?
