> This page is for version Latest (default).
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.coactive.ai/latest/llms.txt

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

# Hybrid Search

POST https://api.coactive.ai/api/v1/search/text-to-hybrid-search
Content-Type: application/json

Search images using a text query that scores results against both visual content and text metadata (titles, captions, descriptions, and other text fields).This endpoint is in beta and requires special access, please contact the support team.

Reference: https://docs.coactive.ai/api-reference/api-reference/search/search/hybrid-search

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a HybridSearchRequest.

- `dataset_id` (string, required) — The unique identifier for the dataset
- `text_query` (string, required) — The text query to search for
- `negative_text` (string, optional, nullable) — Optional text describing what to exclude from search results. Steers the visual query embedding away from this direction.
- `limit` (integer, optional, default: 100) — Max number of items to return from hybrid search
- `datetime_filter` (DateTimeRangeInclusiveClause, optional, nullable) — Filter results to only include items with timestamps within this datetime range
- `skip_moderation` (boolean, optional, default: false) — Skip content moderation if enabled
- `moderation_score_type` (enum, optional) — Type of moderation scores to return when moderation is enabled.probability returns scores 0-1 using BGE Reranker model.level returns scores 0-5 using OpenAI model.This does not enable/disable moderation - use skip_moderation for that.
  - Allowed values: `probability`, `level`

## Response

### 200

Successful Response

- `data` (list of HybridSearchImage, required) — The results from hybrid search

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### DateTimeRangeInclusiveClause

- `key` (string, required)
- `operator` ("DateTimeRangeInclusive", required)
- `start_utc_epoch` (double, optional, nullable)
- `end_utc_epoch` (double, optional, nullable)

### HybridSearchImage

An image asset response

- `created_user_id` (string, required) — The user that created the resource
- `created_dt` (string, required) — The created datetime of the resource
- `updated_user_id` (string, required) — The user that last updated the resource
- `updated_dt` (string, required) — The datetime the resource was last updated
- `coactive_image_id` (string, required) — The coactive image id
- `relevance_score` (double, required) — The relevance score of the image
- `path` (string, optional, nullable) — The original path of the image
- `metadata` (map from string to any, optional, nullable) — The user provided metadata for the image
- `moderation_score` (double, optional, nullable) — The moderation score of the image

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "dataset_id": "c40276f0-024b-4a3f-b3e6-dcf0d304843e",
  "text_query": "Dog"
}
```

**Response**

```json
{
  "data": [
    {
      "created_user_id": "user_example",
      "created_dt": "2018-09-11T15:11:45.456777Z",
      "updated_user_id": "user_example",
      "updated_dt": "2018-09-11T15:11:45.456777Z",
      "coactive_image_id": "a6894d72-612d-4c20-b4d0-8f3f21c2bb10",
      "relevance_score": 0.5,
      "path": "s3://your-s3-bucket/path/to/video.mp4",
      "metadata": {
        "artist": "bufo frog"
      },
      "moderation_score": 0.1
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.coactive.ai/api/v1/search/text-to-hybrid-search"

payload = {
    "dataset_id": "c40276f0-024b-4a3f-b3e6-dcf0d304843e",
    "text_query": "Dog"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.coactive.ai/api/v1/search/text-to-hybrid-search';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"dataset_id":"c40276f0-024b-4a3f-b3e6-dcf0d304843e","text_query":"Dog"}'
};

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

```go
package main

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

func main() {

	url := "https://api.coactive.ai/api/v1/search/text-to-hybrid-search"

	payload := strings.NewReader("{\n  \"dataset_id\": \"c40276f0-024b-4a3f-b3e6-dcf0d304843e\",\n  \"text_query\": \"Dog\"\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
require 'uri'
require 'net/http'

url = URI("https://api.coactive.ai/api/v1/search/text-to-hybrid-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  \"dataset_id\": \"c40276f0-024b-4a3f-b3e6-dcf0d304843e\",\n  \"text_query\": \"Dog\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.coactive.ai/api/v1/search/text-to-hybrid-search")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"dataset_id\": \"c40276f0-024b-4a3f-b3e6-dcf0d304843e\",\n  \"text_query\": \"Dog\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.coactive.ai/api/v1/search/text-to-hybrid-search', [
  'body' => '{
  "dataset_id": "c40276f0-024b-4a3f-b3e6-dcf0d304843e",
  "text_query": "Dog"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.coactive.ai/api/v1/search/text-to-hybrid-search");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"dataset_id\": \"c40276f0-024b-4a3f-b3e6-dcf0d304843e\",\n  \"text_query\": \"Dog\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "dataset_id": "c40276f0-024b-4a3f-b3e6-dcf0d304843e",
  "text_query": "Dog"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.coactive.ai/api/v1/search/text-to-hybrid-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()
```