Chat completions interface enhanced with Web search functionality for real-time web information.
Overview
The Web Search interface allows AI models to access real-time web information when generating responses. This is particularly useful for queries that require up-to-date information.
Authentication
All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Request Parameters
ID of the model to use. Models supporting Web search include GPT models with search capabilities.
A list of messages comprising the conversation.
Sampling temperature between 0 and 2. Higher values make output more random, lower values make it more focused.
Maximum number of tokens to generate.
Whether to stream responses.
Whether to enable Web search functionality.
Request Example
curl -X POST https://api.example.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4-web",
"messages": [
{"role": "user", "content": "What are today news headlines?"}
],
"web_search": true,
"temperature": 0.7
}'
Response Example
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4-web",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Based on the latest web search results, today's main news headlines include..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 150,
"total_tokens": 165
}
}
Response Fields
Unique identifier for the completion.
Object type, which is chat.completion.
Unix timestamp of when the completion was created.
List of completion choices.
Usage statistics for the request.
Parameters
| Parameter | Type | Required | Default | Description |
|---|
| model | string | Yes | - | ID of the model to use |
| messages | array | Yes | - | List of messages in the conversation |
| temperature | number | No | 1 | Sampling temperature (0-2) |
| max_tokens | integer | No | - | Maximum tokens to generate |
| stream | boolean | No | false | Enable streaming responses |
| web_search | boolean | No | true | Enable Web search |