// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { PagePromise, SearchHitsOffset, type SearchHitsOffsetParams } from '../core/pagination'; import { RequestOptions } from '../internal/request-options'; export class Search extends APIResource { /** * Search for assets. At least one of the following fields must have a value: * `query`, `filter`, `image`, or `images`. * * `image`, `images` are mutually exclusive. */ assetSearch( params: SearchAssetSearchParams, options?: RequestOptions, ): PagePromise { const { originalAssets, projectId, ...body } = params; return this._client.getAPIList('/search/assets', SearchHitsOffset, { query: { originalAssets, projectId }, body, method: 'post', ...options, }); } /** * Search for models. At least one of the following fields must have a value: * `query`, `filter`, `image`, or `images`. * * `image`, and `images` are mutually exclusive. */ modelSearch( params: SearchModelSearchParams, options?: RequestOptions, ): PagePromise { const { originalAssets, originalModels, projectId, ...body } = params; return this._client.getAPIList('/search/models', SearchHitsOffset, { query: { originalAssets, originalModels, projectId }, body, method: 'post', ...options, }); } } export type SearchAssetSearchResponsesSearchHitsOffset = SearchHitsOffset; export type SearchModelSearchResponsesSearchHitsOffset = SearchHitsOffset; export interface SearchAssetSearchResponse { /** * Unique identifier for the asset (e.g., "asset_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; /** * User ID of the asset creator/author */ authorId: string; /** * Array of collection IDs this asset belongs to */ collectionIds: Array; /** * Creation timestamp in ISO 8601 format (e.g., "2025-01-16T11:19:41.579Z") */ createdAt: string; /** * Metadata containing detailed information about the asset's properties and * generation parameters */ metadata: SearchAssetSearchResponse.Metadata; /** * MIME type of the asset (e.g., "image/png", "image/jpeg") */ mimeType: string; /** * Array of detected NSFW categories */ nsfw: Array; /** * Project ID of the asset owner */ ownerId: string; /** * Privacy setting of the asset ("public", "private", or "unlisted") */ privacy: string; /** * Array of user-assigned tags for categorization */ tags: Array; /** * Team ID of the asset owner */ teamId: string; /** * Last modification timestamp in ISO 8601 format (e.g., * "2025-01-16T11:19:41.579Z") */ updatedAt: string; /** * Signed URL of the asset */ url: string; /** * Indexed body for text assets (`AssetKind.Text`). The full content lives in S3; * this field carries up to TEXT_INDEX_MAX_BYTES of UTF-8 for BM25 lookup. Always * undefined for non-text assets. */ content?: string; /** * Textual description of the asset. Can be either: * * - User-provided description for training images * - Automatically generated caption for images and videos assets * - Automatically generated description for audio assets */ description?: string; /** * Score assigned to the asset based on usage and popularity */ score?: number; /** * Thumbnail preview of the asset 3D, video... */ thumbnail?: SearchAssetSearchResponse.Thumbnail; /** * Transcription of the asset. Can be either: * * - Automatically generated transcription for audio assets with speech */ transcription?: string; } export namespace SearchAssetSearchResponse { /** * Metadata containing detailed information about the asset's properties and * generation parameters */ export interface Metadata { /** * Aspect ratio of the asset (e.g., "1:1", "16:9") */ aspectRatio?: string; /** * ID of the base model used for generation */ baseModelId?: string; /** * Guidance scale used for diffusion models to control prompt adherence */ guidance?: number; /** * Height of the asset in pixels */ height?: number; /** * Classification of the asset (e.g., "image", "video") */ kind?: string; /** * ID of the specific model used if asset is model-based */ modelId?: string; /** * Type of model used for generation (e.g., "flux.1", "flux.1-lora") */ modelType?: string; /** * Custom name given to the asset */ name?: string; /** * Negative prompt used during generation to specify what to avoid */ negativePrompt?: string; /** * For Flux models: controls the influence of the negative prompt */ negativePromptStrength?: number; /** * Number of inference steps used during generation */ numInferenceSteps?: number; /** * ID of the parent job that created this asset */ parentJobId?: string; /** * Text prompt used to generate the asset */ prompt?: string; /** * Scheduler algorithm used during generation */ scheduler?: string; /** * Random seed used for generation, enables reproducibility */ seed?: string; /** * File size of the asset in bytes */ size?: number; /** * Text used to generate the asset: mainly for speech to text */ text?: string; /** * Thumbnail image information for the asset. Ex. Canvas thumbnail */ thumbnail?: Metadata.Thumbnail; /** * Specific type/category of the asset (e.g., "canvas", "inference-txt") */ type?: string; /** * Width of the asset in pixels */ width?: number; } export namespace Metadata { /** * Thumbnail image information for the asset. Ex. Canvas thumbnail */ export interface Thumbnail { /** * ID of the asset used as thumbnail */ assetId: string; } } /** * Thumbnail preview of the asset 3D, video... */ export interface Thumbnail { /** * ID of the asset used as thumbnail */ assetId: string; /** * Signed URL of the thumbnail */ url: string; } } export interface SearchModelSearchResponse { /** * Unique identifier for the model (e.g., "model_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; /** * User ID of the model creator/author */ authorId: string; /** * Array of model capabilities */ capabilities: Array; /** * Array of collection IDs this model belongs to */ collectionIds: Array; /** * Array of concept models associated with this model Each concept contains a * reference to its source model */ concepts: Array; /** * Creation timestamp in ISO 8601 format (e.g., "2025-01-16T11:19:41.579Z") */ createdAt: string; /** * Array of example asset IDs associated with this model */ exampleAssetIds: Array; /** * Display name of the model */ name: string; /** * Project ID of the model owner */ ownerId: string; /** * Privacy setting of the model ("public", "private", or "unlisted") */ privacy: string; /** * Short description of the model */ shortDescription: string; /** * Source/origin of the model (e.g., "training", "import") */ source: string; /** * Array of user-assigned tags for categorization */ tags: Array; /** * Team ID of the model owner */ teamId: string; /** * Number of images used to train this model */ trainingImagesNumber: number; /** * Type of the model (e.g., "flux.1", "flux.1-lora") */ type: string; /** * Last modification timestamp in ISO 8601 format (e.g., * "2025-01-16T11:19:41.579Z") */ updatedAt: string; /** * ID of the parent model this model was derived from */ parentModelId?: string; /** * Score assigned to the model based on usage and popularity */ score?: number; /** * Thumbnail image information for the model */ thumbnail?: SearchModelSearchResponse.Thumbnail; } export namespace SearchModelSearchResponse { export interface Concept { /** * ID of the concept's source model */ modelId: string; } /** * Thumbnail image information for the model */ export interface Thumbnail { /** * ID of the asset used as thumbnail */ assetId: string; /** * Signed URL of the thumbnail */ url: string; } } export interface SearchAssetSearchParams extends SearchHitsOffsetParams { /** * Query param: If set to true, returns the original asset without transformation */ originalAssets?: boolean; /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; /** * Body param: Filter queries by an attribute's value */ filter?: string; /** * Body param: Maximum number of documents returned for a page. Must be used with * `page`. */ hitsPerPage?: number; /** * Body param: Search for similar images with `image` as a reference. * * Must be an existing `AssetId` or a valid data URL. */ image?: string; /** * Body param: Search for similar images with `images.like` and `images.unlike` as * a reference * * Must be arrays of existing `AssetId` or valid data URLs. */ images?: SearchAssetSearchParams.Images; /** * Body param: Image embedding ratio for hybrid search, applied when `image`, * `images.like`, or `images.unlike` are provided */ imageSemanticRatio?: number; /** * Body param: Maximum number of documents returned. Must be used with `offset`. */ limit?: number; /** * Body param: Request a specific page of results. Must be used with `hitsPerPage`. */ page?: number; /** * Body param: Search for public images not necessarily belonging to the current * `ownerId` */ public?: boolean; /** * Body param: A string used for querying search results. */ query?: string; /** * Body param: Query embedding for hybrid search, if possible */ querySemanticRatio?: number; /** * Body param: Sort the search results by the given attributes. Each attribute in * the list must be followed by a colon (`:`) and the preferred sorting order: * either ascending (`asc`) or descending (`desc`). * * Example: `['createdAt:desc']` */ sortBy?: Array; } export namespace SearchAssetSearchParams { /** * Search for similar images with `images.like` and `images.unlike` as a reference * * Must be arrays of existing `AssetId` or valid data URLs. */ export interface Images { /** * Search for similar images with `images.like` as a reference. * * Must be an array of existing `AssetId` or valid data URLs. */ like?: Array; /** * Search for images that are not similar to `images.unlike` as a reference. * * Must be an array of existing `AssetId` or valid data URLs. */ unlike?: Array; } } export interface SearchModelSearchParams extends SearchHitsOffsetParams { /** * Query param: If set to true, returns the original asset without transformation */ originalAssets?: boolean; /** * Query param */ originalModels?: unknown; /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; /** * Body param: Filter queries by an attribute's value */ filter?: string; /** * Body param: Maximum number of documents returned for a page. Must be used with * `page`. */ hitsPerPage?: number; /** * Body param: Search for model with `image` as a reference * * Must be an existing `AssetId` or a valid data URL. */ image?: string; /** * Body param: Search for model with `images.like` and `images.unlike` as a * reference * * Must be an array of existing `AssetId` or valid data URLs. */ images?: SearchModelSearchParams.Images; /** * Body param: Image embedding ratio for hybrid search, applied when `image`, * `images.like`, or `images.unlike` are provided */ imageSemanticRatio?: number; /** * Body param: Maximum number of documents returned. Must be used with `offset`. */ limit?: number; /** * Body param: Request a specific page of results. Must be used with `hitsPerPage`. */ page?: number; /** * Body param: Search for public images not necessarily belonging to the current * `ownerId` */ public?: boolean; /** * Body param: A string used for querying search results. */ query?: string; /** * Body param: Query embedding for hybrid search, if possible */ querySemanticRatio?: number; /** * Body param: Sort the search results by the given attributes. Each attribute in * the list must be followed by a colon (`:`) and the preferred sorting order: * either ascending (`asc`) or descending (`desc`). * * Example: `['createdAt:desc']` */ sortBy?: Array; } export namespace SearchModelSearchParams { /** * Search for model with `images.like` and `images.unlike` as a reference * * Must be an array of existing `AssetId` or valid data URLs. */ export interface Images { /** * Search for model images with `images.like` as a reference * * Must be an array of existing `AssetId` or valid data URLs. */ like?: Array; /** * Search for model images that are not similar to `images.unlike` as a reference * * Must be an array of existing `AssetId` or valid data URLs. */ unlike?: Array; } } export declare namespace Search { export { type SearchAssetSearchResponse as SearchAssetSearchResponse, type SearchModelSearchResponse as SearchModelSearchResponse, type SearchAssetSearchResponsesSearchHitsOffset as SearchAssetSearchResponsesSearchHitsOffset, type SearchModelSearchResponsesSearchHitsOffset as SearchModelSearchResponsesSearchHitsOffset, type SearchAssetSearchParams as SearchAssetSearchParams, type SearchModelSearchParams as SearchModelSearchParams, }; }