@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api Replicate HTTP API
@base https://api.replicate.com/v1
@version 1.0.0-a1
@auth Bearer bearer
@endpoints 36
@hint download_for_search
@toc account(1), collections(2), deployments(6), files(5), hardware(1), models(12), predictions(4), search(1), trainings(3), webhooks(1)

@group account
@endpoint GET /account
@returns(200) {avatar_url: str(uri), github_url: str(uri), name: str, type: str, username: str}

@endgroup

@group collections
@endpoint GET /collections
@returns(200) {next: str?, previous: str?, results: [map]}

@endpoint GET /collections/{collection_slug}
@required {collection_slug: str}
@returns(200) {description: str, full_description: str?, models: [map], name: str, slug: str}

@endgroup

@group deployments
@endpoint GET /deployments
@returns(200) {next: str?, previous: str?, results: [map]}

@endpoint POST /deployments
@required {hardware: str, max_instances: int, min_instances: int, model: str, name: str, version: str}
@returns(200) {current_release: map{configuration: map{hardware: str, max_instances: int, min_instances: int}, created_at: str(date-time), created_by: map{avatar_url: str(uri), github_url: str(uri), name: str, type: str, username: str}, model: str, number: int, version: str}, name: str, owner: str}

@endpoint DELETE /deployments/{deployment_owner}/{deployment_name}
@required {deployment_owner: str, deployment_name: str}
@returns(204)

@endpoint GET /deployments/{deployment_owner}/{deployment_name}
@required {deployment_owner: str, deployment_name: str}
@returns(200) {current_release: map{configuration: map{hardware: str, max_instances: int, min_instances: int}, created_at: str(date-time), created_by: map{avatar_url: str(uri), github_url: str(uri), name: str, type: str, username: str}, model: str, number: int, version: str}, name: str, owner: str}

@endpoint PATCH /deployments/{deployment_owner}/{deployment_name}
@required {deployment_owner: str, deployment_name: str}
@optional {hardware: str, max_instances: int, min_instances: int, version: str}
@returns(200) {current_release: map{configuration: map{hardware: str, max_instances: int, min_instances: int}, created_at: str(date-time), created_by: map{avatar_url: str(uri), github_url: str(uri), name: str, type: str, username: str}, model: str, number: int, version: str}, name: str, owner: str}

@endpoint POST /deployments/{deployment_owner}/{deployment_name}/predictions
@required {deployment_owner: str, deployment_name: str, input: map}
@optional {Prefer: str, Cancel-After: str, stream: bool, webhook: str, webhook_events_filter: [str]}
@returns(201) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}
@returns(202) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}

@endgroup

@group files
@endpoint GET /files
@returns(200) {next: str(uri)?, previous: str(uri)?, results: [map]}

@endpoint POST /files
@returns(201) {checksums: map{sha256: str}, content_type: str, created_at: str(date-time), expires_at: str(date-time), id: str, metadata: map, size: int, urls: map{get: str(uri)}}
@errors {413}

@endpoint DELETE /files/{file_id}
@required {file_id: str}
@returns(204)
@errors {404}

@endpoint GET /files/{file_id}
@required {file_id: str}
@returns(200) {checksums: map{sha256: str}, content_type: str, created_at: str(date-time), expires_at: str(date-time), id: str, metadata: map, size: int, urls: map{get: str(uri)}}
@errors {404}

@endpoint GET /files/{file_id}/download
@required {file_id: str, owner: str, expiry: int(int64), signature: str}
@returns(200)
@errors {404}

@endgroup

@group hardware
@endpoint GET /hardware
@returns(200)

@endgroup

@group models
@endpoint GET /models
@optional {sort_by: str(model_created_at/latest_version_created_at)=latest_version_created_at, sort_direction: str(asc/desc)=desc}
@returns(200) {next: str?, previous: str?, results: [map]}

@endpoint POST /models
@required {hardware: str, name: str, owner: str, visibility: str(public/private)}
@optional {cover_image_url: str, description: str, github_url: str, license_url: str, paper_url: str}
@returns(201) {cover_image_url: str(uri)?, default_example: map?, description: str?, github_url: str(uri)?, is_official: bool, latest_version: map?, license_url: str(uri)?, name: str, owner: str, paper_url: str(uri)?, run_count: int, url: str(uri), visibility: str}

@endpoint DELETE /models/{model_owner}/{model_name}
@required {model_owner: str, model_name: str}
@returns(204)

@endpoint GET /models/{model_owner}/{model_name}
@required {model_owner: str, model_name: str}
@returns(200) {cover_image_url: str(uri)?, default_example: map?, description: str?, github_url: str(uri)?, is_official: bool, latest_version: map?, license_url: str(uri)?, name: str, owner: str, paper_url: str(uri)?, run_count: int, url: str(uri), visibility: str}

@endpoint PATCH /models/{model_owner}/{model_name}
@required {model_owner: str, model_name: str}
@optional {description: str, github_url: str, license_url: str, paper_url: str, readme: str, weights_url: str}
@returns(200) {cover_image_url: str(uri)?, default_example: map?, description: str?, github_url: str(uri)?, is_official: bool, latest_version: map?, license_url: str(uri)?, name: str, owner: str, paper_url: str(uri)?, run_count: int, url: str(uri), visibility: str}

@endpoint GET /models/{model_owner}/{model_name}/examples
@required {model_owner: str, model_name: str}
@returns(200) {next: str?, previous: str?, results: [map]}

@endpoint POST /models/{model_owner}/{model_name}/predictions
@required {model_owner: str, model_name: str, input: map}
@optional {Prefer: str, Cancel-After: str, stream: bool, webhook: str, webhook_events_filter: [str]}
@returns(201) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}
@returns(202) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}

@endpoint GET /models/{model_owner}/{model_name}/readme
@required {model_owner: str, model_name: str}
@returns(200)
@errors {404}

@endpoint GET /models/{model_owner}/{model_name}/versions
@required {model_owner: str, model_name: str}
@returns(200) {next: str?, previous: str?, results: [map]}

@endpoint DELETE /models/{model_owner}/{model_name}/versions/{version_id}
@required {model_owner: str, model_name: str, version_id: str}
@returns(202)

@endpoint GET /models/{model_owner}/{model_name}/versions/{version_id}
@required {model_owner: str, model_name: str, version_id: str}
@returns(200) {cog_version: str?, created_at: str(date-time), id: str, openapi_schema: map?}

@endpoint POST /models/{model_owner}/{model_name}/versions/{version_id}/trainings
@required {model_owner: str, model_name: str, version_id: str, destination: str, input: map}
@optional {webhook: str, webhook_events_filter: [str]}
@returns(201) {completed_at: str(date-time), created_at: str(date-time), error: str?, id: str, input: map, logs: str, metrics: map{predict_time: num, total_time: num}, model: str, output: map{version: str, weights: str}, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri)}, version: str}

@endgroup

@group predictions
@endpoint GET /predictions
@optional {created_after: str(date-time), created_before: str(date-time), source: str}
@returns(200) {next: str(uri)?, previous: str(uri)?, results: [map]}

@endpoint POST /predictions
@required {input: map, version: str}
@optional {Prefer: str, Cancel-After: str, stream: bool, webhook: str, webhook_events_filter: [str]}
@returns(201) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}
@returns(202) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}

@endpoint GET /predictions/{prediction_id}
@required {prediction_id: str}
@returns(200) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}

@endpoint POST /predictions/{prediction_id}/cancel
@required {prediction_id: str}
@returns(200) {completed_at: str(date-time), created_at: str(date-time), data_removed: bool, deadline: str(date-time), deployment: str, error: str?, id: str, input: map, logs: str, metrics: map{total_time: num}, model: str, output: any, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri), stream: str(uri), web: str(uri)}, version: any}

@endgroup

@group search
@endpoint GET /search
@required {query: str}
@optional {limit: int=20}
@returns(200) {collections: [map], models: [map], pages: [map], query: str}
@errors {400, 500}

@endgroup

@group trainings
@endpoint GET /trainings
@returns(200) {next: str?, previous: str?, results: [map]}

@endpoint GET /trainings/{training_id}
@required {training_id: str}
@returns(200) {completed_at: str(date-time), created_at: str(date-time), error: str?, id: str, input: map, logs: str, metrics: map{predict_time: num, total_time: num}, model: str, output: map{version: str, weights: str}, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri)}, version: str}

@endpoint POST /trainings/{training_id}/cancel
@required {training_id: str}
@returns(200) {completed_at: str(date-time), created_at: str(date-time), error: str?, id: str, input: map, logs: str, metrics: map{predict_time: num, total_time: num}, model: str, output: map{version: str, weights: str}, source: str, started_at: str(date-time), status: str, urls: map{cancel: str(uri), get: str(uri)}, version: str}

@endgroup

@group webhooks
@endpoint GET /webhooks/default/secret
@returns(200) {key: str}

@endgroup

@end
