---
openapi: 3.0.0
info:
  title: Baidu AI Mode API
  description: Get Baidu AI Mode answers as structured JSON. To continue an eligible
    answer, pass pagination.conversation_token with the next question. Continuation
    is available for the default model without deep_search. Deep search is supported
    only by the default model.
  version: 1.0.0
servers:
- url: https://www.searchapi.io/api/v1
paths:
  "/search":
    get:
      summary: Baidu AI Mode Search
      security:
      - ApiKeyAuth: []
      - ApiKeyQuery: []
      parameters:
      - name: engine
        in: query
        required: true
        description: Set to baidu_ai_mode.
        schema:
          type: string
          enum:
          - baidu_ai_mode
      - name: q
        in: query
        required: true
        description: The question to send to Baidu AI Mode, up to 20000 characters.
          The limit counts UTF-16 code units; a supplementary character such as an
          emoji counts as two.
        schema:
          type: string
          maxLength: 20000
      - name: model
        in: query
        required: false
        description: The model to use. A follow-up keeps its conversation model.
        schema:
          type: string
          enum:
          - smartMode
          - ERINE-5.1
          default: smartMode
      - name: deep_search
        in: query
        required: false
        description: Enable deep search with the default model. Omit for conversation
          continuation.
        schema:
          type: string
          enum:
          - 'true'
      - name: conversation_token
        in: query
        required: false
        description: Use pagination.conversation_token from a fresh response to continue
          the conversation. Omit model and deep_search on follow-up requests.
        schema:
          type: string
          maxLength: 4096
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/SearchResponse"
        '400':
          description: Validation Error. There is an issue with query parameters,
            such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been
            exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchMetadata:
      type: object
      required:
      - status
      - created_at
      properties:
        id:
          type: string
          description: Unique identifier for the search request
        status:
          type: string
          description: Status of the search request
        created_at:
          type: string
          format: date-time
          description: Timestamp when the search was created
        request_time_taken:
          type: number
          description: Time taken to make the request in seconds
        parsing_time_taken:
          type: number
          description: Time taken to parse the results in seconds
        total_time_taken:
          type: number
          description: Total time taken for the search in seconds
        request_url:
          type: string
          description: Upstream URL used for this search
        html_url:
          type: string
          description: URL to view the raw event stream
        json_url:
          type: string
          description: URL to view JSON results
    ErrorResponse:
      type: object
      required:
      - error
      properties:
        error:
          type: string
          description: Error message describing what went wrong
    SearchResponse:
      type: object
      properties:
        search_metadata:
          "$ref": "#/components/schemas/SearchMetadata"
        search_parameters:
          "$ref": "#/components/schemas/SearchParameters"
        error:
          type: string
          description: Message saying why Baidu AI Mode returned no answer.
        text_blocks:
          type: array
          description: The answer split into structured blocks.
          items:
            "$ref": "#/components/schemas/AiAnswerTextBlock"
        markdown:
          type: string
          description: The answer in Markdown.
        inline_images:
          type: array
          description: Images Baidu shows with the answer, from web pages or generated
            for it.
          items:
            type: object
            properties:
              title:
                type: string
                description: Image title.
              link:
                type: string
                description: The destination URL.
              original:
                type: string
                description: Full-size image URL.
              thumbnail:
                type: string
                description: Thumbnail image URL.
              width:
                type: integer
                description: Image width in pixels.
              height:
                type: integer
                description: Image height in pixels.
            additionalProperties: false
        web_results:
          type: array
          description: The pages retrieved for the answer.
          items:
            type: object
            properties:
              position:
                type: integer
                description: The position in the result collection.
              title:
                type: string
                description: Page title.
              link:
                type: string
                description: The destination URL.
              source:
                type: string
                description: Name of the website or publisher of the page.
              snippet:
                type: string
                description: Excerpt of the page as plain text.
              favicon:
                type: string
                description: Favicon URL of the website.
              is_global:
                type: boolean
                description: Whether the page came from Baidu's global search.
              trust:
                type: object
                description: Baidu's credibility tag on the page.
                properties:
                  label:
                    type: string
                    description: Text of the credibility tag.
                additionalProperties: false
              thumbnail:
                type: string
                description: Thumbnail image URL of the page.
              source_link:
                type: string
                description: URL of the publisher's profile page.
            additionalProperties: false
        ads:
          type: array
          description: Ads Baidu shows above or below the answer.
          items:
            type: object
            properties:
              position:
                type: integer
                description: The position in the result collection.
              id:
                type: string
                description: Baidu's identifier for the ad.
              block_position:
                type: string
                description: Position of the ad block relative to the answer, top
                  for above it and bottom for below it.
              title:
                type: string
                description: Ad title.
              snippet:
                type: string
                description: Ad description text.
              link:
                type: string
                description: The destination URL.
              tracking_link:
                type: string
                description: Baidu redirect URL that leads to the ad's landing page.
              thumbnail:
                type: string
                description: Thumbnail image URL of the ad.
              is_official:
                type: boolean
                description: Whether Baidu shows its official site badge on the ad.
              source:
                type: string
                description: Advertiser name.
              price:
                type: string
                description: Price as shown on the ad, with its currency symbol and
                  unit.
            additionalProperties: false
        related_questions:
          type: array
          description: The follow-up questions Baidu suggests after the answer.
          items:
            type: object
            properties:
              question:
                type: string
                description: Suggested follow-up question text.
              label:
                type: string
                description: Sentence of the answer's closing offer that suggests
                  the question.
            additionalProperties: false
        search_queries:
          type: array
          description: The web searches Baidu ran for the answer.
          items:
            type: string
            description: A search query.
        tools:
          type: array
          description: The tools Baidu called for the answer.
          items:
            type: object
            properties:
              id:
                type: string
                description: Baidu's identifier for the tool.
              name:
                type: string
                description: Tool name.
              type:
                type: string
                description: Baidu's category for the tool.
              logo:
                type: string
                description: Tool logo image URL.
            additionalProperties: false
        response_metadata:
          type: object
          description: Details about the answer.
          properties:
            conversation_id:
              type: string
              description: Baidu's identifier for the conversation.
            message_id:
              type: string
              description: Baidu's identifier for the answer.
            is_web_search_performed:
              type: boolean
              description: Whether Baidu searched the web for the answer.
            model:
              type: string
              description: Baidu's name for the model that wrote the answer.
          additionalProperties: false
        pagination:
          type: object
          description: How to continue the conversation.
          properties:
            conversation_token:
              type: string
              description: The token to pass with the next question.
          additionalProperties: false
        cards:
          type: array
          description: Structured cards Baidu shows with the answer.
          items:
            oneOf:
            - type: object
              properties:
                type:
                  type: string
                  description: The card type, always weather.
                  enum:
                  - weather
                source:
                  type: object
                  description: Who supplied the card's data.
                  properties:
                    name:
                      type: string
                      description: Provider name.
                  additionalProperties: false
                location:
                  type: string
                  description: Forecast location name.
                current:
                  type: object
                  description: Current weather conditions.
                  properties:
                    temperature:
                      type: integer
                      description: Current temperature, in the unit named by `unit`.
                    unit:
                      type: string
                      description: Temperature unit for `temperature`, `feels_like`
                        and the forecast `high` and `low`.
                    condition:
                      type: string
                      description: Current condition text.
                    feels_like:
                      type: integer
                      description: Apparent temperature, in the unit named by `unit`.
                    humidity:
                      type: integer
                      description: Relative humidity in percent.
                    pressure:
                      type: number
                      description: Atmospheric pressure, in the unit named by `pressure_unit`.
                    pressure_unit:
                      type: string
                      description: Pressure unit.
                      enum:
                      - hPa
                    uv_index:
                      type: integer
                      description: Current UV index.
                    wind_direction:
                      type: string
                      description: Direction the wind blows from.
                    air_quality:
                      type: object
                      description: Current air quality.
                      properties:
                        aqi:
                          type: integer
                          description: Air quality index.
                        description:
                          type: string
                          description: Air quality level Baidu gives for the index.
                      additionalProperties: false
                  additionalProperties: false
                forecast:
                  type: array
                  description: Daily forecast entries.
                  items:
                    type: object
                    properties:
                      date:
                        type: string
                        description: Forecast day as an ISO 8601 date.
                      day_of_week:
                        type: string
                        description: English day name for `date`.
                      high:
                        type: integer
                        description: High temperature, in the unit named by `current.unit`.
                      low:
                        type: integer
                        description: Low temperature, in the unit named by `current.unit`.
                      condition:
                        type: string
                        description: Daytime forecast condition text.
                      night_condition:
                        type: string
                        description: Nighttime forecast condition text.
                      condition_icon:
                        type: string
                        description: Baidu's icon slug for the daytime condition.
                      humidity:
                        type: integer
                        description: Relative humidity in percent.
                      pressure:
                        type: number
                        description: Atmospheric pressure, in the unit named by `pressure_unit`.
                      pressure_unit:
                        type: string
                        description: Pressure unit.
                        enum:
                        - hPa
                      precipitation_chance:
                        type: integer
                        description: Daytime chance of precipitation in percent.
                      wind_direction:
                        type: string
                        description: Direction the wind blows from during the day.
                      air_quality:
                        type: object
                        description: Air quality for the day.
                        properties:
                          aqi:
                            type: integer
                            description: Air quality index.
                          description:
                            type: string
                            description: Air quality level Baidu gives for the index.
                        additionalProperties: false
                      sunrise:
                        type: string
                        description: Sunrise time at the location, as HH:MM.
                      sunset:
                        type: string
                        description: Sunset time at the location, as HH:MM.
                      moon_phase:
                        type: string
                        description: Moon phase name as Baidu writes it.
                      hourly:
                        type: array
                        description: Hour-by-hour readings that fall on the day.
                        items:
                          type: object
                          properties:
                            time:
                              type: string
                              description: Local time of the reading, as YYYY-MM-DD
                                HH:MM.
                            temperature:
                              type: integer
                              description: Temperature in the card's `current.unit`.
                            precipitation_chance:
                              type: integer
                              description: Chance of precipitation in percent.
                            wind_direction:
                              type: string
                              description: Direction the wind blows from.
                            wind_force:
                              type: string
                              description: Wind force grade as Baidu writes it, such as 2级.
                            uv_index:
                              type: integer
                              description: UV index.
                            uv_level:
                              type: string
                              description: UV exposure level Baidu gives for the index.
                          additionalProperties: false
                    additionalProperties: false
              additionalProperties: false
              required:
              - type
            - type: object
              properties:
                type:
                  type: string
                  description: The card type, always finance.
                  enum:
                  - finance
                symbol:
                  type: string
                  description: Ticker symbol.
                name:
                  type: string
                  description: Company or instrument name.
                price:
                  type: number
                  description: Latest price.
                change:
                  type: number
                  description: Absolute price change.
                change_percent:
                  type: number
                  description: Percent price change.
                price_open:
                  type: number
                  description: Opening price.
                price_high:
                  type: number
                  description: Intraday high price.
                price_low:
                  type: number
                  description: Intraday low price.
                previous_close:
                  type: number
                  description: Closing price of the previous trading day.
                exchange:
                  type: string
                  description: Listing exchange.
                price_52w_high:
                  type: number
                  description: 52-week high price.
                price_52w_low:
                  type: number
                  description: 52-week low price.
                pe_ratio:
                  type: number
                  description: Price/earnings ratio.
                market_cap:
                  type: number
                  description: Approximate market capitalization, expanded from the
                    abbreviated figure Baidu shows.
                logo:
                  type: string
                  description: Instrument logo image URL.
              additionalProperties: false
              required:
              - type
            - "$ref": "#/components/schemas/RawCard"
        disclaimer:
          type: string
          description: The notice Baidu shows under the answer.
        inline_videos:
          type: array
          description: Videos Baidu shows with the answer.
          items:
            type: object
            properties:
              position:
                type: integer
                description: The position in the result collection.
              title:
                type: string
                description: Video title.
              link:
                type: string
                description: The destination URL.
              video_id:
                type: string
                description: Baidu's identifier for the video.
              channel:
                type: string
                description: Name of the channel that published the video.
              duration:
                type: string
                description: Video duration in m:ss or h:mm:ss.
              thumbnail:
                type: string
                description: Thumbnail image URL of the video.
              channel_thumbnail:
                type: string
                description: Avatar image URL of the channel.
              key_moments:
                type: array
                description: Chapters in the video.
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Chapter title.
                    start_seconds:
                      type: integer
                      description: Start time of the chapter in seconds.
                  additionalProperties: false
            additionalProperties: false
        inline_shopping:
          type: array
          description: Priced products Baidu lists with the answer, including hotels
            and cars.
          items:
            type: object
            properties:
              position:
                type: integer
                description: The position in the result collection.
              title:
                type: string
                description: Product title.
              link:
                type: string
                description: The destination URL.
              tracking_link:
                type: string
                description: Redirect URL that leads to the product page at `link`.
              product_id:
                type: string
                description: Baidu's identifier for the product.
              thumbnail:
                type: string
                description: Thumbnail image URL of the product.
              price:
                type: string
                description: Product price as Baidu shows it, with its currency sign
                  and any unit.
              extracted_price:
                type: number
                description: Numeric value of `price`, approximate when the price
                  shown is abbreviated.
              seller:
                type: string
                description: Name of the shop selling the product on the marketplace.
              source:
                type: string
                description: Name of the marketplace or platform that lists the product.
              description:
                type: string
                description: Short caption Baidu shows with the product.
              rating:
                type: number
                description: Product rating on the platform that lists it.
            additionalProperties: false
        document:
          type: object
          description: The document Baidu wrote a long answer as, whose text is in
            `markdown`.
          properties:
            title:
              type: string
              description: Document title.
          additionalProperties: false
        thinking_steps:
          type: array
          description: The reasoning Baidu showed before the answer.
          items:
            type: object
            properties:
              description:
                type: string
                description: Text of the reasoning step.
            additionalProperties: false
      additionalProperties: false
      required:
      - search_metadata
      - search_parameters
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          enum:
          - baidu_ai_mode
          description: Set to baidu_ai_mode.
        q:
          type: string
          maxLength: 20000
          description: The question to send to Baidu AI Mode, up to 20000 characters.
            The limit counts UTF-16 code units; a supplementary character such as
            an emoji counts as two.
        model:
          type: string
          enum:
          - smartMode
          - ERINE-5.1
          default: smartMode
          description: The model to use. A follow-up keeps its conversation model.
        deep_search:
          type: boolean
          description: Whether deep search was requested.
        conversation_token:
          type: string
          maxLength: 4096
          description: Use pagination.conversation_token from a fresh response to
            continue the conversation. Omit model and deep_search on follow-up requests.
    AiAnswerTextBlock:
      type: object
      required:
      - type
      properties:
        type:
          type: string
          enum:
          - header
          - paragraph
          - unordered_list
          - ordered_list
          - table
          - code_blocks
          description: Type of content block.
        answer:
          type: string
          description: Text of a header, paragraph or list item, with inline code
            kept in backticks.
        items:
          type: array
          description: Nested blocks within a list or list item.
          items:
            "$ref": "#/components/schemas/AiAnswerTextBlock"
        table:
          type: object
          description: Table data (for table type)
          required:
          - headers
          - rows
          properties:
            headers:
              type: array
              description: Table header row; cells keep inline-code backticks like
                `answer`
              items:
                type: string
            rows:
              type: array
              description: Table data rows; cells keep inline-code backticks like
                `answer`
              items:
                type: array
                items:
                  type: string
        language:
          type: string
          description: Programming language (for code_blocks type)
        code:
          type: string
          description: Code content (for code_blocks type)
    RawCard:
      type: object
      description: A card with no schema of its own, with the source's payload under
        `raw`.
      required:
      - type
      - raw
      additionalProperties: false
      properties:
        type:
          type: string
          description: Provider card type (singular snake_case), never a known canonical
            type
          not:
            enum:
            - weather
            - finance
        raw:
          type: object
          description: Provider-native card payload, preserved as-is; never empty
          minProperties: 1
