claude-opus-4-7
Web Search
POST
/
v1
/
messages
Authorization
- Auth Type:
Bearer Auth(In:header) - Format:
Authorization: Bearer <YOUR_API_KEY> - Description: Use
Bearer <YOUR_API_KEY>. Format:Authorization: Bearer sk-xxxxxx. - API Key: where API Key is your AGCloud API KEY
Show Sync Responses
Show Sync Responses
Show Async Responses
Show Async Responses
Show Streaming Responses
Show Streaming Responses
Async Chat Response Field Description
| Field | Type | Range | Description |
|---|---|---|---|
id | string | - | The current chat task id. |
object | string | - | The type of object returned by the API. In this case it is always task. |
status | string | pending processing success failed | Current status of the task. |
created_at | number | - | Unix timestamp (in seconds) indicating when the task was created. |
Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | ✅ | claude-opus-4-6 | The model ID to use for this request. |
messages | string | array<object> | ✅ | - | An array of message objects representing the conversation history. |
max_tokens | integer | ✅ | 1024 | The maximum number of tokens the model can generate in the response. Range 1-32000 |
tools | array<object> | ✅ | - | Array of tool objects. For web search, must include the web_search tool configuration with type web_search_20250305. |
async | boolean | - | false | Whether to return an asynchronous response. Only supported for non-streaming requests. See Tools. |
stream | boolean | - | false | If true, returns a stream of server-sent events (SSE) as the response is generated. |
system | string | array<object> | - | - | System prompt that sets the behavior and context for the assistant. |
temperature | number | - | 1.0 | Controls the randomness of the output. Lower values produce more focused responses, higher values produce more creative outputs. Range 0.0-1.0 |
top_p | number | - | 1.0 | Nucleus sampling parameter. The model considers tokens with top_p cumulative probability mass. Range 0.0-1.0 |
top_k | integer | - | - | Limits token selection to the K most probable tokens at each step. |
stop_sequences | array<string> | - | - | An array of strings that will stop generation when encountered. |
Tools Object Structure
| Field | Type | Required | Description |
|---|---|---|---|
type | string | ✅ | The tool type. Must be web_search_20250305 for web search. |
name | string | ✅ | Override the default tool name. Default: web_search. |
max_uses | integer | - | Maximum number of web search requests allowed per model turn. Range 1-20. |
allowed_domains | array<string> | - | Only include search results from these domains. Cannot be used with blocked_domains. |
blocked_domains | array<string> | - | Never include search results from these domains. Cannot be used with allowed_domains. |
user_location | object | - | Approximate user location for localized search results. |
>user_location.type | string | - | Must be approximate if provided. |
>user_location.city | string | - | City name (e.g., "San Francisco"). |
>user_location.region | string | - | Region or state (e.g., "California"). |
>user_location.country | string | - | Two-letter country code (e.g., "US"). |
>user_location.timezone | string | - | IANA timezone (e.g., "America/New_York"). |
{
"type": "web_search_20250305",
"name": "web_search",
"max_uses": 5,
"allowed_domains": ["example.com", "trusteddomain.org"],
"user_location": {
"type": "approximate",
"city": "San Francisco",
"region": "California",
"country": "US",
"timezone": "America/Los_Angeles"
}
}
Max Uses
Themax_uses parameter limits the number of searches performed. If Claude attempts more searches than allowed, the web_search_tool_result will be an error with the max_uses_exceeded error code.
Domain Filtering
When using domain filters:- Domains should not include the HTTP/HTTPS scheme (use
example.cominstead ofhttps://example.com) - Subdomains are automatically included (
example.comcoversdocs.example.com) - Specific subdomains restrict results to only that subdomain (
docs.example.comreturns only results from that subdomain, not fromexample.comorapi.example.com) - Subpaths are supported (
example.com/blog) - You can use either
allowed_domainsorblocked_domains, but not both in the same request - Request-level domain restrictions must be compatible with organization-level domain restrictions configured in the Console