Web Search
This document explains how to use the Web Search feature on the Infron platform.
Last updated
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://llm.onerouter.pro/v1"
)
response = client.chat.completions.create(
model="anthropic/claude-opus-4.6",
messages=[
{
"role": "user",
"content": "How is the weather in Beijing today?"
}
],
extra_body={
"web_search_options": {
"search_context_size": "high",
"user_location": {
"approximate": {
"timezone": "Asia/Shanghai",
"country": "CN",
"city": "Beijing"
}
}
}
}
)
print(response.json())curl -X POST "https://llm.onerouter.pro/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "anthropic/claude-opus-4.6",
"messages": [
{
"role": "user",
"content": "How is the weather in Beijing today?"
}
],
"web_search_options": {
"search_context_size": "high",
"user_location": {
"approximate": {
"timezone": "Asia/Shanghai",
"country": "CN",
"city": "Beijing"
}
}
}
}'{
"id": "msg_016gnzBRiQ1zuyGAdfMZFRaY",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": ".\n\nOverall, it's a cool and mostly pleasant early spring day in Beijing. A jacket or sweater is recommended, especially for the chilly morning and evening hours. Enjoy the sunshine! ☀️",
"refusal": null,
"role": "assistant",
"annotations": null,
"audio": null,
"function_call": null,
"tool_calls": null
}
}
],
"created": 1773060007,
"model": "anthropic/claude-opus-4.6",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": null,
"usage": {
"completion_tokens": 404,
"prompt_tokens": 12095,
"total_tokens": 12499,
"completion_tokens_details": null,
"prompt_tokens_details": {
"audio_tokens": null,
"cached_tokens": null
},
"input_tokens": 0,
"output_tokens": 0,
"ttft": 0,
"server_tool_use": {
"web_search_requests": ""
}
},
"request_id": "e42a26abb0f047339a5dc1081bf9e277"
}