몇 분 안에 첫 Microsoft Web IQ API 호출을 만듭니다. 웹을 검색하고, 응답을 검사하고, 알려진 URL에서 쿼리 중심 구절을 추출합니다. 추가 예제에서는 위치 검색 및 자동 증거 검색을 보여 줍니다.
Web IQ 리소스가 아직 없는 경우 계속하기 전에 Azure 포털 또는 Azure CLI 사용하여 만듭니다.
이 페이지의 맨 위에서 SDK 또는 REST 예제를 선택하여 모든 예제를 함께 전환합니다. SDK는 인증, 재시도 및 응답 유형을 처리합니다.
API 키는 Web IQ를 평가하는 가장 빠른 방법입니다. 프로덕션 워크로드의 경우 Microsoft Entra ID 사용합니다.
사전 요구 사항
- 프로필 관리의 Web IQ API 키입니다.
메모
애플리케이션이 중국에서 실행되는 경우 검색 엔드포인트의 경우 https://api.microsoftol.com/v3 대신 https://api.microsoft.ai/v3를 호출합니다. REST 예제에서 URL을 바꿉니다. SDK 클라이언트를 생성할 때 Python의 baseUrl 인수, TypeScript의 base_url 옵션, Rust의 WebIqClient::builder().base_url(...), Java의 WebIQClientOptions.builder().baseUrl(...), 또는 .NET의 WebIQClientOptions.BaseUrl 속성을 사용하여 동일한 기본 URL을 설정합니다.
기본 URL을 참조하세요.
Tip
코드 없이 단계별 시작을 선호하시겠습니까? 웹 IQ 개발자 포털 에서 시작 : 앱 프로필을 선택하고, API 키를 만들고, Playground에서 요청을 보내고, 생성된 코드를 복사하고, 사용량을 확인합니다.
1. API 키를 저장하세요
요청 예제에서 키를 반복하지 않고 소스 코드에 넣지 않도록 키를 환경 변수에 저장합니다.
macOS 또는 Linux
export WEBIQ_API_KEY="your-api-key"
Windows PowerShell
$env:WEBIQ_API_KEY="your-api-key"
Warning
소스 제어에 키를 커밋하거나 브라우저 또는 클라이언트 쪽 코드에 노출하지 마세요. 프로덕션 자격 증명을 Secret Manager에 저장합니다.
2. 웹 검색
질문이나 쿼리가 있고 Web IQ가 관련 페이지를 찾아 순위를 매기도록 하려는 경우 Web Search를 사용합니다.
모든 요청에 대해 maxResults = 10, contentFormat = passage, maxLength = 3000를 최적화된 운영 지점으로 설정하는 것이 좋습니다. 여기에서 사용 사례에 따라 이러한 설정을 미세 조정할 수 있습니다.
엔드포인트:POST https://api.microsoft.ai/v3/search/web
curl --request POST "https://api.microsoft.ai/v3/search/web" \
--header "x-apikey: $WEBIQ_API_KEY" \
--header "content-type: application/json" \
--data '{
"query": "latest developments in retrieval augmented generation",
"maxResults": 10,
"contentFormat": "passage",
"maxLength": 3000
}'
Python 3.11 이상에서 python -m pip install webiq==1.2.1와 함께 SDK를 설치한 다음, 다음을 실행합니다.
import os
from webiq import WebIQClient
from webiq.types import ContentFormat
with WebIQClient(api_key=os.environ["WEBIQ_API_KEY"]) as client:
results = client.web.search(
"latest developments in retrieval augmented generation",
max_results=10,
content_format=ContentFormat.passage,
max_length=3000,
)
for result in results.webResults or []:
print(result.title, result.url)
npm install @microsoft/webiq@1.2.1로 SDK를 설치합니다(Node.js 22.x에서는 22.18 이상 또는 24 이상). 이 예제를 search.mts(으)로 저장하고 node search.mts를 사용하여 실행합니다.
import { WebIQClient, ContentFormat } from "@microsoft/webiq";
async function main() {
const client = new WebIQClient({ apiKey: process.env.WEBIQ_API_KEY });
try {
const results = await client.web.search(
"latest developments in retrieval augmented generation",
{
maxResults: 10,
contentFormat: ContentFormat.PASSAGE,
maxLength: 3000,
},
);
for (const result of results.webResults ?? []) {
console.log(result.title, result.url);
}
} finally {
await client.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Rust 1.88 이상 프로젝트에서 cargo add webiq@1.2.1 및 cargo add tokio --features macros,rt-multi-thread를 실행하세요. 이 예제를 src/main.rs로 저장하고 cargo run를 실행하세요.
use webiq::{ContentFormat, WebIqClient, WebSearchOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WebIqClient::new(std::env::var("WEBIQ_API_KEY")?)?;
let results = client.web().search(
"latest developments in retrieval augmented generation",
WebSearchOptions::new()
.max_results(10)
.content_format(ContentFormat::Passage)
.max_length(3000),
).await?;
for result in results.web_results.unwrap_or_default() {
println!("{:?} {:?}", result.title, result.url);
}
Ok(())
}
Java 11 이상용으로 구성된 Maven 프로젝트에서 pom.xml에 다음 종속성을 추가합니다:
<dependency>
<groupId>com.microsoft.webiq</groupId>
<artifactId>webiq</artifactId>
<version>1.2.1</version>
</dependency>
이 예제를 src/main/java/Search.java로 저장하고 mvn compile exec:java -Dexec.mainClass=Search를 실행하세요.
import com.microsoft.webiq.WebIQClient;
import com.microsoft.webiq.models.ContentFormat;
import com.microsoft.webiq.models.WebResponse;
import com.microsoft.webiq.models.WebResult;
import com.microsoft.webiq.resources.WebSearchOptions;
public class Search {
public static void main(String[] args) {
try (WebIQClient client = WebIQClient.withApiKey(System.getenv("WEBIQ_API_KEY"))) {
WebResponse results = client.web.search(
"latest developments in retrieval augmented generation",
WebSearchOptions.builder()
.maxResults(10)
.contentFormat(ContentFormat.PASSAGE)
.maxLength(3000)
.build());
if (results.getWebResults() != null) {
for (WebResult result : results.getWebResults()) {
System.out.println(result.getTitle() + " " + result.getUrl());
}
}
}
}
}
.NET 8 이상 콘솔 프로젝트에서 dotnet add package Microsoft.WebIQ --version 1.2.1를 실행합니다. 이 예제를 Program.cs로 저장하고 dotnet run를 실행하세요.
using Microsoft.WebIQ;
using Microsoft.WebIQ.Models;
string apiKey = Environment.GetEnvironmentVariable("WEBIQ_API_KEY")
?? throw new InvalidOperationException("Set WEBIQ_API_KEY before running this example.");
using var client = new WebIQClient(apiKey);
var results = await client.Web.SearchAsync(
"latest developments in retrieval augmented generation",
request =>
{
request.MaxResults = 10;
request.ContentFormat = ContentFormat.Passage;
request.MaxLength = 3000;
});
foreach (var result in results.WebResults ?? [])
Console.WriteLine($"{result.Title} {result.Url}");
import os
import json
import requests
response = requests.post(
"https://api.microsoft.ai/v3/search/web",
headers={
"x-apikey": os.environ["WEBIQ_API_KEY"],
"content-type": "application/json",
},
json={
"query": "latest developments in retrieval augmented generation",
"maxResults": 10,
"contentFormat": "passage",
"maxLength": 3000,
},
timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
이 예제를 search.mjs(으)로 저장하고 node search.mjs를 사용하여 실행합니다.
const response = await fetch("https://api.microsoft.ai/v3/search/web", {
method: "POST",
headers: {
"x-apikey": process.env.WEBIQ_API_KEY,
"content-type": "application/json",
},
body: JSON.stringify({
query: "latest developments in retrieval augmented generation",
maxResults: 10,
contentFormat: "passage",
maxLength: 3000,
}),
});
if (!response.ok) {
throw new Error(`Web Search failed: ${response.status} ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));
3. 응답 이해하기
성공적인 Web Search는 webResults 배열을 반환합니다. 이 약어 예제에서는 가장 자주 사용할 필드를 보여 줍니다.
{
"webResults": [
{
"title": "Example result",
"url": "https://example.com/article",
"content": "The query-relevant passage extracted from the page...",
"crawledAt": "2026-07-18T12:00:00Z"
}
],
"traceId": "00000000000000000000000000000000"
}
-
title및url은 원본을 식별합니다. -
content에는contentFormat: "passage"를 사용한 요청이므로 쿼리 관련 내용이 포함됩니다. -
traceId는 Web IQ 지원에서 요청을 검토할 수 있도록 도움이 됩니다.
REST 응답 및 MCP 도구 결과에서 중첩된 결과 개체의 필드를 포함하여 "" 또는 빈 문자열(null) 값을 가진 모델 필드는 생략됩니다. 빈 목록/배열([]) 필드는 유지되지만, Places에서는 목록 필드도 없을 수 있습니다. 없는 필드를 사용할 수 없는 것으로 간주하고 비어 있거나 없는 목록을 항목이 없는 것으로 간주합니다. 공백 전용 문자열, false, 0, 빈 사전, 개별 배열/사전 항목 및 포함된 원시 JSON이 유지됩니다. 루트 배열 및 MCP content 와 같은 프로토콜 엔벌로프 컬렉션은 변경되지 않습니다.
모든 매개 변수 및 응답 필드에 대한 Web Search API 참조 를 참조하세요.
4. 엔드포인트 선택
| 시작하기 | 사용 | 얻을 수 있는 것 |
|---|---|---|
| 질문 또는 검색 쿼리 | 웹 검색 | 쿼리 관련 콘텐츠가 있는 순위가 지정된 페이지 |
| 특정 URL | 찾아보기 | 해당 페이지에서 추출된 콘텐츠 |
| 위치 또는 로컬 비즈니스 쿼리 | 장소 | 주소 및 영업 시간과 같은 구조화된 장소 세부 정보 |
| 자동으로 선택된 답변 형식이 필요한 쿼리 | REST 또는 SDK 1.2.1 이상을 통해 자동으로 | 결과 범위 인용이 있는 형식화된 증거 |
| 쇼핑 또는 제품 쿼리 | REST를 통한 Commerce (프라이빗 미리 보기) | 판매자 제안, 가격 및 제품 세부 정보가 포함된 순위별 제품 |
공통 그라운딩 워크플로는 두 엔드포인트를 모두 사용합니다. 관련 원본을 검색하고, 결과 URL을 선택한 다음, 해당 URL을 탐색하여 후속 질문과 관련된 구절을 추출합니다.
5. URL에서 콘텐츠 추출
읽을 페이지를 이미 알고 있는 경우 찾아보기를 사용합니다.
passage을 query로 설정하고 비어 있지 않은 contentFormat을 제공하면 질문과 가장 관련된 페이지 부분을 검색할 수 있습니다.
liveCrawl: "fallback" 페이지가 아직 인덱스에 없는 경우 웹 IQ에 페이지를 크롤링하도록 요청합니다. 라이브 크롤링은 퍼블리셔 측 크롤링 예의 정책 제한 및 가용성의 적용을 받습니다. fallback는 실제 크롤링을 보장하지 않습니다.
모든 예제는 그라운딩에 권장되는 형식인 쿼리 중심 구절을 요청합니다. 선택 영역 query은 비어 있지 않아야 하며 1,000자를 넘지 않아야 합니다. maxLength은 반환되는 콘텐츠의 양을 별도로 제어합니다. 전체 문서 형식(texthtml및markdown)에는 전체 문서 액세스가 필요합니다.
엔드포인트:POST https://api.microsoft.ai/v3/browse
curl --request POST "https://api.microsoft.ai/v3/browse" \
--header "x-apikey: $WEBIQ_API_KEY" \
--header "content-type: application/json" \
--data '{
"url": "https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
"query": "How fast is Web IQ",
"contentFormat": "passage",
"maxLength": 3000,
"liveCrawl": "fallback"
}'
Python 3.11 이상에서 python -m pip install webiq==1.2.1와 함께 SDK를 설치한 다음, 다음을 실행합니다.
import os
from webiq import WebIQClient
from webiq.types import BrowseContentFormat
with WebIQClient(api_key=os.environ["WEBIQ_API_KEY"]) as client:
page = client.browse.fetch(
"https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
query="How fast is Web IQ",
content_format=BrowseContentFormat.passage,
max_length=3000,
live_crawl="fallback",
)
print(page.content)
npm install @microsoft/webiq@1.2.1로 SDK를 설치합니다(Node.js 22.x에서는 22.18 이상 또는 24 이상). 이 예제를 browse.mts(으)로 저장하고 node browse.mts를 사용하여 실행합니다.
import { WebIQClient, BrowseContentFormat, LiveCrawlMode } from "@microsoft/webiq";
async function main() {
const client = new WebIQClient({ apiKey: process.env.WEBIQ_API_KEY });
try {
const page = await client.browse.fetch(
"https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
{
query: "How fast is Web IQ",
contentFormat: BrowseContentFormat.PASSAGE,
maxLength: 3000,
liveCrawl: LiveCrawlMode.FALLBACK,
},
);
console.log(JSON.stringify(page, null, 2));
} finally {
await client.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Rust 1.88 이상 프로젝트에서 cargo add webiq@1.2.1 및 cargo add tokio --features macros,rt-multi-thread를 실행하세요. 이 예제를 src/main.rs로 저장하고 cargo run를 실행하세요.
use webiq::{BrowseContentFormat, BrowseOptions, LiveCrawlMode, WebIqClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WebIqClient::new(std::env::var("WEBIQ_API_KEY")?)?;
let page = client.browse().fetch(
"https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
BrowseOptions::new()
.query("How fast is Web IQ")
.content_format(BrowseContentFormat::Passage)
.max_length(3000)
.live_crawl(LiveCrawlMode::Fallback),
).await?;
println!("{}", page.content.unwrap_or_default());
Ok(())
}
Java 11 이상용으로 구성된 Maven 프로젝트에서 pom.xml에 다음 종속성을 추가합니다:
<dependency>
<groupId>com.microsoft.webiq</groupId>
<artifactId>webiq</artifactId>
<version>1.2.1</version>
</dependency>
이 예제를 src/main/java/Browse.java로 저장하고 mvn compile exec:java -Dexec.mainClass=Browse를 실행하세요.
import com.microsoft.webiq.WebIQClient;
import com.microsoft.webiq.models.BrowseContentFormat;
import com.microsoft.webiq.models.BrowseResponse;
import com.microsoft.webiq.models.LiveCrawlMode;
import com.microsoft.webiq.resources.BrowseFetchOptions;
public class Browse {
public static void main(String[] args) {
try (WebIQClient client = WebIQClient.withApiKey(System.getenv("WEBIQ_API_KEY"))) {
BrowseResponse page = client.browse.fetch(
"https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
BrowseFetchOptions.builder()
.query("How fast is Web IQ")
.contentFormat(BrowseContentFormat.PASSAGE)
.maxLength(3000)
.liveCrawl(LiveCrawlMode.FALLBACK)
.build());
System.out.println(page.getContent());
}
}
}
.NET 8 이상 콘솔 프로젝트에서 dotnet add package Microsoft.WebIQ --version 1.2.1를 실행합니다. 이 예제를 Program.cs로 저장하고 dotnet run를 실행하세요.
using Microsoft.WebIQ;
using Microsoft.WebIQ.Models;
string apiKey = Environment.GetEnvironmentVariable("WEBIQ_API_KEY")
?? throw new InvalidOperationException("Set WEBIQ_API_KEY before running this example.");
using var client = new WebIQClient(apiKey);
var page = await client.Browse.FetchAsync(
"https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
request =>
{
request.ContentFormat = BrowseContentFormat.Passage;
request.Query = "How fast is Web IQ";
request.MaxLength = 3000;
request.LiveCrawl = LiveCrawlMode.Fallback;
});
Console.WriteLine(page.Content);
import os
import json
import requests
response = requests.post(
"https://api.microsoft.ai/v3/browse",
headers={
"x-apikey": os.environ["WEBIQ_API_KEY"],
"content-type": "application/json",
},
json={
"url": "https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
"query": "How fast is Web IQ",
"contentFormat": "passage",
"maxLength": 3000,
"liveCrawl": "fallback",
},
timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
이 예제를 browse.mjs(으)로 저장하고 node browse.mjs를 사용하여 실행합니다.
const response = await fetch("https://api.microsoft.ai/v3/browse", {
method: "POST",
headers: {
"x-apikey": process.env.WEBIQ_API_KEY,
"content-type": "application/json",
},
body: JSON.stringify({
url: "https://techcommunity.microsoft.com/blog/azuredevcommunityblog/why-ai-agents-need-external-grounding/4565283",
query: "How fast is Web IQ",
contentFormat: "passage",
maxLength: 3000,
liveCrawl: "fallback",
}),
});
if (!response.ok) {
throw new Error(`Browse failed: ${response.status} ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));
성공적인 200 응답에는 페이지 url, title, 추출된 content, 및 응답 traceId가 포함됩니다. 라이브 크롤링은 ISO 8601 UTC 타임스탬프인 202와 함께 retryAfter를 반환할 수 있습니다. 해당 시간까지 기다린 다음 동일한 요청을 다시 보냅니다. 전체 응답 사양에 대한 찾아보기 API 참조를 참조하세요.
6. 장소 검색(선택 사항)
장소 검색을 사용하여 지역 비즈니스 및 기타 장소에 대한 구조화된 정보를 검색합니다. SDK 예제에서는 2단계에 설치된 1.2.1 패키지를 사용합니다.
엔드포인트:POST https://api.microsoft.ai/v3/search/places
curl --request POST "https://api.microsoft.ai/v3/search/places" \
--header "x-apikey: $WEBIQ_API_KEY" \
--header "content-type: application/json" \
--data '{
"query": "coffee in Seattle",
"maxResults": 5,
"language": "en",
"region": "US",
"location": "lat:47.6062;long:-122.3321"
}'
import os
from webiq import WebIQClient
with WebIQClient(api_key=os.environ["WEBIQ_API_KEY"]) as client:
places = client.places.search(
"coffee in Seattle",
max_results=5,
language="en",
region="US",
location="lat:47.6062;long:-122.3321",
)
for place in places.placeResults or []:
print(place.name, place.businessUrl)
이 예제를 places.mts(으)로 저장하고 node places.mts를 사용하여 실행합니다.
import { WebIQClient } from "@microsoft/webiq";
async function main() {
const client = new WebIQClient({ apiKey: process.env.WEBIQ_API_KEY });
try {
const places = await client.places.search("coffee in Seattle", {
maxResults: 5,
language: "en",
region: "US",
location: "lat:47.6062;long:-122.3321",
});
for (const place of places.placeResults ?? []) {
console.log(place.name, place.businessUrl);
}
} finally {
await client.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
2단계에서 Tokio 설정을 사용합니다. 이 예제를 src/main.rs로 저장하고 cargo run를 실행하세요.
use webiq::{PlacesSearchOptions, WebIqClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WebIqClient::new(std::env::var("WEBIQ_API_KEY")?)?;
let places = client.places().search(
"coffee in Seattle",
PlacesSearchOptions::new()
.max_results(5)
.language("en")
.region("US")
.location("lat:47.6062;long:-122.3321"),
).await?;
for place in places.place_results.unwrap_or_default() {
println!("{:?} {:?}", place.name, place.business_url);
}
Ok(())
}
2단계의 Maven 프로젝트에서 이 예제를 src/main/java/Places.java로 저장하고 mvn compile exec:java -Dexec.mainClass=Places을 실행합니다.
import com.microsoft.webiq.WebIQClient;
import com.microsoft.webiq.models.PlaceItem;
import com.microsoft.webiq.models.PlacesResponse;
import com.microsoft.webiq.resources.PlacesSearchOptions;
public class Places {
public static void main(String[] args) {
try (WebIQClient client = WebIQClient.withApiKey(System.getenv("WEBIQ_API_KEY"))) {
PlacesResponse places = client.places.search("coffee in Seattle",
PlacesSearchOptions.builder().maxResults(5)
.language("en").region("US")
.location("lat:47.6062;long:-122.3321").build());
if (places.getPlaceResults() != null) {
for (PlaceItem place : places.getPlaceResults()) {
System.out.println(place.getName() + " " + place.getBusinessUrl());
}
}
}
}
}
2단계의 .NET 콘솔 프로젝트에서 이 예제를 Program.cs로 저장하고 dotnet run를 실행합니다.
using Microsoft.WebIQ;
string apiKey = Environment.GetEnvironmentVariable("WEBIQ_API_KEY")
?? throw new InvalidOperationException("Set WEBIQ_API_KEY before running this example.");
using var client = new WebIQClient(apiKey);
var places = await client.Places.SearchAsync("coffee in Seattle", request =>
{
request.MaxResults = 5;
request.Language = "en";
request.Region = "US";
request.Location = "lat:47.6062;long:-122.3321";
});
foreach (var place in places.PlaceResults ?? [])
Console.WriteLine($"{place.Name} {place.BusinessUrl}");
import os
import json
import requests
response = requests.post(
"https://api.microsoft.ai/v3/search/places",
headers={
"x-apikey": os.environ["WEBIQ_API_KEY"],
"content-type": "application/json",
},
json={
"query": "coffee in Seattle",
"maxResults": 5,
"language": "en",
"region": "US",
"location": "lat:47.6062;long:-122.3321",
},
timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
이 예제를 places.mjs(으)로 저장하고 node places.mjs를 사용하여 실행합니다.
const response = await fetch("https://api.microsoft.ai/v3/search/places", {
method: "POST",
headers: {
"x-apikey": process.env.WEBIQ_API_KEY,
"content-type": "application/json",
},
body: JSON.stringify({
query: "coffee in Seattle",
maxResults: 5,
language: "en",
region: "US",
location: "lat:47.6062;long:-122.3321",
}),
});
if (!response.ok) {
throw new Error(`Places failed: ${response.status} ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));
placeResults에서 결과를 읽습니다. 목록 및 개별 필드가 없을 수 있으므로 주소, 영업 시간 또는 기타 세부 정보를 사용하기 전에 누락된 값을 확인합니다.
Places API 참조를 참조하세요.
7. Auto를 사용하여 증거 검색
Web IQ에서 검색 원본을 선택하고 인용을 지원하는 형식화된 증거를 반환하려면 Auto를 사용합니다. 날짜, 위치 및 단위와 같은 관련 제약 조건을 유지하면서 완전한 자연어 질문을 합니다. 이러한 예제에서는 기본값을 사용하기 위해 mode를 생략하며 요청 시도당 60초를 허용합니다.
복잡한 질문에 대해 보다 포괄적인 검색이 필요한 경우 advanced를 Auto Advanced로 mode 설정합니다.
자동은 생성된 최종 답변이 아니라 애플리케이션에서 사용할 증거를 반환합니다. 각 증거 결과를 해당 결과 자체의 인용과 함께 읽으세요. 한 결과의 인용을 다른 결과에 대한 근거로 간주하지 마세요. SDK 예제에서는 2단계에 설치된 5개 SDK 모두 버전 1.2.1을 사용합니다.
엔드포인트:POST https://api.microsoft.ai/v3/auto
curl --request POST "https://api.microsoft.ai/v3/auto" \
--max-time 60 \
--header "x-apikey: $WEBIQ_API_KEY" \
--header "content-type: application/json" \
--data '{
"query": "What are the latest developments in retrieval-augmented generation?",
"maxResponseLength": 30000,
"maxCitations": 5
}'
import os
from webiq import WebIQClient
with WebIQClient(api_key=os.environ["WEBIQ_API_KEY"]) as client:
evidence = client.auto.search(
"What are the latest developments in retrieval-augmented generation?",
max_response_length=30000,
max_citations=5,
timeout=60.0,
)
for result in evidence.results or []:
print(result.evidence)
for citation in result.citations or []:
print(citation.title, citation.url)
이 예제를 auto.mts(으)로 저장하고 node auto.mts를 사용하여 실행합니다.
import { WebIQClient } from "@microsoft/webiq";
async function main() {
const client = new WebIQClient({ apiKey: process.env.WEBIQ_API_KEY });
try {
const evidence = await client.auto.search(
"What are the latest developments in retrieval-augmented generation?",
{ maxResponseLength: 30000, maxCitations: 5, timeout: 60_000 },
);
for (const result of evidence.results ?? []) {
console.log(result.evidence);
for (const citation of result.citations ?? []) {
console.log(citation.title, citation.url);
}
}
} finally {
await client.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
2단계에서 Tokio 설정을 사용합니다. 이 예제를 src/main.rs로 저장하고 cargo run를 실행하세요.
use webiq::{AutoSearchOptions, WebIqClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WebIqClient::new(std::env::var("WEBIQ_API_KEY")?)?;
let evidence = client.auto().search(
"What are the latest developments in retrieval-augmented generation?",
AutoSearchOptions::new()
.max_response_length(30000)
.max_citations(5)
.timeout(std::time::Duration::from_secs(60)),
).await?;
for result in evidence.results.unwrap_or_default() {
println!("{:?}", result.evidence);
for citation in result.citations.unwrap_or_default() {
println!("{:?} {:?}", citation.title, citation.url);
}
}
Ok(())
}
2단계의 Maven 프로젝트에서 이 예제를 src/main/java/Auto.java로 저장하고 mvn compile exec:java -Dexec.mainClass=Auto을 실행합니다.
import com.microsoft.webiq.WebIQClient;
import com.microsoft.webiq.models.AutoEvidenceCitation;
import com.microsoft.webiq.models.AutoEvidenceResult;
import com.microsoft.webiq.models.SearchAutoEvidenceResponse;
import com.microsoft.webiq.resources.AutoSearchOptions;
public class Auto {
public static void main(String[] args) {
try (WebIQClient client = WebIQClient.withApiKey(System.getenv("WEBIQ_API_KEY"))) {
SearchAutoEvidenceResponse evidence = client.auto.search(
"What are the latest developments in retrieval-augmented generation?",
AutoSearchOptions.builder()
.maxResponseLength(30000).maxCitations(5)
.timeout(java.time.Duration.ofSeconds(60)).build());
if (evidence.getResults() != null) {
for (AutoEvidenceResult result : evidence.getResults()) {
System.out.println(result.getEvidence());
if (result.getCitations() != null) {
for (AutoEvidenceCitation citation : result.getCitations()) {
System.out.println(citation.getTitle() + " " + citation.getUrl());
}
}
}
}
}
}
}
2단계의 .NET 콘솔 프로젝트에서 이 예제를 Program.cs로 저장하고 dotnet run를 실행합니다.
using Microsoft.WebIQ;
using System.Text.Json;
string apiKey = Environment.GetEnvironmentVariable("WEBIQ_API_KEY")
?? throw new InvalidOperationException("Set WEBIQ_API_KEY before running this example.");
using var client = new WebIQClient(apiKey);
var evidence = await client.Auto.SearchAsync(
"What are the latest developments in retrieval-augmented generation?",
request =>
{
request.MaxResponseLength = 30000;
request.MaxCitations = 5;
}, timeout: TimeSpan.FromSeconds(60));
foreach (var result in evidence.Results ?? [])
{
Console.WriteLine(JsonSerializer.Serialize(result.Evidence));
foreach (var citation in result.Citations ?? [])
Console.WriteLine($"{citation.Title} {citation.Url}");
}
import os
import json
import requests
response = requests.post(
"https://api.microsoft.ai/v3/auto",
headers={
"x-apikey": os.environ["WEBIQ_API_KEY"],
"content-type": "application/json",
},
json={
"query": "What are the latest developments in retrieval-augmented generation?",
"maxResponseLength": 30000,
"maxCitations": 5,
},
timeout=60,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))
이 예제를 auto.mjs(으)로 저장하고 node auto.mjs를 사용하여 실행합니다.
const response = await fetch("https://api.microsoft.ai/v3/auto", {
method: "POST",
signal: AbortSignal.timeout(60_000),
headers: {
"x-apikey": process.env.WEBIQ_API_KEY,
"content-type": "application/json",
},
body: JSON.stringify({
query: "What are the latest developments in retrieval-augmented generation?",
maxResponseLength: 30000,
maxCitations: 5,
}),
});
if (!response.ok) {
throw new Error(`Auto failed: ${response.status} ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));
성공적인 응답에는 results 배열이 포함됩니다. 각 결과는 형식화된 evidence 개체와 이를 뒷받침하는 citations 지원 정보를 쌍으로 연결합니다. 비어 있거나 없는 results 배열에는 처리할 증거가 없습니다. 증명 정보 유형, 응답 예제 및 요청 제한은 Auto API 참조 를 참조하세요.
8. 상거래를 사용하는 제품 검색(선택 사항)
상거래 API를 사용하여 쇼핑 쿼리에 대한 제품 및 판매자 오퍼를 찾습니다. 검색은 기본 판매자 오퍼가 포함된 순위별 제품을 반환하고, Offers는 한 제품에 대해 더 많은 오퍼를 반환하며, 제품 세부 정보는 제품의 제목, 설명 및 평점을 반환합니다.
메모
상거래 API는 프라이빗 미리 보기로 제공되며 전체 문서 액세스 권한이 있는 AppID에 포함됩니다. 액세스는 각 엔드포인트에 대해 별도로 사용하도록 설정됩니다. AppID에 해당 액세스 권한이 없는 경우, AppID와 함께 Web IQ 지원 요청(문제 유형 인증 및 액세스)을 엽니다.
엔드포인트:POST https://api.microsoft.ai/v3/search/commerce/products, POST https://api.microsoft.ai/v3/fetch/commerce/products/offers및 POST https://api.microsoft.ai/v3/fetch/commerce/products/details
이 단계에서는 REST 호출을 보여 줍니다. 페이지 맨 위에 있는 cURL, Python(REST) 또는 JavaScript(REST)를 선택하여 확인합니다.
제품 검색:
curl --request POST "https://api.microsoft.ai/v3/search/commerce/products" \
--header "x-apikey: $WEBIQ_API_KEY" \
--header "content-type: application/json" \
--data '{
"query": "wireless headphones",
"maxResults": 3,
"language": "en",
"region": "US"
}'
응답의 첫 번째 제품에서 해당 id, skuId, 그리고 첫 번째 오퍼의 id를 복사합니다.
아래의 SKU_ID, OFFER_ID 및 PRODUCT_ID를 바꾼 다음, 더 많은 오퍼와 제품 세부 정보를 조회합니다. 일부 제품은 id 또는 skuId 없이 오퍼만 반환합니다. offerId에는 Offers만 보내고, 제품 또는 SKU ID가 필요한 Product Details는 건너뛰세요.
curl --request POST "https://api.microsoft.ai/v3/fetch/commerce/products/offers" \
--header "x-apikey: $WEBIQ_API_KEY" \
--header "content-type: application/json" \
--data '{
"productId": "PRODUCT_ID",
"skuId": "SKU_ID",
"offerId": "OFFER_ID",
"language": "en",
"region": "US"
}'
curl --request POST "https://api.microsoft.ai/v3/fetch/commerce/products/details" \
--header "x-apikey: $WEBIQ_API_KEY" \
--header "content-type: application/json" \
--data '{
"productId": "PRODUCT_ID",
"skuId": "SKU_ID",
"language": "en",
"region": "US"
}'
import json
import os
import requests
BASE_URL = "https://api.microsoft.ai/v3"
HEADERS = {
"x-apikey": os.environ["WEBIQ_API_KEY"],
"content-type": "application/json",
}
MARKET = {"language": "en", "region": "US"}
def post(path, body):
response = requests.post(BASE_URL + path, headers=HEADERS, json=body, timeout=30)
response.raise_for_status()
return response.json()
search = post("/search/commerce/products", {"query": "wireless headphones", "maxResults": 3, **MARKET})
products = search.get("products") or []
if not products:
print("No matching products.")
else:
product = products[0]
first_offer = (product.get("offers") or [{}])[0]
ids = {"productId": product.get("id"), "skuId": product.get("skuId")}
ids = {key: value for key, value in ids.items() if value}
offer_ids = {**ids, "offerId": first_offer.get("id")} if first_offer.get("id") else ids
offers = post("/fetch/commerce/products/offers", {**offer_ids, **MARKET})
# Product Details needs a product id or SKU id; some products return only an offer.
details = post("/fetch/commerce/products/details", {**ids, **MARKET}) if ids else None
print(json.dumps({"product": product, "offers": offers, "details": details}, indent=2))
이 예제를 commerce.mjs(으)로 저장하고 node commerce.mjs를 사용하여 실행합니다.
const baseUrl = "https://api.microsoft.ai/v3";
const headers = {
"x-apikey": process.env.WEBIQ_API_KEY,
"content-type": "application/json",
};
const market = { language: "en", region: "US" };
async function post(path, body) {
const response = await fetch(`${baseUrl}${path}`, {
method: "POST",
headers,
body: JSON.stringify(body),
});
if (!response.ok) {
throw new Error(`${path} failed: ${response.status} ${await response.text()}`);
}
return response.json();
}
const search = await post("/search/commerce/products", {
query: "wireless headphones",
maxResults: 3,
...market,
});
const product = search.products?.[0];
if (!product) {
console.log("No matching products.");
} else {
const ids = {};
if (product.id) ids.productId = product.id;
if (product.skuId) ids.skuId = product.skuId;
const offerId = product.offers?.[0]?.id;
const offerIds = offerId ? { ...ids, offerId } : ids;
const offers = await post("/fetch/commerce/products/offers", { ...offerIds, ...market });
// Product Details needs a product id or SKU id; some products return only an offer.
const details = Object.keys(ids).length
? await post("/fetch/commerce/products/details", { ...ids, ...market })
: null;
console.log(JSON.stringify({ product, offers, details }, null, 2));
}
검색은 순위 순서대로 제품과 각 제품의 기본 판매자 오퍼를 반환합니다. maxResults는 오퍼가 아니라 제품을 제한합니다. 오퍼는 먼저 기본 오퍼를 반환한 다음 추가 오퍼를 반환합니다. 일치하는 항목이 없는 유효한 요청은 빈 offers 또는 200 OK 배열이 포함된 products을 반환합니다. 가격은 통화의 부 단위로 정수입니다: 39999 USD는 $399.99입니다.
사용자 또는 사용자를 대리하는 에이전트를 오퍼로 보내려면 해당 응답에서 반환된 오퍼의 clickUrl를 정확히 그대로 사용합니다.
displayUrl는 가맹점만 식별하므로 사용하지 말고, 링크를 다시 작성, 단축 또는 재사용하지 마세요. 모델이 링크를 재현하게 하지 말고 애플리케이션 코드에서 링크를 빌드합니다.
오퍼 링크 및 출처 표시 및 상거래 가이드를 참조하세요.
Troubleshooting
| Status | 확인할 사항 |
|---|---|
401 Unauthorized |
WEBIQ_API_KEY이 설정되어 있고 요청이 x-apikey 헤더에 이를 전송하는지 확인하세요. |
415 Unsupported Media Type |
전송합니다 content-type: application/json. |
429 Too Many Requests |
다시 시도하기 전에 기다렸다가 요청 빈도를 줄이세요. |
찾아보기 404 Not Found |
URL이 공개되어 있고 유효한지 확인하세요. 인덱싱된 콘텐츠를 사용할 수 없을 수 있는 경우 liveCrawl: "fallback"를 사용합니다. |
찾아보기 202 Accepted |
retryAfter에 있는 시간(ISO 8601 UTC 타임스탬프)이 될 때까지 기다린 다음 동일한 요청을 다시 보냅니다. |
자동 403 Forbidden |
프로필 관리의 허용된 서비스 아래에 Auto가 나열되어 있는지 확인합니다. 그렇지 않은 경우 AppID를 사용하여 Web IQ 지원 요청을 엽니다. |
그 외 오류가 발생하면 traceId를 저장하고 오류 처리를 참조하세요.
Web IQ 지원에 문의하려면 traceId 및 AppID를 포함하세요. AppID가 없는 경우에는 회사 이름과 Web IQ 리소스 이름을 포함하세요.
다음 단계
- 웹 검색 및 찾아보기 API 참조를 탐색합니다.
- Places를 사용하여 구조화된 로컬 비즈니스 데이터를 검색하거나 Auto를 사용하여 자동으로 선택된 근거 정보를 검색합니다.
- 상거래 가이드를 사용하여 쇼핑 환경을 구축합니다.
- Python, TypeScript, Rust, Java 및 .NET SDK를 사용합니다.
- Claude Code, Cursor 또는 VS Code에 MCP 서버를 설치합니다.
- Microsoft Entra ID를 사용하여 프로덕션 인증을 설정합니다.
- GitHub 웹 IQ 코드 샘플에서 전체 예제를 실행합니다.
- 웹 IQ를 사용하여 에이전트에 웹 기반 지식을 통합하는 교육 모듈을 수강하세요.
- 실제 인텔리전스로 에이전트 그라운딩, Microsoft IQ 시리즈의 Web IQ 에피소드를 보세요.