> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.usescout.sh/llms.txt.
> For full documentation content, see https://docs.usescout.sh/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.usescout.sh/_mcp/server.

# Chat completion

POST https://core.usescout.sh/v1/chat/completions
Content-Type: application/json

OpenAI-compatible chat completions, grounded in live web search.

When `web_search` is false (or `tools` is false) we skip the SERP
fetch entirely and route straight to Claude — sub-1s for simple chat.
When `stream` is true we return Server-Sent Events with OpenAI-style
chat.completion.chunk frames terminated by `data: [DONE]`.

Reference: https://docs.usescout.sh/api-reference/scout/chat/completions-v-1-chat-completions-post

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Scout
  version: 1.0.0
paths:
  /v1/chat/completions:
    post:
      operationId: completions-v-1-chat-completions-post
      summary: Chat completion
      description: |-
        OpenAI-compatible chat completions, grounded in live web search.

        When `web_search` is false (or `tools` is false) we skip the SERP
        fetch entirely and route straight to Claude — sub-1s for simple chat.
        When `stream` is true we return Server-Sent Events with OpenAI-style
        chat.completion.chunk frames terminated by `data: [DONE]`.
      tags:
        - subpackage_chat
      parameters:
        - name: Authorization
          in: header
          description: Your API key, sent as a Bearer token.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
servers:
  - url: https://core.usescout.sh
components:
  schemas:
    ChatMessage:
      type: object
      properties:
        role:
          type: string
          description: '''system'', ''user'' or ''assistant''.'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    ChatResponseFormatType:
      type: string
      enum:
        - text
        - json_object
        - json_schema
      default: text
      description: 'Output shape: free text, any JSON, or schema-conformant JSON.'
      title: ChatResponseFormatType
    ChatResponseFormat:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ChatResponseFormatType'
          description: 'Output shape: free text, any JSON, or schema-conformant JSON.'
        json_schema:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
          description: >-
            When type='json_schema', the OpenAI shape {name, schema, strict?}.
            The `schema` field is a JSON Schema the assistant's reply MUST
            conform to.
      description: OpenAI-compatible response_format. Subset we support.
      title: ChatResponseFormat
    ChatRequestTools:
      oneOf:
        - type: boolean
        - type: array
          items:
            type: object
            additionalProperties:
              description: Any type
      description: >-
        `false` disables Scout's built-in web search (pure chat). An array is
        accepted for OpenAI compatibility but client-defined tools are not yet
        wired up; Scout's built-in search is always available.
      title: ChatRequestTools
    ChatRequestStop:
      oneOf:
        - type: string
        - type: array
          items:
            type: string
      description: String or list of stop sequences. Forwarded as Anthropic stop_sequences.
      title: ChatRequestStop
    ChatRequest:
      type: object
      properties:
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: OpenAI-style messages (system / user / assistant).
        model:
          type:
            - string
            - 'null'
          description: Echoed back in the response; does not affect routing.
        stream:
          type: boolean
          default: false
          description: >-
            When true, return Server-Sent Events with OpenAI-style
            chat.completion.chunk frames terminated by `data: [DONE]`.
        response_format:
          oneOf:
            - $ref: '#/components/schemas/ChatResponseFormat'
            - type: 'null'
          description: >-
            Output format. text (default), json_object, or json_schema. For
            json_schema, pass {type:'json_schema', json_schema:{name, schema}}.
        temperature:
          type:
            - number
            - 'null'
          format: double
          description: OpenAI-range 0-2. Mapped to Anthropic's 0-1 range (clamped).
        top_p:
          type:
            - number
            - 'null'
          format: double
          description: Nucleus sampling cutoff. Forwarded to Anthropic.
        'n':
          type: integer
          default: 1
          description: Number of chat completions to generate. Capped at 4.
        tools:
          oneOf:
            - $ref: '#/components/schemas/ChatRequestTools'
            - type: 'null'
          description: >-
            `false` disables Scout's built-in web search (pure chat). An array
            is accepted for OpenAI compatibility but client-defined tools are
            not yet wired up; Scout's built-in search is always available.
        web_search:
          type: boolean
          default: true
          description: >-
            Explicit toggle for the built-in web grounding. Set to false for
            pure chat (sub-1s).
        seed:
          type:
            - integer
            - 'null'
          description: Deterministic sampling seed (forwarded when supported).
        max_tokens:
          type: integer
          default: 2048
          description: Max tokens in the response.
        stop:
          oneOf:
            - $ref: '#/components/schemas/ChatRequestStop'
            - type: 'null'
          description: >-
            String or list of stop sequences. Forwarded as Anthropic
            stop_sequences.
      required:
        - messages
      title: ChatRequest
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: Your API key, sent as a Bearer token.

```

## SDK Code Examples

```python Chat_completionsV1ChatCompletionsPost_example
import requests

url = "https://core.usescout.sh/v1/chat/completions"

payload = {
    "messages": [
        {
            "role": "user",
            "content": "What did Anthropic announce this week?"
        }
    ],
    "model": "scout-web"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Chat_completionsV1ChatCompletionsPost_example
const url = 'https://core.usescout.sh/v1/chat/completions';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"messages":[{"role":"user","content":"What did Anthropic announce this week?"}],"model":"scout-web"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Chat_completionsV1ChatCompletionsPost_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://core.usescout.sh/v1/chat/completions"

	payload := strings.NewReader("{\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What did Anthropic announce this week?\"\n    }\n  ],\n  \"model\": \"scout-web\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Chat_completionsV1ChatCompletionsPost_example
require 'uri'
require 'net/http'

url = URI("https://core.usescout.sh/v1/chat/completions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What did Anthropic announce this week?\"\n    }\n  ],\n  \"model\": \"scout-web\"\n}"

response = http.request(request)
puts response.read_body
```

```java Chat_completionsV1ChatCompletionsPost_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://core.usescout.sh/v1/chat/completions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What did Anthropic announce this week?\"\n    }\n  ],\n  \"model\": \"scout-web\"\n}")
  .asString();
```

```php Chat_completionsV1ChatCompletionsPost_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://core.usescout.sh/v1/chat/completions', [
  'body' => '{
  "messages": [
    {
      "role": "user",
      "content": "What did Anthropic announce this week?"
    }
  ],
  "model": "scout-web"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Chat_completionsV1ChatCompletionsPost_example
using RestSharp;

var client = new RestClient("https://core.usescout.sh/v1/chat/completions");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What did Anthropic announce this week?\"\n    }\n  ],\n  \"model\": \"scout-web\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Chat_completionsV1ChatCompletionsPost_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "messages": [
    [
      "role": "user",
      "content": "What did Anthropic announce this week?"
    ]
  ],
  "model": "scout-web"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://core.usescout.sh/v1/chat/completions")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```