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

# Search (AI Search)

POST {{baseUrl}}/api/ai/search
Content-Type: application/json

**What:** Turn a natural-language query into up to 50 real TMDB movies (Gemini proposes titles+years; each is resolved against TMDB).

**Auth:** Bearer token required. Spends 1 daily AI action on success.

**Body (JSON):**

| Field | Type | Required | Description | Example |
|---|---|---|---|---|
| query | string | yes | Natural-language search. Blank = 400. | `mind-bending sci-fi about dreams` |
| exclude_ids | array | no | TMDB ids on screen (Smart Reroll soft filter). | `[27205]` |

**Returns:** `data = [tmdbMovie]` (raw TMDB objects, no reason) + sibling `aiUsage`.

Reference: https://apidocs.movieknight.site/movie-knight-api/ai/search-ai-search

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/ai/search:
    post:
      operationId: search-ai-search
      summary: Search (AI Search)
      description: >-
        **What:** Turn a natural-language query into up to 50 real TMDB movies
        (Gemini proposes titles+years; each is resolved against TMDB).


        **Auth:** Bearer token required. Spends 1 daily AI action on success.


        **Body (JSON):**


        | Field | Type | Required | Description | Example |

        |---|---|---|---|---|

        | query | string | yes | Natural-language search. Blank = 400. |
        `mind-bending sci-fi about dreams` |

        | exclude_ids | array | no | TMDB ids on screen (Smart Reroll soft
        filter). | `[27205]` |


        **Returns:** `data = [tmdbMovie]` (raw TMDB objects, no reason) +
        sibling `aiUsage`.
      tags:
        - subpackage_ai
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AI_Search (AI Search)_Response_200'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiAiSearchRequestBadRequestError'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiAiSearchRequestTooManyRequestsError
        '502':
          description: Bad Gateway
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiAiSearchRequestBadGatewayError'
        '504':
          description: Gateway Timeout
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiAiSearchRequestGatewayTimeoutError'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
              required:
                - query
servers:
  - url: '{{baseUrl}}'
    description: '{{baseUrl}}'
components:
  schemas:
    ApiAiSearchPostResponsesContentApplicationJsonSchemaDataItems:
      type: object
      properties:
        id:
          type: integer
        adult:
          type: boolean
        title:
          type: string
        video:
          type: boolean
        overview:
          type: string
        genre_ids:
          type: array
          items:
            type: integer
        popularity:
          type: number
          format: double
        vote_count:
          type: integer
        poster_path:
          type: string
        release_date:
          type: string
          format: date
        vote_average:
          type: number
          format: double
        backdrop_path:
          type: string
        original_title:
          type: string
        original_language:
          type: string
      required:
        - id
        - adult
        - title
        - video
        - overview
        - genre_ids
        - popularity
        - vote_count
        - poster_path
        - release_date
        - vote_average
        - backdrop_path
        - original_title
        - original_language
      title: ApiAiSearchPostResponsesContentApplicationJsonSchemaDataItems
    ApiAiSearchPostResponsesContentApplicationJsonSchemaAiUsage:
      type: object
      properties:
        used:
          type: integer
        limit:
          type: integer
        remaining:
          type: integer
      required:
        - used
        - limit
        - remaining
      title: ApiAiSearchPostResponsesContentApplicationJsonSchemaAiUsage
    AI_Search (AI Search)_Response_200:
      type: object
      properties:
        ok:
          type: boolean
        data:
          type: array
          items:
            $ref: >-
              #/components/schemas/ApiAiSearchPostResponsesContentApplicationJsonSchemaDataItems
        aiUsage:
          $ref: >-
            #/components/schemas/ApiAiSearchPostResponsesContentApplicationJsonSchemaAiUsage
      required:
        - ok
        - data
        - aiUsage
      title: AI_Search (AI Search)_Response_200
    PostApiAiSearchRequestBadRequestError:
      type: object
      properties:
        ok:
          type: boolean
        error:
          type: string
      required:
        - ok
        - error
      title: PostApiAiSearchRequestBadRequestError
    PostApiAiSearchRequestTooManyRequestsError:
      type: object
      properties:
        ok:
          type: boolean
        code:
          type: string
        error:
          type: string
      required:
        - ok
        - code
        - error
      title: PostApiAiSearchRequestTooManyRequestsError
    PostApiAiSearchRequestBadGatewayError:
      type: object
      properties:
        ok:
          type: boolean
        error:
          type: string
      required:
        - ok
        - error
      title: PostApiAiSearchRequestBadGatewayError
    PostApiAiSearchRequestGatewayTimeoutError:
      type: object
      properties:
        ok:
          type: boolean
        error:
          type: string
      required:
        - ok
        - error
      title: PostApiAiSearchRequestGatewayTimeoutError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

```

## Examples



**Request**

```json
{
  "query": "mind-bending sci-fi movies about dreams"
}
```

**Response**

```json
{
  "ok": true,
  "data": [
    {
      "id": 27205,
      "adult": false,
      "title": "Inception",
      "video": false,
      "overview": "Cobb, a skilled thief who commits corporate espionage by infiltrating the subconscious of his targets, is offered a chance to regain his old life.",
      "genre_ids": [
        28,
        878,
        12
      ],
      "popularity": 95.13,
      "vote_count": 36219,
      "poster_path": "/oYuLEt3zVCKq57qu2F8dT7NIa6f.jpg",
      "release_date": "2010-07-15",
      "vote_average": 8.369,
      "backdrop_path": "/s3TBrRGB1iav7gFOCNx3H31MoES.jpg",
      "original_title": "Inception",
      "original_language": "en"
    },
    {
      "id": 550,
      "adult": false,
      "title": "Fight Club",
      "video": false,
      "overview": "A ticking-time-bomb insomniac and a slippery soap salesman channel primal male aggression into a shocking new form of therapy.",
      "genre_ids": [
        18
      ],
      "popularity": 65.482,
      "vote_count": 28543,
      "poster_path": "/pB8BM7pdSp6B6Ih7QZ4DrQ3PmJK.jpg",
      "release_date": "1999-10-15",
      "vote_average": 8.438,
      "backdrop_path": "/hZkgoQYus5vegHoetLkCJzb17zJ.jpg",
      "original_title": "Fight Club",
      "original_language": "en"
    }
  ],
  "aiUsage": {
    "used": 1,
    "limit": 5,
    "remaining": 4
  }
}
```

**SDK Code**

```python AI_Search (AI Search)_example
import requests

url = "https://{{baseurl}}/api/ai/search"

payload = { "query": "mind-bending sci-fi movies about dreams" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript AI_Search (AI Search)_example
const url = 'https://{{baseurl}}/api/ai/search';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"query":"mind-bending sci-fi movies about dreams"}'
};

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

```go AI_Search (AI Search)_example
package main

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

func main() {

	url := "https://{{baseurl}}/api/ai/search"

	payload := strings.NewReader("{\n  \"query\": \"mind-bending sci-fi movies about dreams\"\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 AI_Search (AI Search)_example
require 'uri'
require 'net/http'

url = URI("https://{{baseurl}}/api/ai/search")

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  \"query\": \"mind-bending sci-fi movies about dreams\"\n}"

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

```java AI_Search (AI Search)_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://{{baseurl}}/api/ai/search")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"query\": \"mind-bending sci-fi movies about dreams\"\n}")
  .asString();
```

```php AI_Search (AI Search)_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://{{baseurl}}/api/ai/search', [
  'body' => '{
  "query": "mind-bending sci-fi movies about dreams"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp AI_Search (AI Search)_example
using RestSharp;

var client = new RestClient("https://{{baseurl}}/api/ai/search");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"query\": \"mind-bending sci-fi movies about dreams\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift AI_Search (AI Search)_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["query": "mind-bending sci-fi movies about dreams"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://{{baseurl}}/api/ai/search")! 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()
```