import { APIResource } from "../../core/resource.js"; import * as ExamplesAPI from "./examples.js"; import { ExampleListParams, Examples } from "./examples.js"; import * as PredictionsAPI from "./predictions.js"; import { PredictionCreateParams, Predictions } from "./predictions.js"; import * as ReadmeAPI from "./readme.js"; import { Readme, ReadmeGetParams, ReadmeGetResponse } from "./readme.js"; import * as VersionsAPI from "./versions.js"; import { VersionDeleteParams, VersionGetParams, VersionListParams, Versions } from "./versions.js"; import { APIPromise } from "../../core/api-promise.js"; import { CursorURLPage, PagePromise } from "../../core/pagination.js"; import { RequestOptions } from "../../internal/request-options.js"; export declare class Models extends APIResource { examples: ExamplesAPI.Examples; predictions: PredictionsAPI.Predictions; readme: ReadmeAPI.Readme; versions: VersionsAPI.Versions; /** * Create a model. * * Example cURL request: * * ```console * curl -s -X POST \ * -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ * -H 'Content-Type: application/json' \ * -d '{"owner": "alice", "name": "hot-dog-detector", "description": "Detect hot dogs in images", "visibility": "public", "hardware": "cpu"}' \ * https://api.replicate.com/v1/models * ``` * * The response will be a model object in the following format: * * ```json * { * "url": "https://replicate.com/alice/hot-dog-detector", * "owner": "alice", * "name": "hot-dog-detector", * "description": "Detect hot dogs in images", * "visibility": "public", * "github_url": null, * "paper_url": null, * "license_url": null, * "run_count": 0, * "cover_image_url": null, * "default_example": null, * "latest_version": null * } * ``` * * Note that there is a limit of 1,000 models per account. For most purposes, we * recommend using a single model and pushing new * [versions](https://replicate.com/docs/how-does-replicate-work#versions) of the * model as you make changes to it. * * @example * ```ts * await replicate.models.create({ * hardware: 'cpu', * name: 'hot-dog-detector', * owner: 'alice', * visibility: 'public', * }); * ``` */ create(body: ModelCreateParams, options?: RequestOptions): APIPromise; /** * Get a paginated list of public models. * * Example cURL request: * * ```console * curl -s \ * -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ * https://api.replicate.com/v1/models * ``` * * The response will be a pagination object containing a list of model objects. * * See the [`models.get`](#models.get) docs for more details about the model * object. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const modelListResponse of replicate.models.list()) { * // ... * } * ``` */ list(options?: RequestOptions): PagePromise; /** * Delete a model * * Model deletion has some restrictions: * * - You can only delete models you own. * - You can only delete private models. * - You can only delete models that have no versions associated with them. * Currently you'll need to * [delete the model's versions](#models.versions.delete) before you can delete * the model itself. * * Example cURL request: * * ```command * curl -s -X DELETE \ * -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ * https://api.replicate.com/v1/models/replicate/hello-world * ``` * * The response will be an empty 204, indicating the model has been deleted. * * @example * ```ts * await replicate.models.delete({ * model_owner: 'model_owner', * model_name: 'model_name', * }); * ``` */ delete(params: ModelDeleteParams, options?: RequestOptions): APIPromise; /** * Example cURL request: * * ```console * curl -s \ * -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ * https://api.replicate.com/v1/models/replicate/hello-world * ``` * * The response will be a model object in the following format: * * ```json * { * "url": "https://replicate.com/replicate/hello-world", * "owner": "replicate", * "name": "hello-world", * "description": "A tiny model that says hello", * "visibility": "public", * "github_url": "https://github.com/replicate/cog-examples", * "paper_url": null, * "license_url": null, * "run_count": 5681081, * "cover_image_url": "...", * "default_example": {...}, * "latest_version": {...}, * } * ``` * * The model object includes the * [input and output schema](https://replicate.com/docs/reference/openapi#model-schemas) * for the latest version of the model. * * Here's an example showing how to fetch the model with cURL and display its input * schema with [jq](https://stedolan.github.io/jq/): * * ```console * curl -s \ * -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ * https://api.replicate.com/v1/models/replicate/hello-world \ * | jq ".latest_version.openapi_schema.components.schemas.Input" * ``` * * This will return the following JSON object: * * ```json * { * "type": "object", * "title": "Input", * "required": ["text"], * "properties": { * "text": { * "type": "string", * "title": "Text", * "x-order": 0, * "description": "Text to prefix with 'hello '" * } * } * } * ``` * * The `cover_image_url` string is an HTTPS URL for an image file. This can be: * * - An image uploaded by the model author. * - The output file of the example prediction, if the model author has not set a * cover image. * - The input file of the example prediction, if the model author has not set a * cover image and the example prediction has no output file. * - A generic fallback image. * * The `default_example` object is a [prediction](#predictions.get) created with * this model. * * The `latest_version` object is the model's most recently pushed * [version](#models.versions.get). * * @example * ```ts * await replicate.models.get({ * model_owner: 'model_owner', * model_name: 'model_name', * }); * ``` */ get(params: ModelGetParams, options?: RequestOptions): APIPromise; /** * Get a list of public models matching a search query. * * Example cURL request: * * ```console * curl -s -X QUERY \ * -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ * -H "Content-Type: text/plain" \ * -d "hello" \ * https://api.replicate.com/v1/models * ``` * * The response will be a paginated JSON object containing an array of model * objects. * * See the [`models.get`](#models.get) docs for more details about the model * object. * * @example * ```ts * await replicate.models.search({ body: 'body' }); * ``` */ search(params: ModelSearchParams, options?: RequestOptions): APIPromise; } export type ModelListResponsesCursorURLPage = CursorURLPage; export interface ModelListResponse { /** * A URL for the model's cover image */ cover_image_url?: string | null; /** * The model's default example prediction */ default_example?: unknown | null; /** * A description of the model */ description?: string; /** * A URL for the model's source code on GitHub */ github_url?: string | null; /** * The model's latest version */ latest_version?: unknown | null; /** * A URL for the model's license */ license_url?: string | null; /** * The name of the model */ name?: string; /** * The name of the user or organization that owns the model */ owner?: string; /** * A URL for the model's paper */ paper_url?: string | null; /** * The number of times the model has been run */ run_count?: number; /** * The URL of the model on Replicate */ url?: string; /** * Whether the model is public or private */ visibility?: 'public' | 'private'; } export interface ModelCreateParams { /** * The SKU for the hardware used to run the model. Possible values can be retrieved * from the `hardware.list` endpoint. */ hardware: string; /** * The name of the model. This must be unique among all models owned by the user or * organization. */ name: string; /** * The name of the user or organization that will own the model. This must be the * same as the user or organization that is making the API request. In other words, * the API token used in the request must belong to this user or organization. */ owner: string; /** * Whether the model should be public or private. A public model can be viewed and * run by anyone, whereas a private model can be viewed and run only by the user or * organization members that own the model. */ visibility: 'public' | 'private'; /** * A URL for the model's cover image. This should be an image file. */ cover_image_url?: string; /** * A description of the model. */ description?: string; /** * A URL for the model's source code on GitHub. */ github_url?: string; /** * A URL for the model's license. */ license_url?: string; /** * A URL for the model's paper. */ paper_url?: string; } export interface ModelDeleteParams { /** * The name of the user or organization that owns the model. */ model_owner: string; /** * The name of the model. */ model_name: string; } export interface ModelGetParams { /** * The name of the user or organization that owns the model. */ model_owner: string; /** * The name of the model. */ model_name: string; } export interface ModelSearchParams { /** * The search query */ body: string; } export declare namespace Models { export { type ModelListResponse as ModelListResponse, type ModelListResponsesCursorURLPage as ModelListResponsesCursorURLPage, type ModelCreateParams as ModelCreateParams, type ModelDeleteParams as ModelDeleteParams, type ModelGetParams as ModelGetParams, type ModelSearchParams as ModelSearchParams, }; export { Examples as Examples, type ExampleListParams as ExampleListParams }; export { Predictions as Predictions, type PredictionCreateParams as PredictionCreateParams }; export { Readme as Readme, type ReadmeGetResponse as ReadmeGetResponse, type ReadmeGetParams as ReadmeGetParams, }; export { Versions as Versions, type VersionListParams as VersionListParams, type VersionDeleteParams as VersionDeleteParams, type VersionGetParams as VersionGetParams, }; } //# sourceMappingURL=models.d.ts.map