Search API client for the Mosaia SDK

Provides universal search functionality across multiple resource types (agents, apps, tools, models) in the Mosaia platform.

This class provides a specialized search interface that allows searching across multiple resource types simultaneously with a single query.

import { Mosaia } from 'mosaia-node-sdk';

const mosaia = new Mosaia({ apiKey: 'your-api-key' });
const search = mosaia.search;

// Search across all resource types
const results = await search.query({
q: 'customer support',
limit: 10
});

console.log('Agents:', results.data.agents);
console.log('Apps:', results.data.apps);
console.log('Tools:', results.data.tools);
console.log('Models:', results.data.models);
// Search specific resource types
const results = await search.query({
q: 'AI assistant',
search_types: ['agent', 'app'],
limit: 5
});

// Or use search_type for single type
const agentResults = await search.query({
q: 'support bot',
search_type: 'agent',
limit: 10
});

Constructors

Methods

Constructors

  • Creates a new Search API client instance

    Initializes the search client with the appropriate endpoint URI. The search endpoint provides universal search across multiple resource types.

    Parameters

    • uri: string = ''

      Optional base URI path. If provided, the endpoint will be ${uri}/search. If not provided, defaults to /search.

    Returns Search

    // Create with default endpoint (/search)
    const search = new Search();

    // Create with custom base URI
    const search = new Search('/api/v1');
    // This will use endpoint: /api/v1/search

Methods

  • Perform a universal search across multiple resource types

    Searches across agents, apps, tools, and models simultaneously based on the provided query parameters. Returns results grouped by resource type.

    Parameters

    • params: SearchQueryParams

      Search query parameters

      • [key: string]: any
      • Optionalq?: string
      • Optionalsearch_types?: string[]
      • Optionalsearch_type?: string
      • Optionallimit?: number

    Returns Promise<SearchResponse>

    Promise resolving to search results grouped by resource type

    // Search all resource types
    const results = await search.query({
    q: 'customer support AI',
    limit: 10
    });

    // Access results by type
    if (results.data.agents) {
    console.log(`Found ${results.data.agents.length} agents`);
    }
    if (results.data.apps) {
    console.log(`Found ${results.data.apps.length} apps`);
    }
    // Search specific types only
    const results = await search.query({
    q: 'AI assistant',
    search_types: ['agent', 'model'],
    limit: 5
    });

    // Check paging information
    if (results.paging?.agents) {
    console.log('Agent search pagination:', results.paging.agents);
    }

    When API request fails