Web Search API
The Web Search API provides real-time internet information retrieval, enabling AI models to access the latest web content for more accurate and up-to-date responses. The API is compatible with the OpenAI Chat Completions format for seamless integration.
Try it Online
Quick Start
bash
curl -X POST https://open.dieyuyun.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "web-search",
"messages": [
{"role": "user", "content": "What are the latest developments in AI?"}
]
}'Endpoint
| Property | Value |
|---|---|
| Method | POST |
| Path | /v1/chat/completions |
| Base URL | https://open.dieyuyun.com |
| Protocol | OpenAI-compatible |
Authentication
All requests must include your API key in the header:
http
Authorization: Bearer YOUR_API_KEYRequest Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | — | Model identifier, always web-search |
| messages | array | Yes | — | Message list, compatible with OpenAI message format |
| stream | boolean | No | false | Enable streaming output |
| max_tokens | integer | No | 2048 | Maximum output tokens |
Message Roles
| Role | Description |
|---|---|
| system | System prompt (optional) |
| user | User message |
| assistant | Assistant reply (for multi-turn scenarios) |
Request Examples
bash
curl -X POST https://open.dieyuyun.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "web-search",
"messages": [
{"role": "user", "content": "What are the latest breakthroughs in AI research?"}
],
"max_tokens": 4096
}'python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://open.dieyuyun.com/v1"
)
response = client.chat.completions.create(
model="web-search",
messages=[
{"role": "user", "content": "What are the latest breakthroughs in AI research?"}
],
max_tokens=4096
)
print(response.choices[0].message.content)javascript
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://open.dieyuyun.com/v1',
})
const response = await client.chat.completions.create({
model: 'web-search',
messages: [{ role: 'user', content: 'What are the latest breakthroughs in AI research?' }],
max_tokens: 4096,
})
console.log(response.choices[0].message.content)Response Format
Standard Response
json
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1705312200,
"model": "web-search",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Based on the latest internet information, here are the recent important AI research breakthroughs:\n\n1. ...\n\n**Sources:**\n- [Source 1](https://example.com/article1)\n- [Source 2](https://example.com/article2)"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 580,
"total_tokens": 605
}
}Streaming Output
Set stream: true to receive responses in Server-Sent Events (SSE) format:
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Based"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" on"},"finish_reason":null}]}
data: [DONE]Use Cases
| Use Case | Description |
|---|---|
| Real-time information | Retrieve news, stock market data, weather, and other live info |
| Knowledge gap filling | Supplement model knowledge beyond its training cutoff date |
| Fact checking | Verify specific facts, data points, or citations |
| Multi-turn search dialog | Continuously search and follow up on topics across a conversation |
Best Practices
- Ask specific questions: Precise queries yield more accurate search results — avoid overly broad questions
- Multi-turn follow-up: Use conversational turns to drill deeper, focusing each query on a specific aspect
- Use system prompts: Set the response style via the system message, e.g., "Answer concisely and include sources"
- Enable streaming: For user-facing applications (e.g., chatbots), enable
stream: trueto reduce time-to-first-token - Control token usage: Set appropriate
max_tokensto avoid overly long responses
Pricing
Web search is billed per request at ¥0.02 per call, regardless of response length. See Pricing for details.
Rate Limits
| Limit | Value |
|---|---|
| Requests/min | 30 RPM |
| Concurrent | 5 |
Need higher limits? Submit a ticket in the Console.