> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ninjachat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Web Search

> Search the web, academic papers, or news with an optional AI-generated answer that synthesizes the results. Cost: $0.05 per query.



## OpenAPI

````yaml /openapi.json post /api/v1/search
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Access 40+ AI models through a unified API — chat, image generation, video
    generation, and web search. One API key, one endpoint per type, just change
    the `model` parameter.
servers:
  - url: https://www.ninjachat.ai
security:
  - bearerAuth: []
paths:
  /api/v1/search:
    post:
      tags:
        - Endpoints
      summary: Web Search
      description: >-
        Search the web, academic papers, or news with an optional AI-generated
        answer that synthesizes the results. Cost: $0.05 per query.
      operationId: searchWeb
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - query
              properties:
                query:
                  type: string
                  minLength: 1
                  maxLength: 2000
                  description: Search query.
                group:
                  type: string
                  enum:
                    - web
                    - academic
                    - news
                  default: web
                  description: Search source.
                max_results:
                  type: integer
                  minimum: 1
                  maximum: 20
                  default: 10
                  description: Number of results to return.
                search_depth:
                  type: string
                  enum:
                    - basic
                    - advanced
                  default: basic
                  description: basic for fast results, advanced for deeper search.
                topic:
                  type: string
                  enum:
                    - general
                    - news
                    - finance
                  default: general
                  description: Topic filter.
                include_answer:
                  type: boolean
                  default: true
                  description: Generate an AI-synthesized answer from the results.
                include_images:
                  type: boolean
                  default: false
                  description: Include image results.
            example:
              query: latest developments in AI safety
              group: web
              max_results: 10
              search_depth: basic
              include_answer: true
              include_images: false
      responses:
        '200':
          description: Search results.
          content:
            application/json:
              schema:
                type: object
                properties:
                  query:
                    type: string
                  answer:
                    type: string
                    description: AI-synthesized answer (if include_answer is true).
                  sources:
                    type: array
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                        title:
                          type: string
                        content:
                          type: string
                        published_date:
                          type: string
                  images:
                    type: array
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                        description:
                          type: string
                  follow_up_questions:
                    type: array
                    items:
                      type: string
                  cost:
                    $ref: '#/components/schemas/Cost'
                  metadata:
                    type: object
                    properties:
                      group:
                        type: string
                      search_depth:
                        type: string
                      results_count:
                        type: integer
                      latency_ms:
                        type: integer
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient credits.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Cost:
      type: object
      properties:
        this_request:
          type: string
          example: $0.006
          description: Cost of this request.
    ErrorResponse:
      type: object
      description: >-
        OpenAI-compatible error. The top-level `message`, `code`, and
        `request_id` mirror fields inside `error` for convenience.
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error description.
            type:
              type: string
              description: >-
                Error category: invalid_request_error, authentication_error,
                rate_limit_error, insufficient_quota, or api_error.
            code:
              type: string
              description: Machine-readable error code.
            param:
              type: string
              nullable: true
              description: The request parameter that caused the error, if any.
        message:
          type: string
          description: Same as error.message.
        code:
          type: string
          description: Same as error.code.
        request_id:
          type: string
          description: Unique request ID, useful when contacting support.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key starting with nj_sk_

````